vm-tool 1.0.18__tar.gz → 1.0.20__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.
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: vm_tool
3
- Version: 1.0.18
3
+ Version: 1.0.20
4
4
  Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
5
  Home-page: https://github.com/thesunnysinha/vm_tool
6
+ Author: Sunny Sinha
7
+ Author-email: thesunnysinha@gmail.com
6
8
  License: MIT
7
9
  Project-URL: Documentation, https://github.com/thesunnysinha/vm_tool/README.md
8
10
  Project-URL: Source, https://github.com/thesunnysinha/vm_tool
@@ -31,10 +33,13 @@ Requires-Dist: ansible
31
33
  Requires-Dist: ansible-runner
32
34
  Requires-Dist: paramiko
33
35
  Requires-Dist: pydantic
36
+ Requires-Dist: pyyaml
34
37
  Provides-Extra: dev
35
38
  Requires-Dist: pytest; extra == "dev"
36
39
  Requires-Dist: flake8; extra == "dev"
37
40
  Requires-Dist: bump2version; extra == "dev"
41
+ Dynamic: author
42
+ Dynamic: author-email
38
43
  Dynamic: classifier
39
44
  Dynamic: description
40
45
  Dynamic: description-content-type
@@ -56,7 +61,7 @@ The **VM Setup Tool** is an efficient, user-friendly solution designed to simpli
56
61
  ---
57
62
 
58
63
  ## **Pre-requisites**
59
- 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.
64
+ This tool supports projects utilizing **Docker Compose**.
60
65
 
61
66
  ---
62
67
 
@@ -75,15 +80,17 @@ pip install vm-tool
75
80
  Use the following example to configure and run the VM setup:
76
81
 
77
82
  ```python
78
- from vm_tool.runner import SetupRunner
83
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
79
84
 
80
- runner = SetupRunner(
85
+ config = SetupRunnerConfig(
81
86
  github_username='your_github_username', # e.g., username
82
87
  github_token='your_github_token', # e.g., token
83
88
  github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
84
- docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml' e.g. backend/docker-compose.prod.yml
89
+ docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml'
85
90
  )
86
91
 
92
+ runner = SetupRunner(config)
93
+
87
94
  runner.run_setup()
88
95
  ```
89
96
 
@@ -103,20 +110,32 @@ By automating these tasks, the tool minimizes errors and saves time, allowing yo
103
110
  The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
104
111
 
105
112
  ```python
106
- from vm_tool.runner import SetupRunner
113
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
107
114
 
108
- runner = SetupRunner(
115
+ config = SetupRunnerConfig(
109
116
  github_username='your_github_username', # e.g., username
110
117
  github_token='your_github_token', # e.g., token
111
118
  github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
112
- docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml' e.g. backend/docker-compose.prod.yml
119
+ docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml'
113
120
  )
114
121
 
115
- runner.run_cloud_setup(
116
- ssh_username='your_ssh_username', # e.g., ssh_user
117
- ssh_password='your_ssh_password', # e.g., ssh_password
118
- ssh_hostname='your_ssh_hostname' # e.g., ssh.example.com
119
- )
122
+ runner = SetupRunner(config)
123
+
124
+ ssh_configs = [
125
+ SSHConfig(
126
+ ssh_username='your_ssh_username_1', # e.g., ssh_user_1
127
+ ssh_password='your_ssh_password_1', # e.g., ssh_password_1
128
+ ssh_hostname='your_ssh_hostname_1' # e.g., ssh1.example.com
129
+ ),
130
+ SSHConfig(
131
+ ssh_username='your_ssh_username_2', # e.g., ssh_user_2
132
+ ssh_password='your_ssh_password_2', # e.g., ssh_password_2
133
+ ssh_hostname='your_ssh_hostname_2' # e.g., ssh2.example.com
134
+ )
135
+ # Add more SSHConfig instances as needed
136
+ ]
137
+
138
+ runner.run_cloud_setup(ssh_configs)
120
139
  ```
121
140
 
122
141
  ### **What Happens During Cloud Setup**
@@ -7,7 +7,7 @@ The **VM Setup Tool** is an efficient, user-friendly solution designed to simpli
7
7
  ---
