vm-tool 1.0.10__tar.gz → 1.0.12__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.12/MANIFEST.in +1 -0
- {vm_tool-1.0.10/vm_tool.egg-info → vm_tool-1.0.12}/PKG-INFO +2 -2
- vm_tool-1.0.12/README.md +81 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/setup.py +2 -2
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool/cli.py +1 -1
- vm_tool-1.0.12/vm_tool/vm_setup/docker/create_docker_service.yml +53 -0
- vm_tool-1.0.12/vm_tool/vm_setup/docker/install_docker_and_compose.yml +70 -0
- vm_tool-1.0.12/vm_tool/vm_setup/inventory.yml +1 -0
- vm_tool-1.0.12/vm_tool/vm_setup/setup.yml +77 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12/vm_tool.egg-info}/PKG-INFO +2 -2
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool.egg-info/SOURCES.txt +7 -1
- {vm_tool-1.0.10 → vm_tool-1.0.12}/LICENSE +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/setup.cfg +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool/runner.py +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool/ssh.py +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool.egg-info/entry_points.txt +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool.egg-info/requires.txt +0 -0
- {vm_tool-1.0.10 → vm_tool-1.0.12}/vm_tool.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include vm_tool/vm_setup *
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: vm_tool
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: A Comprehensive Tool for Setting Up Virtual Machines Using Ansible.
|
|
5
5
|
License: MIT
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -15,7 +15,7 @@ Dynamic: requires-dist
|
|
|
15
15
|
Dynamic: summary
|
|
16
16
|
|
|
17
17
|
# **VM Setup Tool**
|
|
18
|
-
### **A Comprehensive Solution for Streamlining Virtual Machine Configuration
|
|
18
|
+
### **A Comprehensive Solution for Streamlining Virtual Machine Configuration**
|
|
19
19
|
|
|
20
20
|
## **Overview**
|
|
21
21
|
The **VM Setup Tool** is an efficient, user-friendly solution designed to simplify the process of setting up and managing virtual machines (VMs) using Ansible. Ideal for automating VM deployment and configuration, this tool ensures consistency and enhances operational efficiency across your infrastructure.
|
vm_tool-1.0.12/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# **VM Setup Tool**
|
|
2
|
+
### **A Comprehensive Solution for Streamlining Virtual Machine Configuration**
|
|
3
|
+
|
|
4
|
+
## **Overview**
|
|
5
|
+
The **VM Setup Tool** is an efficient, user-friendly solution designed to simplify the process of setting up and managing virtual machines (VMs) using Ansible. Ideal for automating VM deployment and configuration, this tool ensures consistency and enhances operational efficiency across your infrastructure.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## **Pre-requisites**
|
|
10
|
+
This tool supports projects utilizing **Docker Compose**. Ensure that a `docker-compose.yml` file is present at the root of your project directory before proceeding.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## **Installation**
|
|
15
|
+
Install the VM Setup Tool using **pip**, the Python package manager:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install vm-tool
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## **Example Usage**
|
|
24
|
+
|
|
25
|
+
### **Automated VM Setup**
|
|
26
|
+
Use the following example to configure and run the VM setup:
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from vm_tool.runner import SetupRunner
|
|
30
|
+
|
|
31
|
+
runner = SetupRunner(
|
|
32
|
+
github_username='your_github_username', # e.g., username
|
|
33
|
+
github_token='your_github_token', # e.g., token
|
|
34
|
+
github_project_url='your_github_project_url' # e.g., https://github.com/username/repo
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
runner.run_setup()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### **What Happens During Setup**
|
|
41
|
+
The VM Setup Tool will:
|
|
42
|
+
1. Clone the specified GitHub repository to your local machine.
|
|
43
|
+
2. Install **Docker** if it’s not already available on the target machine.
|
|
44
|
+
3. Install **Docker Compose** for managing multi-container applications.
|
|
45
|
+
4. Create, enable, and start the Docker service.
|
|
46
|
+
5. Ensure the Docker container remains active, providing a robust environment for your applications.
|
|
47
|
+
|
|
48
|
+
By automating these tasks, the tool minimizes errors and saves time, allowing you to focus on development and deployment.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## **SSH Client Feature**
|
|
53
|
+
The **VM Setup Tool** also includes a dedicated **SSH client** feature to simplify the configuration of SSH access for VMs, including automated SSH key generation and management.
|
|
54
|
+
|
|
55
|
+
### **Example Usage**
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from vm_tool.ssh import SSHSetup
|
|
59
|
+
|
|
60
|
+
ssh_setup = SSHSetup(
|
|
61
|
+
hostname='your_vm_hostname', # e.g., vm.example.com
|
|
62
|
+
username='your_vm_username', # e.g., user
|
|
63
|
+
password='your_vm_password', # e.g., password
|
|
64
|
+
email='your_email_for_ssh_key' # e.g., user@example.com
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
ssh_setup.setup()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### **What Happens During SSH Setup**
|
|
71
|
+
When you run the SSH setup, the tool will:
|
|
72
|
+
1. Generate an SSH key pair if none exists.
|
|
73
|
+
2. Read the public SSH key or create a new one if necessary.
|
|
74
|
+
3. Configure the VM by adding the public key to the VM's **authorized_keys** file.
|
|
75
|
+
4. Update the local SSH configuration file with the VM's details.
|
|
76
|
+
5. Establish an SSH connection to verify the setup.
|
|
77
|
+
6. Close the connection once setup is complete.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
With its comprehensive features, the **VM Setup Tool** eliminates the hassle of manual configurations and enables seamless integration of VMs into your workflows. Start using the tool today to automate and optimize your virtual machine setup process.
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
# Read the contents of README.md
|
|
5
|
-
readme_path = os.path.join(os.path.dirname(__file__), '
|
|
5
|
+
readme_path = os.path.join(os.path.dirname(__file__), 'README.md')
|
|
6
6
|
if os.path.exists(readme_path):
|
|
7
7
|
with open(readme_path, encoding='utf-8') as f:
|
|
8
8
|
long_description = f.read()
|
|
@@ -11,7 +11,7 @@ else:
|
|
|
11
11
|
|
|
12
12
|
setup(
|
|
13
13
|
name='vm_tool',
|
|
14
|
-
version='1.0.
|
|
14
|
+
version='1.0.12', # 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.12')
|
|
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,77 @@
|
|
|
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
|
+
- name: Set project_dest_dir variable
|
|
13
|
+
set_fact:
|
|
14
|
+
project_dest_dir: "{{ static_playbook_dir }}/project"
|
|
15
|
+
|
|
16
|
+
- name: Set project_repo_url variable
|
|
17
|
+
set_fact:
|
|
18
|
+
project_repo_url: "{{ github_project_url }}"
|
|
19
|
+
|
|
20
|
+
- name: Configure Git with GitHub token
|
|
21
|
+
shell: |
|
|
22
|
+
git config --global credential.helper store
|
|
23
|
+
echo "https://{{ github_username }}:{{ github_token }}@github.com" > ~/.git-credentials
|
|
24
|
+
become: yes
|
|
25
|
+
|
|
26
|
+
- name: Remove existing Project repository if present
|
|
27
|
+
file:
|
|
28
|
+
path: "{{ project_dest_dir }}"
|
|
29
|
+
state: absent
|
|
30
|
+
force: yes
|
|
31
|
+
become: yes
|
|
32
|
+
|
|
33
|
+
- name: Clone the Project repository
|
|
34
|
+
git:
|
|
35
|
+
repo: "{{ project_repo_url }}"
|
|
36
|
+
dest: "{{ project_dest_dir }}"
|
|
37
|
+
version: main
|
|
38
|
+
become: yes
|
|
39
|
+
|
|
40
|
+
- name: Set service_file_path variable
|
|
41
|
+
set_fact:
|
|
42
|
+
service_file_path: /etc/systemd/system/project.service
|
|
43
|
+
|
|
44
|
+
- name: Adding Docker and Compose packages
|
|
45
|
+
include_tasks: docker/install_docker_and_compose.yml
|
|
46
|
+
|
|
47
|
+
- name: Create Docker Service
|
|
48
|
+
include_tasks: docker/create_docker_service.yml
|
|
49
|
+
|
|
50
|
+
- name: Enable and start project service
|
|
51
|
+
ansible.builtin.systemd:
|
|
52
|
+
name: project
|
|
53
|
+
state: started
|
|
54
|
+
enabled: yes
|
|
55
|
+
become: yes
|
|
56
|
+
ignore_errors: yes
|
|
57
|
+
|
|
58
|
+
# Cleanup section
|
|
59
|
+
- name: Remove GitHub credentials from git-credentials
|
|
60
|
+
file:
|
|
61
|
+
path: ~/.git-credentials
|
|
62
|
+
state: absent
|
|
63
|
+
become: yes
|
|
64
|
+
|
|
65
|
+
- name: Clear Git credential helper configuration
|
|
66
|
+
shell: git config --global --unset credential.helper
|
|
67
|
+
become: yes
|
|
68
|
+
|
|
69
|
+
- name: Unset environment variables
|
|
70
|
+
shell: |
|
|
71
|
+
unset GITHUB_PROJECT_URL
|
|
72
|
+
unset GITHUB_USERNAME
|
|
73
|
+
unset GITHUB_TOKEN
|
|
74
|
+
environment:
|
|
75
|
+
GITHUB_PROJECT_URL: "{{ github_project_url }}"
|
|
76
|
+
GITHUB_USERNAME: "{{ github_username }}"
|
|
77
|
+
GITHUB_TOKEN: "{{ github_token }}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: vm_tool
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: A Comprehensive Tool for Setting Up Virtual Machines Using Ansible.
|
|
5
5
|
License: MIT
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -15,7 +15,7 @@ Dynamic: requires-dist
|
|
|
15
15
|
Dynamic: summary
|
|
16
16
|
|
|
17
17
|
# **VM Setup Tool**
|
|
18
|
-
### **A Comprehensive Solution for Streamlining Virtual Machine Configuration
|
|
18
|
+
### **A Comprehensive Solution for Streamlining Virtual Machine Configuration**
|
|
19
19
|
|
|
20
20
|
## **Overview**
|
|
21
21
|
The **VM Setup Tool** is an efficient, user-friendly solution designed to simplify the process of setting up and managing virtual machines (VMs) using Ansible. Ideal for automating VM deployment and configuration, this tool ensures consistency and enhances operational efficiency across your infrastructure.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
2
4
|
setup.py
|
|
3
5
|
vm_tool/__init__.py
|
|
4
6
|
vm_tool/cli.py
|
|
@@ -9,4 +11,8 @@ vm_tool.egg-info/SOURCES.txt
|
|
|
9
11
|
vm_tool.egg-info/dependency_links.txt
|
|
10
12
|
vm_tool.egg-info/entry_points.txt
|
|
11
13
|
vm_tool.egg-info/requires.txt
|
|
12
|
-
vm_tool.egg-info/top_level.txt
|
|
14
|
+
vm_tool.egg-info/top_level.txt
|
|
15
|
+
vm_tool/vm_setup/inventory.yml
|
|
16
|
+
vm_tool/vm_setup/setup.yml
|
|
17
|
+
vm_tool/vm_setup/docker/create_docker_service.yml
|
|
18
|
+
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
|