vm-tool 1.0__tar.gz → 1.0.1__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/vm_tool.egg-info → vm_tool-1.0.1}/PKG-INFO +2 -6
- {vm_tool-1.0 → vm_tool-1.0.1}/setup.py +2 -6
- vm_tool-1.0.1/vm_tool/runner.py +46 -0
- {vm_tool-1.0 → vm_tool-1.0.1/vm_tool.egg-info}/PKG-INFO +2 -6
- {vm_tool-1.0 → vm_tool-1.0.1}/vm_tool.egg-info/SOURCES.txt +0 -1
- vm_tool-1.0/README.md +0 -28
- vm_tool-1.0/vm_tool/runner.py +0 -36
- {vm_tool-1.0 → vm_tool-1.0.1}/LICENSE +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/setup.cfg +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/vm_tool/cli.py +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/vm_tool.egg-info/entry_points.txt +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/vm_tool.egg-info/requires.txt +0 -0
- {vm_tool-1.0 → vm_tool-1.0.1}/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.1
|
|
4
4
|
Summary: A tool to setup VMs using Ansible.
|
|
5
5
|
License: MIT
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -18,13 +18,9 @@ Dynamic: summary
|
|
|
18
18
|
|
|
19
19
|
Example usage:
|
|
20
20
|
|
|
21
|
-
from vm_tool import SetupRunner
|
|
21
|
+
from vm_tool.runner import SetupRunner
|
|
22
22
|
|
|
23
23
|
runner = SetupRunner(
|
|
24
|
-
ssh_host='your_host', # e.g. 192.168.1.1
|
|
25
|
-
ssh_user='your_user', # e.g. root
|
|
26
|
-
ssh_password='your_password', # e.g. password
|
|
27
|
-
become_pass='your_become_pass', # e.g. password
|
|
28
24
|
github_username='your_github_username', # e.g. username
|
|
29
25
|
github_token='your_github_token', # e.g. token
|
|
30
26
|
github_project_url='your_github_project_url' # e.g. https://github.com/username/repo
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='vm_tool',
|
|
5
|
-
version='1.0',
|
|
5
|
+
version='1.0.1', # This will be updated by bump2version
|
|
6
6
|
packages=find_packages(),
|
|
7
7
|
description='A tool to setup VMs using Ansible.',
|
|
8
8
|
long_description='''
|
|
@@ -10,13 +10,9 @@ setup(
|
|
|
10
10
|
|
|
11
11
|
Example usage:
|
|
12
12
|
|
|
13
|
-
from vm_tool import SetupRunner
|
|
13
|
+
from vm_tool.runner import SetupRunner
|
|
14
14
|
|
|
15
15
|
runner = SetupRunner(
|
|
16
|
-
ssh_host='your_host', # e.g. 192.168.1.1
|
|
17
|
-
ssh_user='your_user', # e.g. root
|
|
18
|
-
ssh_password='your_password', # e.g. password
|
|
19
|
-
become_pass='your_become_pass', # e.g. password
|
|
20
16
|
github_username='your_github_username', # e.g. username
|
|
21
17
|
github_token='your_github_token', # e.g. token
|
|
22
18
|
github_project_url='your_github_project_url' # e.g. https://github.com/username/repo
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import ansible_runner
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
class SetupRunner:
|
|
6
|
+
def __init__(self, github_username, github_token, github_project_url):
|
|
7
|
+
self.github_username = github_username
|
|
8
|
+
self.github_token = github_token
|
|
9
|
+
self.github_project_url = github_project_url
|
|
10
|
+
|
|
11
|
+
def run_setup(self):
|
|
12
|
+
# Construct extravars dictionary
|
|
13
|
+
extravars = {
|
|
14
|
+
'GITHUB_USERNAME': self.github_username,
|
|
15
|
+
'GITHUB_TOKEN': self.github_token,
|
|
16
|
+
'GITHUB_PROJECT_URL': self.github_project_url
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Get the current directory of this script
|
|
20
|
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
21
|
+
|
|
22
|
+
# Get the virtual environment directory
|
|
23
|
+
venv_dir = os.path.join(sys.prefix, 'ansible_runner_data')
|
|
24
|
+
|
|
25
|
+
# Ensure the directory exists
|
|
26
|
+
os.makedirs(venv_dir, exist_ok=True)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Construct dynamic paths
|
|
30
|
+
playbook_path = os.path.join(current_dir, 'vm_setup', 'setup.yml')
|
|
31
|
+
inventory_path = os.path.join(current_dir, 'vm_setup', 'inventory.yml')
|
|
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)}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: vm_tool
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: A tool to setup VMs using Ansible.
|
|
5
5
|
License: MIT
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -18,13 +18,9 @@ Dynamic: summary
|
|
|
18
18
|
|
|
19
19
|
Example usage:
|
|
20
20
|
|
|
21
|
-
from vm_tool import SetupRunner
|
|
21
|
+
from vm_tool.runner import SetupRunner
|
|
22
22
|
|
|
23
23
|
runner = SetupRunner(
|
|
24
|
-
ssh_host='your_host', # e.g. 192.168.1.1
|
|
25
|
-
ssh_user='your_user', # e.g. root
|
|
26
|
-
ssh_password='your_password', # e.g. password
|
|
27
|
-
become_pass='your_become_pass', # e.g. password
|
|
28
24
|
github_username='your_github_username', # e.g. username
|
|
29
25
|
github_token='your_github_token', # e.g. token
|
|
30
26
|
github_project_url='your_github_project_url' # e.g. https://github.com/username/repo
|
vm_tool-1.0/README.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
### Welcome to initial setup of the application
|
|
2
|
-
|
|
3
|
-
1. Connect to deployment machine using VSCode.
|
|
4
|
-
|
|
5
|
-
2. Run the following command to install the package and its dependencies:
|
|
6
|
-
```bash
|
|
7
|
-
pip install .
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
### This is a tool to setup VMs using Ansible.
|
|
11
|
-
|
|
12
|
-
## Example usage:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
from vm_tool import SetupRunner
|
|
16
|
-
|
|
17
|
-
runner = SetupRunner(
|
|
18
|
-
ssh_host='your_host', # e.g. 192.168.1.1
|
|
19
|
-
ssh_user='your_user', # e.g. root
|
|
20
|
-
ssh_password='your_password', # e.g. password
|
|
21
|
-
become_pass='your_become_pass', # e.g. password
|
|
22
|
-
github_username='your_github_username', # e.g. username
|
|
23
|
-
github_token='your_github_token', # e.g. token
|
|
24
|
-
github_project_url='your_github_project_url' # e.g. https://github.com/username/repo
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
runner.run_setup()
|
|
28
|
-
```
|
vm_tool-1.0/vm_tool/runner.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import ansible_runner
|
|
2
|
-
|
|
3
|
-
class SetupRunner:
|
|
4
|
-
def __init__(self, ssh_host, ssh_user, ssh_password, become_pass, github_username, github_token, github_project_url):
|
|
5
|
-
self.ssh_host = ssh_host
|
|
6
|
-
self.ssh_user = ssh_user
|
|
7
|
-
self.ssh_password = ssh_password
|
|
8
|
-
self.become_pass = become_pass
|
|
9
|
-
self.github_username = github_username
|
|
10
|
-
self.github_token = github_token
|
|
11
|
-
self.github_project_url = github_project_url
|
|
12
|
-
|
|
13
|
-
def run_setup(self):
|
|
14
|
-
# Construct extravars dictionary
|
|
15
|
-
extravars = {
|
|
16
|
-
'ANSIBLE_SSH_HOST': self.ssh_host,
|
|
17
|
-
'ANSIBLE_SSH_USER': self.ssh_user,
|
|
18
|
-
'ANSIBLE_SSH_PASS': self.ssh_password,
|
|
19
|
-
'ANSIBLE_BECOME_PASS': self.become_pass,
|
|
20
|
-
'GITHUB_USERNAME': self.github_username,
|
|
21
|
-
'GITHUB_TOKEN': self.github_token,
|
|
22
|
-
'GITHUB_PROJECT_URL': self.github_project_url
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
# Run the Ansible playbook using ansible-runner
|
|
26
|
-
r = ansible_runner.run(
|
|
27
|
-
private_data_dir='.',
|
|
28
|
-
playbook='vm_tool/vm_setup/setup.yml',
|
|
29
|
-
inventory='vm_tool/vm_setup/inventory.yml',
|
|
30
|
-
extravars=extravars
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
if r.rc != 0:
|
|
34
|
-
raise RuntimeError(f"Ansible playbook execution failed: {r.stdout}")
|
|
35
|
-
|
|
36
|
-
print(r.stdout)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|