8
8
 
9
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.
10
+ This tool supports projects utilizing **Docker Compose**.
11
11
 
12
12
  ---
13
13
 
@@ -26,15 +26,17 @@ pip install vm-tool
26
26
  Use the following example to configure and run the VM setup:
27
27
 
28
28
  ```python
29
- from vm_tool.runner import SetupRunner
29
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
30
30
 
31
- runner = SetupRunner(
31
+ config = SetupRunnerConfig(
32
32
  github_username='your_github_username', # e.g., username
33
33
  github_token='your_github_token', # e.g., token
34
34
  github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
35
- docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml' e.g. backend/docker-compose.prod.yml
35
+ docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml'
36
36
  )
37
37
 
38
+ runner = SetupRunner(config)
39
+
38
40
  runner.run_setup()
39
41
  ```
40
42
 
@@ -54,20 +56,32 @@ By automating these tasks, the tool minimizes errors and saves time, allowing yo
54
56
  The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
55
57
 
56
58
  ```python
57
- from vm_tool.runner import SetupRunner
59
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
58
60
 
59
- runner = SetupRunner(
61
+ config = SetupRunnerConfig(
60
62
  github_username='your_github_username', # e.g., username
61
63
  github_token='your_github_token', # e.g., token
62
64
  github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
63
- docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml' e.g. backend/docker-compose.prod.yml
65
+ docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml'
64
66
  )
65
67
 
66
- runner.run_cloud_setup(
67
- ssh_username='your_ssh_username', # e.g., ssh_user
68
- ssh_password='your_ssh_password', # e.g., ssh_password
69
- ssh_hostname='your_ssh_hostname' # e.g., ssh.example.com
70
- )
68
+ runner = SetupRunner(config)
69
+
70
+ ssh_configs = [
71
+ SSHConfig(
72
+ ssh_username='your_ssh_username_1', # e.g., ssh_user_1
73
+ ssh_password='your_ssh_password_1', # e.g., ssh_password_1
74
+ ssh_hostname='your_ssh_hostname_1' # e.g., ssh1.example.com
75
+ ),
76
+ SSHConfig(
77
+ ssh_username='your_ssh_username_2', # e.g., ssh_user_2
78
+ ssh_password='your_ssh_password_2', # e.g., ssh_password_2
79
+ ssh_hostname='your_ssh_hostname_2' # e.g., ssh2.example.com
80
+ )
81
+ # Add more SSHConfig instances as needed
82
+ ]
83
+
84
+ runner.run_cloud_setup(ssh_configs)
71
85
  ```
72
86
 
73
87
  ### **What Happens During Cloud Setup**
@@ -11,7 +11,7 @@ else:
11
11
 
