vm-tool 1.0.10__tar.gz → 1.0.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vm_tool-1.0.11/MANIFEST.in +1 -0
- {vm_tool-1.0.10/vm_tool.egg-info → vm_tool-1.0.11}/PKG-INFO +1 -1
- {vm_tool-1.0.10 → vm_tool-1.0.11}/setup.py +1 -1
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool/cli.py +1 -1
- vm_tool-1.0.11/vm_tool/vm_setup/docker/create_docker_service.yml +53 -0
- vm_tool-1.0.11/vm_tool/vm_setup/docker/install_docker_and_compose.yml +70 -0
- vm_tool-1.0.11/vm_tool/vm_setup/inventory.yml +1 -0
- vm_tool-1.0.11/vm_tool/vm_setup/setup.yml +57 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11/vm_tool.egg-info}/PKG-INFO +1 -1
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool.egg-info/SOURCES.txt +6 -1
- {vm_tool-1.0.10 → vm_tool-1.0.11}/LICENSE +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/setup.cfg +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool/runner.py +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool/ssh.py +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool.egg-info/entry_points.txt +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool.egg-info/requires.txt +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.11}/vm_tool.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include vm_tool/vm_setup *
|
|
@@ -11,7 +11,7 @@ else:
|
|
|
11
11
|
|
|
12
12
|
setup(
|
|
13
13
|
name='vm_tool',
|
|
14
|
-
version='1.0.
|
|
14
|
+
version='1.0.11', # This will be updated by bump2version
|
|
15
15
|
packages=find_packages(),
|
|
16
16
|
description='A Comprehensive Tool for Setting Up Virtual Machines Using Ansible.',
|
|
17
17
|
long_description=long_description,
|
|
@@ -2,7 +2,7 @@ import argparse
|
|
|
2
2
|
|
|
3
3
|
def main():
|
|
4
4
|
parser = argparse.ArgumentParser(description='Setup VMs using Ansible.')
|
|
5
|
-
parser.add_argument('--version', action='version', version='1.0.
|
|
5
|
+
parser.add_argument('--version', action='version', version='1.0.11')
|
|
6
6
|
|
|
7
7
|
args = parser.parse_args()
|
|
8
8
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
- name: Clean up Docker Environment and Set up Docker Service
|
|
2
|
+
block:
|
|
3
|
+
- name: Check if Docker Service File Exists
|
|
4
|
+
ansible.builtin.stat:
|
|
5
|
+
path: "{{ service_file_path }}"
|
|
6
|
+
register: service_file_stat
|
|
7
|
+
|
|
8
|
+
- name: Stop project service and ignore errors
|
|
9
|
+
ansible.builtin.systemd:
|
|
10
|
+
name: project
|
|
11
|
+
state: stopped
|
|
12
|
+
ignore_errors: yes
|
|
13
|
+
|
|
14
|
+
# - name: Run Docker System Prune
|
|
15
|
+
# ansible.builtin.command:
|
|
16
|
+
# cmd: docker system prune -f
|
|
17
|
+
# ignore_errors: yes
|
|
18
|
+
|
|
19
|
+
- name: Remove Existing Docker Service File
|
|
20
|
+
ansible.builtin.file:
|
|
21
|
+
path: "{{ service_file_path }}"
|
|
22
|
+
state: absent
|
|
23
|
+
when: service_file_stat.stat.exists
|
|
24
|
+
|
|
25
|
+
- name: Create Docker Service File
|
|
26
|
+
ansible.builtin.file:
|
|
27
|
+
path: "{{ service_file_path }}"
|
|
28
|
+
state: touch
|
|
29
|
+
mode: '0644'
|
|
30
|
+
|
|
31
|
+
- name: Insert Docker Service Configuration
|
|
32
|
+
ansible.builtin.blockinfile:
|
|
33
|
+
path: "{{ service_file_path }}"
|
|
34
|
+
block: |
|
|
35
|
+
[Unit]
|
|
36
|
+
Description=Project Docker Container
|
|
37
|
+
After=docker.service
|
|
38
|
+
|
|
39
|
+
[Service]
|
|
40
|
+
Type=simple
|
|
41
|
+
WorkingDirectory={{ project_dest_dir }}
|
|
42
|
+
ExecStart=docker compose -f docker-compose.yml up -d
|
|
43
|
+
Restart=always
|
|
44
|
+
RestartSec=10s
|
|
45
|
+
|
|
46
|
+
[Install]
|
|
47
|
+
WantedBy=multi-user.target
|
|
48
|
+
|
|
49
|
+
- name: Reload Systemd Daemon
|
|
50
|
+
ansible.builtin.systemd:
|
|
51
|
+
daemon_reload: yes
|
|
52
|
+
|
|
53
|
+
become: yes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
- name: Install Docker and Docker Compose on Ubuntu
|
|
2
|
+
block:
|
|
3
|
+
- name: Check if Docker is installed
|
|
4
|
+
ansible.builtin.command: docker --version
|
|
5
|
+
register: docker_installed
|
|
6
|
+
ignore_errors: yes
|
|
7
|
+
|
|
8
|
+
- name: Check if Docker Compose is installed
|
|
9
|
+
ansible.builtin.command: docker compose version
|
|
10
|
+
register: docker_compose_installed
|
|
11
|
+
ignore_errors: yes
|
|
12
|
+
|
|
13
|
+
# - name: Update apt package index
|
|
14
|
+
# ansible.builtin.apt:
|
|
15
|
+
# update_cache: yes
|
|
16
|
+
# when: docker_installed.rc != 0 or docker_compose_installed.rc != 0
|
|
17
|
+
|
|
18
|
+
- name: Install prerequisites
|
|
19
|
+
ansible.builtin.apt:
|
|
20
|
+
name:
|
|
21
|
+
- curl
|
|
22
|
+
- apt-transport-https
|
|
23
|
+
- ca-certificates
|
|
24
|
+
- gnupg
|
|
25
|
+
- lsb-release
|
|
26
|
+
- software-properties-common
|
|
27
|
+
state: present
|
|
28
|
+
|
|
29
|
+
- name: Add Docker GPG key
|
|
30
|
+
ansible.builtin.shell:
|
|
31
|
+
cmd: |
|
|
32
|
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
33
|
+
when: docker_installed.rc != 0 or docker_compose_installed.rc != 0
|
|
34
|
+
|
|
35
|
+
- name: Add Docker repository
|
|
36
|
+
ansible.builtin.shell:
|
|
37
|
+
cmd: |
|
|
38
|
+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
39
|
+
when: docker_installed.rc != 0 or docker_compose_installed.rc != 0
|
|
40
|
+
|
|
41
|
+
- name: Set up the Docker stable repository
|
|
42
|
+
ansible.builtin.command: echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
43
|
+
when: docker_installed.rc != 0 or docker_compose_installed.rc != 0
|
|
44
|
+
|
|
45
|
+
- name: Update apt package index again
|
|
46
|
+
ansible.builtin.apt:
|
|
47
|
+
update_cache: yes
|
|
48
|
+
when: docker_installed.rc != 0 or docker_compose_installed.rc != 0
|
|
49
|
+
|
|
50
|
+
- name: Install Docker and Docker Compose
|
|
51
|
+
ansible.builtin.apt:
|
|
52
|
+
name:
|
|
53
|
+
- docker-ce
|
|
54
|
+
- docker-ce-cli
|
|
55
|
+
- containerd.io
|
|
56
|
+
- docker-compose-plugin
|
|
57
|
+
state: present
|
|
58
|
+
when: docker_installed.rc != 0 or docker_compose_installed.rc != 0
|
|
59
|
+
|
|
60
|
+
- name: Enable and Start Docker service
|
|
61
|
+
ansible.builtin.systemd:
|
|
62
|
+
name: docker
|
|
63
|
+
enabled: yes
|
|
64
|
+
state: started
|
|
65
|
+
when: docker_installed.rc != 0
|
|
66
|
+
|
|
67
|
+
- name: Change permissions for Docker socket
|
|
68
|
+
ansible.builtin.command: sudo chmod 666 /var/run/docker.sock
|
|
69
|
+
ignore_errors: yes
|
|
70
|
+
become: yes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
localhost ansible_connection=local
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
- name: Setup Docker and Docker Compose on Ubuntu
|
|
2
|
+
hosts: all
|
|
3
|
+
gather_facts: yes
|
|
4
|
+
|
|
5
|
+
vars:
|
|
6
|
+
github_project_url: "{{ lookup('env', 'GITHUB_PROJECT_URL') }}"
|
|
7
|
+
github_username: "{{ lookup('env', 'GITHUB_USERNAME') }}"
|
|
8
|
+
github_token: "{{ lookup('env', 'GITHUB_TOKEN') }}"
|
|
9
|
+
static_playbook_dir: "{{playbook_dir}}"
|
|
10
|
+
|
|
11
|
+
tasks:
|
|
12
|
+
|
|
13
|
+
- name: Set project_dest_dir variable
|
|
14
|
+
set_fact:
|
|
15
|
+
project_dest_dir: "{{ static_playbook_dir }}/project"
|
|
16
|
+
|
|
17
|
+
- name: Set project_repo_url variable
|
|
18
|
+
set_fact:
|
|
19
|
+
project_repo_url: "{{ github_project_url }}"
|
|
20
|
+
|
|
21
|
+
- name: Configure Git with GitHub token
|
|
22
|
+
shell: |
|
|
23
|
+
git config --global credential.helper store
|
|
24
|
+
echo "https://{{ github_username }}:{{ github_token }}@github.com" > ~/.git-credentials
|
|
25
|
+
become: yes
|
|
26
|
+
|
|
27
|
+
- name: Remove existing Project repository if present
|
|
28
|
+
file:
|
|
29
|
+
path: "{{ project_dest_dir }}"
|
|
30
|
+
state: absent
|
|
31
|
+
force: yes
|
|
32
|
+
become: yes
|
|
33
|
+
|
|
34
|
+
- name: Clone the Project repository
|
|
35
|
+
git:
|
|
36
|
+
repo: "{{ project_repo_url }}"
|
|
37
|
+
dest: "{{ project_dest_dir }}"
|
|
38
|
+
version: main
|
|
39
|
+
become: yes
|
|
40
|
+
|
|
41
|
+
- name: Set service_file_path variable
|
|
42
|
+
set_fact:
|
|
43
|
+
service_file_path: /etc/systemd/system/project.service
|
|
44
|
+
|
|
45
|
+
- name: Adding Docker and Compose packages
|
|
46
|
+
include_tasks: docker/install_docker_and_compose.yml
|
|
47
|
+
|
|
48
|
+
- name: Create Docker Service
|
|
49
|
+
include_tasks: docker/create_docker_service.yml
|
|
50
|
+
|
|
51
|
+
- name: Enable and start project service
|
|
52
|
+
ansible.builtin.systemd:
|
|
53
|
+
name: project
|
|
54
|
+
state: started
|
|
55
|
+
enabled: yes
|
|
56
|
+
become: yes
|
|
57
|
+
ignore_errors: yes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
2
3
|
setup.py
|
|
3
4
|
vm_tool/__init__.py
|
|
4
5
|
vm_tool/cli.py
|
|
@@ -9,4 +10,8 @@ vm_tool.egg-info/SOURCES.txt
|
|
|
9
10
|
vm_tool.egg-info/dependency_links.txt
|
|
10
11
|
vm_tool.egg-info/entry_points.txt
|
|
11
12
|
vm_tool.egg-info/requires.txt
|
|
12
|
-
vm_tool.egg-info/top_level.txt
|
|
13
|
+
vm_tool.egg-info/top_level.txt
|
|
14
|
+
vm_tool/vm_setup/inventory.yml
|
|
15
|
+
vm_tool/vm_setup/setup.yml
|
|
16
|
+
vm_tool/vm_setup/docker/create_docker_service.yml
|
|
17
|
+
vm_tool/vm_setup/docker/install_docker_and_compose.yml
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|