vm-tool 1.0.11__tar.gz → 1.0.13__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/vm_tool.egg-info → vm_tool-1.0.13}/PKG-INFO +32 -2
- vm_tool-1.0.13/README.md +111 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/setup.py +2 -2
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/cli.py +1 -1
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/runner.py +42 -0
- vm_tool-1.0.13/vm_tool/vm_setup/cloud_inventory.yml +8 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/vm_setup/setup.yml +25 -12
- {vm_tool-1.0.11 → vm_tool-1.0.13/vm_tool.egg-info}/PKG-INFO +32 -2
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool.egg-info/SOURCES.txt +2 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/LICENSE +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/MANIFEST.in +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/setup.cfg +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/ssh.py +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/vm_setup/docker/create_docker_service.yml +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool/vm_setup/inventory.yml +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool.egg-info/entry_points.txt +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool.egg-info/requires.txt +0 -0
- {vm_tool-1.0.11 → vm_tool-1.0.13}/vm_tool.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: vm_tool
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.13
|
|
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.
|
|
@@ -65,6 +65,36 @@ By automating these tasks, the tool minimizes errors and saves time, allowing yo
|
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
+
## **Cloud Setup**
|
|
69
|
+
The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from vm_tool.runner import SetupRunner
|
|
73
|
+
|
|
74
|
+
runner = SetupRunner(
|
|
75
|
+
github_username='your_github_username', # e.g., username
|
|
76
|
+
github_token='your_github_token', # e.g., token
|
|
77
|
+
github_project_url='your_github_project_url' # e.g., https://github.com/username/repo
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
runner.run_cloud_setup(
|
|
81
|
+
ssh_username='your_ssh_username', # e.g., ssh_user
|
|
82
|
+
ssh_password='your_ssh_password', # e.g., ssh_password
|
|
83
|
+
ssh_hostname='your_ssh_hostname' # e.g., ssh.example.com
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### **What Happens During Cloud Setup**
|
|
88
|
+
When you run the cloud setup, the tool will:
|
|
89
|
+
1. Connect to the specified cloud VM using SSH.
|
|
90
|
+
2. Clone the specified GitHub repository to the VM.
|
|
91
|
+
3. Install **Docker** if it’s not already available on the VM.
|
|
92
|
+
4. Install **Docker Compose** for managing multi-container applications.
|
|
93
|
+
5. Create, enable, and start the Docker service on the VM.
|
|
94
|
+
6. Ensure the Docker container remains active, providing a robust environment for your applications.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
68
98
|
## **SSH Client Feature**
|
|
69
99
|
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.
|
|
70
100
|
|
vm_tool-1.0.13/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
## **Cloud Setup**
|
|
53
|
+
The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from vm_tool.runner import SetupRunner
|
|
57
|
+
|
|
58
|
+
runner = SetupRunner(
|
|
59
|
+
github_username='your_github_username', # e.g., username
|
|
60
|
+
github_token='your_github_token', # e.g., token
|
|
61
|
+
github_project_url='your_github_project_url' # e.g., https://github.com/username/repo
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
runner.run_cloud_setup(
|
|
65
|
+
ssh_username='your_ssh_username', # e.g., ssh_user
|
|
66
|
+
ssh_password='your_ssh_password', # e.g., ssh_password
|
|
67
|
+
ssh_hostname='your_ssh_hostname' # e.g., ssh.example.com
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### **What Happens During Cloud Setup**
|
|
72
|
+
When you run the cloud setup, the tool will:
|
|
73
|
+
1. Connect to the specified cloud VM using SSH.
|
|
74
|
+
2. Clone the specified GitHub repository to the VM.
|
|
75
|
+
3. Install **Docker** if it’s not already available on the VM.
|
|
76
|
+
4. Install **Docker Compose** for managing multi-container applications.
|
|
77
|
+
5. Create, enable, and start the Docker service on the VM.
|
|
78
|
+
6. Ensure the Docker container remains active, providing a robust environment for your applications.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## **SSH Client Feature**
|
|
83
|
+
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.
|
|
84
|
+
|
|
85
|
+
### **Example Usage**
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from vm_tool.ssh import SSHSetup
|
|
89
|
+
|
|
90
|
+
ssh_setup = SSHSetup(
|
|
91
|
+
hostname='your_vm_hostname', # e.g., vm.example.com
|
|
92
|
+
username='your_vm_username', # e.g., user
|
|
93
|
+
password='your_vm_password', # e.g., password
|
|
94
|
+
email='your_email_for_ssh_key' # e.g., user@example.com
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
ssh_setup.setup()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### **What Happens During SSH Setup**
|
|
101
|
+
When you run the SSH setup, the tool will:
|
|
102
|
+
1. Generate an SSH key pair if none exists.
|
|
103
|
+
2. Read the public SSH key or create a new one if necessary.
|
|
104
|
+
3. Configure the VM by adding the public key to the VM's **authorized_keys** file.
|
|
105
|
+
4. Update the local SSH configuration file with the VM's details.
|
|
106
|
+
5. Establish an SSH connection to verify the setup.
|
|
107
|
+
6. Close the connection once setup is complete.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
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.13', # 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.13')
|
|
6
6
|
|
|
7
7
|
args = parser.parse_args()
|
|
8
8
|
|
|
@@ -30,6 +30,48 @@ class SetupRunner:
|
|
|
30
30
|
playbook_path = os.path.join(current_dir, 'vm_setup', 'setup.yml')
|
|
31
31
|
inventory_path = os.path.join(current_dir, 'vm_setup', 'inventory.yml')
|
|
32
32
|
|
|
33
|
+
try:
|
|
34
|
+
# Run the Ansible playbook using ansible-runner
|
|
35
|
+
r = ansible_runner.run(
|
|
36
|
+
private_data_dir=venv_dir,
|
|
37
|
+
playbook=playbook_path,
|
|
38
|
+
inventory=inventory_path,
|
|
39
|
+
extravars=extravars
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if r.rc != 0:
|
|
43
|
+
raise RuntimeError(f"Ansible playbook execution failed with return code {r.rc}: {r.stdout}")
|
|
44
|
+
|
|
45
|
+
except Exception as e:
|
|
46
|
+
raise RuntimeError(f"An error occurred while running the Ansible playbook: {str(e)}")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def run_cloud_setup(self,ssh_username,ssh_password,ssh_hostname):
|
|
50
|
+
# Construct extravars dictionary
|
|
51
|
+
extravars = {
|
|
52
|
+
'SSH_USERNAME': ssh_username,
|
|
53
|
+
'SSH_PASSWORD': ssh_password,
|
|
54
|
+
'SSH_HOSTNAME': ssh_hostname,
|
|
55
|
+
'GITHUB_USERNAME': self.github_username,
|
|
56
|
+
'GITHUB_TOKEN': self.github_token,
|
|
57
|
+
'GITHUB_PROJECT_URL': self.github_project_url
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# Get the current directory of this script
|
|
62
|
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
63
|
+
|
|
64
|
+
# Get the virtual environment directory
|
|
65
|
+
venv_dir = os.path.join(sys.prefix, 'ansible_runner_data')
|
|
66
|
+
|
|
67
|
+
# Ensure the directory exists
|
|
68
|
+
os.makedirs(venv_dir, exist_ok=True)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Construct dynamic paths
|
|
72
|
+
playbook_path = os.path.join(current_dir, 'vm_setup', 'setup.yml')
|
|
73
|
+
inventory_path = os.path.join(current_dir, 'vm_setup', 'cloud_inventory.yml')
|
|
74
|
+
|
|
33
75
|
try:
|
|
34
76
|
# Run the Ansible playbook using ansible-runner
|
|
35
77
|
r = ansible_runner.run(
|
|
@@ -3,25 +3,17 @@
|
|
|
3
3
|
gather_facts: yes
|
|
4
4
|
|
|
5
5
|
vars:
|
|
6
|
-
|
|
7
|
-
github_username: "{{ lookup('env', 'GITHUB_USERNAME') }}"
|
|
8
|
-
github_token: "{{ lookup('env', 'GITHUB_TOKEN') }}"
|
|
9
|
-
static_playbook_dir: "{{playbook_dir}}"
|
|
6
|
+
static_playbook_dir: "{{ playbook_dir }}"
|
|
10
7
|
|
|
11
8
|
tasks:
|
|
12
|
-
|
|
13
9
|
- name: Set project_dest_dir variable
|
|
14
10
|
set_fact:
|
|
15
11
|
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
12
|
|
|
21
13
|
- name: Configure Git with GitHub token
|
|
22
14
|
shell: |
|
|
23
15
|
git config --global credential.helper store
|
|
24
|
-
echo "https://{{
|
|
16
|
+
echo "https://{{ GITHUB_USERNAME }}:{{ GITHUB_TOKEN }}@github.com" > ~/.git-credentials
|
|
25
17
|
become: yes
|
|
26
18
|
|
|
27
19
|
- name: Remove existing Project repository if present
|
|
@@ -33,7 +25,7 @@
|
|
|
33
25
|
|
|
34
26
|
- name: Clone the Project repository
|
|
35
27
|
git:
|
|
36
|
-
repo: "{{
|
|
28
|
+
repo: "{{ GITHUB_PROJECT_URL }}"
|
|
37
29
|
dest: "{{ project_dest_dir }}"
|
|
38
30
|
version: main
|
|
39
31
|
become: yes
|
|
@@ -54,4 +46,25 @@
|
|
|
54
46
|
state: started
|
|
55
47
|
enabled: yes
|
|
56
48
|
become: yes
|
|
57
|
-
ignore_errors: yes
|
|
49
|
+
ignore_errors: yes
|
|
50
|
+
|
|
51
|
+
# Cleanup section
|
|
52
|
+
- name: Remove GitHub credentials from git-credentials
|
|
53
|
+
file:
|
|
54
|
+
path: ~/.git-credentials
|
|
55
|
+
state: absent
|
|
56
|
+
become: yes
|
|
57
|
+
|
|
58
|
+
- name: Clear Git credential helper configuration
|
|
59
|
+
shell: git config --global --unset credential.helper
|
|
60
|
+
become: yes
|
|
61
|
+
|
|
62
|
+
- name: Unset environment variables
|
|
63
|
+
shell: |
|
|
64
|
+
unset GITHUB_PROJECT_URL
|
|
65
|
+
unset GITHUB_USERNAME
|
|
66
|
+
unset GITHUB_TOKEN
|
|
67
|
+
environment:
|
|
68
|
+
GITHUB_PROJECT_URL: "{{ GITHUB_PROJECT_URL }}"
|
|
69
|
+
GITHUB_USERNAME: "{{ GITHUB_USERNAME }}"
|
|
70
|
+
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.13
|
|
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.
|
|
@@ -65,6 +65,36 @@ By automating these tasks, the tool minimizes errors and saves time, allowing yo
|
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
+
## **Cloud Setup**
|
|
69
|
+
The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from vm_tool.runner import SetupRunner
|
|
73
|
+
|
|
74
|
+
runner = SetupRunner(
|
|
75
|
+
github_username='your_github_username', # e.g., username
|
|
76
|
+
github_token='your_github_token', # e.g., token
|
|
77
|
+
github_project_url='your_github_project_url' # e.g., https://github.com/username/repo
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
runner.run_cloud_setup(
|
|
81
|
+
ssh_username='your_ssh_username', # e.g., ssh_user
|
|
82
|
+
ssh_password='your_ssh_password', # e.g., ssh_password
|
|
83
|
+
ssh_hostname='your_ssh_hostname' # e.g., ssh.example.com
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### **What Happens During Cloud Setup**
|
|
88
|
+
When you run the cloud setup, the tool will:
|
|
89
|
+
1. Connect to the specified cloud VM using SSH.
|
|
90
|
+
2. Clone the specified GitHub repository to the VM.
|
|
91
|
+
3. Install **Docker** if it’s not already available on the VM.
|
|
92
|
+
4. Install **Docker Compose** for managing multi-container applications.
|
|
93
|
+
5. Create, enable, and start the Docker service on the VM.
|
|
94
|
+
6. Ensure the Docker container remains active, providing a robust environment for your applications.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
68
98
|
## **SSH Client Feature**
|
|
69
99
|
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.
|
|
70
100
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
MANIFEST.in
|
|
3
|
+
README.md
|
|
3
4
|
setup.py
|
|
4
5
|
vm_tool/__init__.py
|
|
5
6
|
vm_tool/cli.py
|
|
@@ -11,6 +12,7 @@ vm_tool.egg-info/dependency_links.txt
|
|
|
11
12
|
vm_tool.egg-info/entry_points.txt
|
|
12
13
|
vm_tool.egg-info/requires.txt
|
|
13
14
|
vm_tool.egg-info/top_level.txt
|
|
15
|
+
vm_tool/vm_setup/cloud_inventory.yml
|
|
14
16
|
vm_tool/vm_setup/inventory.yml
|
|
15
17
|
vm_tool/vm_setup/setup.yml
|
|
16
18
|
vm_tool/vm_setup/docker/create_docker_service.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|