12
12
  setup(
13
13
  name='vm_tool',
14
- version='1.0.18', # This will be updated by bump2version
14
+ version='1.0.20', # This will be updated by bump2version
15
15
  packages=find_packages(),
16
16
  description='A Comprehensive Tool for Setting Up Virtual Machines.',
17
17
  long_description=long_description,
@@ -20,7 +20,8 @@ setup(
20
20
  'ansible',
21
21
  'ansible-runner',
22
22
  'paramiko',
23
- 'pydantic'
23
+ 'pydantic',
24
+ 'pyyaml'
24
25
  ],
25
26
  extras_require={
26
27
  'dev': [
@@ -62,4 +63,6 @@ setup(
62
63
  'Source': 'https://github.com/thesunnysinha/vm_tool',
63
64
  'Tracker': 'https://github.com/thesunnysinha/vm_tool/issues',
64
65
  },
66
+ author='Sunny Sinha',
67
+ author_email='thesunnysinha@gmail.com',
65
68
  )
@@ -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.18')
5
+ parser.add_argument('--version', action='version', version='1.0.20')
6
6
 
7
7
  args = parser.parse_args()
8
8
 
@@ -1,18 +1,25 @@
1
1
  import sys
2
2
  import ansible_runner
3
3
  import os
4
- from pydantic import BaseModel, HttpUrl, validator
4
+ import yaml
5
+ from pydantic import BaseModel, validator
6
+ from typing import List
5
7
 
6
8
  class SetupRunnerConfig(BaseModel):
7
9
  github_username: str
8
10
  github_token: str
9
- github_project_url: HttpUrl
11
+ github_project_url: str
10
12
  docker_compose_file_path: str = 'docker-compose.yml'
11
13
 
12
14
  @validator('docker_compose_file_path', pre=True, always=True)
13
15
  def set_default_docker_compose_file_path(cls, v):
14
16
  return v or 'docker-compose.yml'
15
17
 
18
+ class SSHConfig(BaseModel):
19
+ ssh_username: str
20
+ ssh_password: str
21
+ ssh_hostname: str
22
+
16
23
  class SetupRunner:
17
24
  def __init__(self, config: SetupRunnerConfig):
18
25
  self.github_username = config.github_username
@@ -63,12 +70,36 @@ class SetupRunner:
63
70
 
64
71
  self._run_ansible_playbook(extravars, 'inventory.yml')
65
72
 
66
- def run_cloud_setup(self, ssh_username: str, ssh_password: str, ssh_hostname: str):
73
+ def run_cloud_setup(self, ssh_configs: List[SSHConfig]):
74
+ # Define the path for the dynamic inventory file
75
+ inventory_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'vm_setup', 'dynamic_inventory.yml')
76
+
77
+ # Create dynamic inventory content
78
+ inventory_content = {
79
+ 'all': {
80
+ 'hosts': {},
81
+ 'vars': {
82
+ 'ansible_python_interpreter': '/usr/bin/python3'
83
+ }
84
+ }
85
+ }
86
+
87
+ print(ssh_configs)
88
+
89
+ for i, ssh_config in enumerate(ssh_configs):
90
+ host_key = f'cloud_host_{i}'
91
+ inventory_content['all']['hosts'][host_key] = {
92
+ 'ansible_host': ssh_config.ssh_hostname,
93
+ 'ansible_user': ssh_config.ssh_username,
94
+ 'ansible_ssh_pass': ssh_config.ssh_password
95
+ }
96
+
97
+ # Write dynamic inventory to a file
98
+ with open(inventory_file_path, 'w') as inventory_file:
99
+ yaml.dump(inventory_content, inventory_file)
100
+
67
101
  # Construct extravars dictionary
68
102
  extravars = {
69
- 'SSH_USERNAME': ssh_username,
70
- 'SSH_PASSWORD': ssh_password,
71
- 'SSH_HOSTNAME': ssh_hostname,
72
103
  'GITHUB_USERNAME': self.github_username,
73
104
  'GITHUB_TOKEN': self.github_token,
74
105
  'GITHUB_PROJECT_URL': self.github_project_url,
@@ -78,4 +109,4 @@ class SetupRunner:
78
109
  if self.docker_compose_file_path:
79
110
  extravars["DOCKER_COMPOSE_FILE_PATH"] = self.docker_compose_file_path
80
111
 
81
- self._run_ansible_playbook(extravars, 'cloud_inventory.yml')
112
+ self._run_ansible_playbook(extravars, 'dynamic_inventory.yml')
File without changes
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: vm_tool
3
- Version: 1.0.18
3
+ Version: 1.0.20
4
4
  Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
5
  Home-page: https://github.com/thesunnysinha/vm_tool
6
+ Author: Sunny Sinha
7
+ Author-email: thesunnysinha@gmail.com
6
8
  License: MIT
7
9
  Project-URL: Documentation, https://github.com/thesunnysinha/vm_tool/README.md
8
10
  Project-URL: Source, https://github.com/thesunnysinha/vm_tool
@@ -31,10 +33,13 @@ Requires-Dist: ansible
31
33
  Requires-Dist: ansible-runner
32
34
  Requires-Dist: paramiko
33
35
  Requires-Dist: pydantic
36
+ Requires-Dist: pyyaml
34
37
  Provides-Extra: dev
35
38
  Requires-Dist: pytest; extra == "dev"
36
39
  Requires-Dist: flake8; extra == "dev"
37
40
  Requires-Dist: bump2version; extra == "dev"
41
+ Dynamic: author
42
+ Dynamic: author-email
38
43
  Dynamic: classifier
39
44
  Dynamic: description
40
45
  Dynamic: description-content-type
@@ -56,7 +61,7 @@ The **VM Setup Tool** is an efficient, user-friendly solution designed to simpli
56
61
  ---
57
62
 
58
63
  ## **Pre-requisites**
59
- 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.
64
+ This tool supports projects utilizing **Docker Compose**.
60
65
 
61
66
  ---
62
67
 
@@ -75,15 +80,17 @@ pip install vm-tool
75
80
  Use the following example to configure and run the VM setup:
76
81
 
77
82
  ```python
78
- from vm_tool.runner import SetupRunner
83
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
79
84
 
80
- runner = SetupRunner(
85
+ config = SetupRunnerConfig(
81
86
  github_username='your_github_username', # e.g., username
82
87
  github_token='your_github_token', # e.g., token
83
88
  github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
84
- docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml' e.g. backend/docker-compose.prod.yml
89
+ docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml'
85
90
  )
86
91
 
92
+ runner = SetupRunner(config)
93
+
87
94
  runner.run_setup()
88
95
  ```
89
96
 
@@ -103,20 +110,32 @@ By automating these tasks, the tool minimizes errors and saves time, allowing yo
103
110
  The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
104
111
 
105
112
  ```python
106
- from vm_tool.runner import SetupRunner
113
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
107
114
 
108
- runner = SetupRunner(
115
+ config = SetupRunnerConfig(
109
116
  github_username='your_github_username', # e.g., username
110
117
  github_token='your_github_token', # e.g., token
111
118
  github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
112
- docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml' e.g. backend/docker-compose.prod.yml
119
+ docker_compose_file_path='path_to_your_docker_compose_file' # Optional, defaults to 'docker-compose.yml'
113
120
  )
114
121
 
115
- runner.run_cloud_setup(
116
- ssh_username='your_ssh_username', # e.g., ssh_user
117
- ssh_password='your_ssh_password', # e.g., ssh_password
118
- ssh_hostname='your_ssh_hostname' # e.g., ssh.example.com
119
- )
122
+ runner = SetupRunner(config)
123
+
124
+ ssh_configs = [
125
+ SSHConfig(
126
+ ssh_username='your_ssh_username_1', # e.g., ssh_user_1
127
+ ssh_password='your_ssh_password_1', # e.g., ssh_password_1
128
+ ssh_hostname='your_ssh_hostname_1' # e.g., ssh1.example.com
129
+ ),
130
+ SSHConfig(
131
+ ssh_username='your_ssh_username_2', # e.g., ssh_user_2
132
+ ssh_password='your_ssh_password_2', # e.g., ssh_password_2
133
+ ssh_hostname='your_ssh_hostname_2' # e.g., ssh2.example.com
134
+ )
135
+ # Add more SSHConfig instances as needed
136
+ ]
137
+
138
+ runner.run_cloud_setup(ssh_configs)
120
139
  ```
121
140
 
122
141
  ### **What Happens During Cloud Setup**
@@ -12,7 +12,7 @@ vm_tool.egg-info/dependency_links.txt
12
12
  vm_tool.egg-info/entry_points.txt
13
13
  vm_tool.egg-info/requires.txt
14
14
  vm_tool.egg-info/top_level.txt
15
- vm_tool/vm_setup/cloud_inventory.yml
15
+ vm_tool/vm_setup/dynamic_inventory.yml
16
16
  vm_tool/vm_setup/inventory.yml
17
17
  vm_tool/vm_setup/setup.yml
18
18
  vm_tool/vm_setup/docker/create_docker_service.yml
@@ -2,6 +2,7 @@ ansible
2
2
  ansible-runner
3
3
  paramiko
4
4
  pydantic
5
+ pyyaml
5
6
 
6
7
  [dev]
7
8
  pytest
@@ -1,8 +0,0 @@
1
- all:
2
- hosts:
3
- cloud_host:
4
- ansible_host: "{{ SSH_HOSTNAME }}"
5
- ansible_user: "{{ SSH_USERNAME }}"
6
- ansible_ssh_pass: "{{ SSH_PASSWORD }}"
7
- vars:
8
- ansible_python_interpreter: /usr/bin/python3
File without changes
File without changes
File without changes
File without changes
File without changes