vm-tool 1.0.26__tar.gz → 1.0.28__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.
Files changed (30) hide show
  1. {vm_tool-1.0.26/vm_tool.egg-info → vm_tool-1.0.28}/PKG-INFO +48 -7
  2. {vm_tool-1.0.26 → vm_tool-1.0.28}/README.md +45 -0
  3. {vm_tool-1.0.26 → vm_tool-1.0.28}/setup.py +1 -6
  4. vm_tool-1.0.28/vm_tool/cli.py +9 -0
  5. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/runner.py +26 -12
  6. vm_tool-1.0.28/vm_tool/vm_setup/github/git_configuration.yml +73 -0
  7. vm_tool-1.0.28/vm_tool/vm_setup/project_service.yml +17 -0
  8. {vm_tool-1.0.26 → vm_tool-1.0.28/vm_tool.egg-info}/PKG-INFO +48 -7
  9. vm_tool-1.0.26/vm_tool/cli.py +0 -14
  10. vm_tool-1.0.26/vm_tool/vm_setup/github/git_configuration.yml +0 -39
  11. vm_tool-1.0.26/vm_tool/vm_setup/project_service.yml +0 -16
  12. {vm_tool-1.0.26 → vm_tool-1.0.28}/LICENSE +0 -0
  13. {vm_tool-1.0.26 → vm_tool-1.0.28}/MANIFEST.in +0 -0
  14. {vm_tool-1.0.26 → vm_tool-1.0.28}/setup.cfg +0 -0
  15. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/__init__.py +0 -0
  16. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/ssh.py +0 -0
  17. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/cleanup.yml +0 -0
  18. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/docker/create_docker_service.yml +0 -0
  19. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/docker/docker_setup.yml +0 -0
  20. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
  21. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/docker/login_to_docker_hub.yml +0 -0
  22. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/dynamic_inventory.yml +0 -0
  23. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/inventory.yml +0 -0
  24. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/main.yml +0 -0
  25. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool/vm_setup/setup.yml +0 -0
  26. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool.egg-info/SOURCES.txt +0 -0
  27. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool.egg-info/dependency_links.txt +0 -0
  28. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool.egg-info/entry_points.txt +0 -0
  29. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool.egg-info/requires.txt +0 -0
  30. {vm_tool-1.0.26 → vm_tool-1.0.28}/vm_tool.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: vm_tool
3
- Version: 1.0.26
3
+ Version: 1.0.28
4
4
  Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
5
  Home-page: https://github.com/thesunnysinha/vm_tool
6
6
  Author: Sunny Sinha
@@ -15,11 +15,6 @@ Classifier: Intended Audience :: Developers
15
15
  Classifier: Intended Audience :: System Administrators
16
16
  Classifier: License :: OSI Approved :: MIT License
17
17
  Classifier: Programming Language :: Python
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.6
20
- Classifier: Programming Language :: Python :: 3.7
21
- Classifier: Programming Language :: Python :: 3.8
22
- Classifier: Programming Language :: Python :: 3.9
23
18
  Classifier: Programming Language :: Python :: 3.10
24
19
  Classifier: Programming Language :: Python :: 3.11
25
20
  Classifier: Programming Language :: Python :: 3.12
@@ -46,6 +41,7 @@ Dynamic: description-content-type
46
41
  Dynamic: home-page
47
42
  Dynamic: keywords
48
43
  Dynamic: license
44
+ Dynamic: license-file
49
45
  Dynamic: project-url
50
46
  Dynamic: provides-extra
51
47
  Dynamic: requires-dist
@@ -190,4 +186,49 @@ When you run the SSH setup, the tool will:
190
186
 
191
187
  ---
192
188
 
189
+ ## Command Line Version Info
190
+
191
+ If you want to check the installed version of `vm_tool`, you can use the following command:
192
+
193
+ ```bash
194
+ vm_tool --version
195
+ ```
196
+
197
+ This will print the current version of the package.
198
+
199
+ ---
200
+
201
+ ## Python API Usage
202
+
203
+ The primary class for using the VM Setup Tool is `SetupRunner`, which orchestrates the entire setup process.
204
+
205
+ ### **Example Usage**
206
+
207
+ ```python
208
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
209
+
210
+ config = SetupRunnerConfig(
211
+ # Configuration options
212
+ )
213
+
214
+ runner = SetupRunner(config)
215
+
216
+ runner.run_setup()
217
+ ```
218
+
219
+ ### **Configuration Options**
220
+ - `github_username`: Your GitHub username (required for private repositories).
221
+ - `github_token`: A GitHub token with repo access (required for private repositories).
222
+ - `github_project_url`: The URL of your GitHub project.
223
+ - `github_branch`: The branch of the GitHub repository to use.
224
+ - `docker_compose_file_path`: Path to your Docker Compose file.
225
+ - `dockerhub_username`: Your Docker Hub username (if Docker Hub login is needed).
226
+ - `dockerhub_password`: Your Docker Hub password (if Docker Hub login is needed).
227
+
228
+ ### **Methods**
229
+ - `run_setup()`: Executes the VM setup process.
230
+ - `run_cloud_setup(ssh_configs)`: Executes the cloud VM setup process using the provided SSH configurations.
231
+
232
+ ---
233
+
193
234
  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.
@@ -136,4 +136,49 @@ When you run the SSH setup, the tool will:
136
136
 
137
137
  ---
138
138
 
139
+ ## Command Line Version Info
140
+
141
+ If you want to check the installed version of `vm_tool`, you can use the following command:
142
+
143
+ ```bash
144
+ vm_tool --version
145
+ ```
146
+
147
+ This will print the current version of the package.
148
+
149
+ ---
150
+
151
+ ## Python API Usage
152
+
153
+ The primary class for using the VM Setup Tool is `SetupRunner`, which orchestrates the entire setup process.
154
+
155
+ ### **Example Usage**
156
+
157
+ ```python
158
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
159
+
160
+ config = SetupRunnerConfig(
161
+ # Configuration options
162
+ )
163
+
164
+ runner = SetupRunner(config)
165
+
166
+ runner.run_setup()
167
+ ```
168
+
169
+ ### **Configuration Options**
170
+ - `github_username`: Your GitHub username (required for private repositories).
171
+ - `github_token`: A GitHub token with repo access (required for private repositories).
172
+ - `github_project_url`: The URL of your GitHub project.
173
+ - `github_branch`: The branch of the GitHub repository to use.
174
+ - `docker_compose_file_path`: Path to your Docker Compose file.
175
+ - `dockerhub_username`: Your Docker Hub username (if Docker Hub login is needed).
176
+ - `dockerhub_password`: Your Docker Hub password (if Docker Hub login is needed).
177
+
178
+ ### **Methods**
179
+ - `run_setup()`: Executes the VM setup process.
180
+ - `run_cloud_setup(ssh_configs)`: Executes the cloud VM setup process using the provided SSH configurations.
181
+
182
+ ---
183
+
139
184
  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.
@@ -11,7 +11,7 @@ else:
11
11
 
12
12
  setup(
13
13
  name='vm_tool',
14
- version='1.0.26', # This will be updated by bump2version
14
+ version='1.0.28', # 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,
@@ -41,11 +41,6 @@ setup(
41
41
  'Intended Audience :: System Administrators',
42
42
  'License :: OSI Approved :: MIT License',
43
43
  'Programming Language :: Python',
44
- 'Programming Language :: Python :: 3',
45
- 'Programming Language :: Python :: 3.6',
46
- 'Programming Language :: Python :: 3.7',
47
- 'Programming Language :: Python :: 3.8',
48
- 'Programming Language :: Python :: 3.9',
49
44
  'Programming Language :: Python :: 3.10',
50
45
  'Programming Language :: Python :: 3.11',
51
46
  'Programming Language :: Python :: 3.12',
@@ -0,0 +1,9 @@
1
+ import argparse
2
+
3
+ def main():
4
+ parser = argparse.ArgumentParser(description='VM Tool version info')
5
+ parser.add_argument('--version', action='version', version='1.0.28')
6
+ parser.parse_args()
7
+
8
+ if __name__ == '__main__':
9
+ main()
@@ -2,7 +2,7 @@ import sys
2
2
  import ansible_runner
3
3
  import os
4
4
  import yaml
5
- from pydantic import BaseModel, validator, model_validator
5
+ from pydantic import BaseModel, validator, model_validator, Field
6
6
  from typing import List, Optional
7
7
 
8
8
  class SetupRunnerConfig(BaseModel):
@@ -19,13 +19,23 @@ class SetupRunnerConfig(BaseModel):
19
19
  dockerhub_password (Optional[str]): DockerHub password (required if username is provided).
20
20
  """
21
21
 
22
- github_username: Optional[str] = None
23
- github_token: Optional[str] = None
24
- github_project_url: str
25
- github_branch: str = "main" # Default to main branch
26
- docker_compose_file_path: str = 'docker-compose.yml'
27
- dockerhub_username: Optional[str] = None
28
- dockerhub_password: Optional[str] = None
22
+ github_username: Optional[str] = Field(
23
+ default=None, description="GitHub username for authentication (optional)"
24
+ )
25
+ github_token: Optional[str] = Field(
26
+ default=None, description="GitHub token for authentication (optional)"
27
+ )
28
+ github_project_url: str = Field(..., description="URL of the GitHub repository")
29
+ github_branch: str = Field(default='main', description="GitHub branch to use (default: 'main')")
30
+ docker_compose_file_path: str = Field(
31
+ default='docker-compose.yml', description="Path to the Docker Compose file (default: 'docker-compose.yml')"
32
+ )
33
+ dockerhub_username: Optional[str] = Field(
34
+ default=None, description="DockerHub username (optional)"
35
+ )
36
+ dockerhub_password: Optional[str] = Field(
37
+ default=None, description="DockerHub password (required if username is provided)"
38
+ )
29
39
 
30
40
  @validator('docker_compose_file_path', pre=True, always=True)
31
41
  def set_default_docker_compose_file_path(cls, v):
@@ -71,10 +81,14 @@ class SSHConfig(BaseModel):
71
81
  ssh_identity_file (Optional[str]): Path to SSH private key file (optional if password is provided).
72
82
  """
73
83
 
74
- ssh_username: str
75
- ssh_hostname: str
76
- ssh_password: Optional[str] = None
77
- ssh_identity_file: Optional[str] = None
84
+ ssh_username: str = Field(..., description="SSH username")
85
+ ssh_hostname: str = Field(..., description="SSH host/IP")
86
+ ssh_password: Optional[str] = Field(
87
+ default=None, description="SSH password (optional if identity file is provided)"
88
+ )
89
+ ssh_identity_file: Optional[str] = Field(
90
+ default=None, description="Path to SSH private key file (optional if password is provided)"
91
+ )
78
92
 
79
93
  @model_validator(mode="before")
80
94
  def validate_authentication(cls, values):
@@ -0,0 +1,73 @@
1
+ - name: Git Configuration Playbook
2
+ block:
3
+ - name: Ensure Git is installed
4
+ package:
5
+ name: git
6
+ state: present
7
+ become: yes
8
+
9
+ # --- Extract Project Name from GITHUB_PROJECT_URL ---
10
+ - name: Extract project name from GITHUB_PROJECT_URL
11
+ set_fact:
12
+ project_name: "{{ GITHUB_PROJECT_URL | basename | regex_replace('\\.git$', '') }}"
13
+
14
+ # --- Git Credential Setup ---
15
+ - name: Check if Git credentials file exists
16
+ stat:
17
+ path: ~/.git-credentials
18
+ register: git_credentials_stat
19
+
20
+ - name: Read contents of Git credentials file
21
+ slurp:
22
+ src: ~/.git-credentials
23
+ register: git_credentials_content
24
+ when: git_credentials_stat.stat.exists
25
+
26
+ - name: Decode Git credentials content
27
+ set_fact:
28
+ git_credentials: "{{ git_credentials_content.content | b64decode }}"
29
+ when: git_credentials_stat.stat.exists
30
+
31
+ - name: Fail if Git credentials not configured and vars not provided
32
+ fail:
33
+ msg: >
34
+ Git credentials not found and GITHUB_USERNAME/GITHUB_TOKEN not provided. Aborting.
35
+ when: >
36
+ (not git_credentials_stat.stat.exists or
37
+ ("{{ GITHUB_USERNAME }}" not in git_credentials | default(''))) and
38
+ (GITHUB_USERNAME is not defined or GITHUB_TOKEN is not defined)
39
+
40
+ - name: Configure Git with GitHub token if not already configured
41
+ shell: |
42
+ git config --global credential.helper store
43
+ echo "https://{{ GITHUB_USERNAME }}:{{ GITHUB_TOKEN }}@github.com" > ~/.git-credentials
44
+ become: yes
45
+ when: >
46
+ (not git_credentials_stat.stat.exists or
47
+ ("{{ GITHUB_USERNAME }}" not in git_credentials | default(''))) and
48
+ (GITHUB_USERNAME is defined and GITHUB_TOKEN is defined)
49
+
50
+ # --- Git Clone or Pull Logic ---
51
+ - name: Check if .git directory exists (repo already cloned)
52
+ stat:
53
+ path: "{{ project_dest_dir }}/.git"
54
+ register: project_dir_stat
55
+
56
+ - name: Pull latest changes if repository already exists
57
+ shell: |
58
+ cd {{ project_dest_dir }}
59
+ git remote set-url origin {{ GITHUB_PROJECT_URL }}
60
+ git fetch origin
61
+ git checkout {{ GITHUB_BRANCH }}
62
+ git pull origin {{ GITHUB_BRANCH }}
63
+ when: project_dir_stat.stat.exists
64
+ become: yes
65
+
66
+ - name: Clone the Project repository if not already cloned
67
+ git:
68
+ repo: "{{ GITHUB_PROJECT_URL }}"
69
+ dest: "{{ project_dest_dir }}"
70
+ version: "{{ GITHUB_BRANCH }}"
71
+ depth: 1
72
+ when: not project_dir_stat.stat.exists
73
+ become: yes
@@ -0,0 +1,17 @@
1
+ - name: Project Service Playbook
2
+ block:
3
+ - name: Set systemd service unit variables
4
+ set_fact:
5
+ systemd_unit_name: "{{ project_name }}-{{ branch_name }}.service"
6
+ systemd_unit_path: "/etc/systemd/system/{{ systemd_unit_name }}.service"
7
+
8
+ - name: Create Docker Service
9
+ include_tasks: docker/create_docker_service.yml
10
+
11
+ - name: Enable and start service
12
+ ansible.builtin.systemd:
13
+ name: "{{ systemd_unit_name }}"
14
+ state: started
15
+ enabled: yes
16
+ become: yes
17
+ ignore_errors: yes
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: vm_tool
3
- Version: 1.0.26
3
+ Version: 1.0.28
4
4
  Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
5
  Home-page: https://github.com/thesunnysinha/vm_tool
6
6
  Author: Sunny Sinha
@@ -15,11 +15,6 @@ Classifier: Intended Audience :: Developers
15
15
  Classifier: Intended Audience :: System Administrators
16
16
  Classifier: License :: OSI Approved :: MIT License
17
17
  Classifier: Programming Language :: Python
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.6
20
- Classifier: Programming Language :: Python :: 3.7
21
- Classifier: Programming Language :: Python :: 3.8
22
- Classifier: Programming Language :: Python :: 3.9
23
18
  Classifier: Programming Language :: Python :: 3.10
24
19
  Classifier: Programming Language :: Python :: 3.11
25
20
  Classifier: Programming Language :: Python :: 3.12
@@ -46,6 +41,7 @@ Dynamic: description-content-type
46
41
  Dynamic: home-page
47
42
  Dynamic: keywords
48
43
  Dynamic: license
44
+ Dynamic: license-file
49
45
  Dynamic: project-url
50
46
  Dynamic: provides-extra
51
47
  Dynamic: requires-dist
@@ -190,4 +186,49 @@ When you run the SSH setup, the tool will:
190
186
 
191
187
  ---
192
188
 
189
+ ## Command Line Version Info
190
+
191
+ If you want to check the installed version of `vm_tool`, you can use the following command:
192
+
193
+ ```bash
194
+ vm_tool --version
195
+ ```
196
+
197
+ This will print the current version of the package.
198
+
199
+ ---
200
+
201
+ ## Python API Usage
202
+
203
+ The primary class for using the VM Setup Tool is `SetupRunner`, which orchestrates the entire setup process.
204
+
205
+ ### **Example Usage**
206
+
207
+ ```python
208
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
209
+
210
+ config = SetupRunnerConfig(
211
+ # Configuration options
212
+ )
213
+
214
+ runner = SetupRunner(config)
215
+
216
+ runner.run_setup()
217
+ ```
218
+
219
+ ### **Configuration Options**
220
+ - `github_username`: Your GitHub username (required for private repositories).
221
+ - `github_token`: A GitHub token with repo access (required for private repositories).
222
+ - `github_project_url`: The URL of your GitHub project.
223
+ - `github_branch`: The branch of the GitHub repository to use.
224
+ - `docker_compose_file_path`: Path to your Docker Compose file.
225
+ - `dockerhub_username`: Your Docker Hub username (if Docker Hub login is needed).
226
+ - `dockerhub_password`: Your Docker Hub password (if Docker Hub login is needed).
227
+
228
+ ### **Methods**
229
+ - `run_setup()`: Executes the VM setup process.
230
+ - `run_cloud_setup(ssh_configs)`: Executes the cloud VM setup process using the provided SSH configurations.
231
+
232
+ ---
233
+
193
234
  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.
@@ -1,14 +0,0 @@
1
- import argparse
2
-
3
- def main():
4
- parser = argparse.ArgumentParser(description='Setup VMs using Ansible.')
5
- parser.add_argument('--version', action='version', version='1.0.26')
6
-
7
- args = parser.parse_args()
8
-
9
- # If no arguments are provided, print the help message
10
- if not vars(args):
11
- parser.print_help()
12
-
13
- if __name__ == '__main__':
14
- main()
@@ -1,39 +0,0 @@
1
- - name: Git Configuration Playbook
2
- block:
3
- - name: Ensure Git is installed
4
- package:
5
- name: git
6
- state: present
7
- become: yes
8
-
9
- - name: Configure Git with GitHub token
10
- shell: |
11
- git config --global credential.helper store
12
- echo "https://{{ GITHUB_USERNAME }}:{{ GITHUB_TOKEN }}@github.com" > ~/.git-credentials
13
- become: yes
14
- when: GITHUB_TOKEN is defined and GITHUB_USERNAME is defined
15
-
16
- - name: Check if project directory exists
17
- stat:
18
- path: "{{ project_dest_dir }}"
19
- register: project_dir_stat
20
-
21
- - name: Remove existing Project repository if present
22
- file:
23
- path: "{{ project_dest_dir }}"
24
- state: absent
25
- force: yes
26
- become: yes
27
- when: project_dir_stat.stat.exists
28
-
29
- - name: Log the GitHub repository being cloned
30
- debug:
31
- msg: "Cloning repository from {{ GITHUB_PROJECT_URL }} (branch: {{ GITHUB_BRANCH }})"
32
-
33
- - name: Clone the Project repository with shallow clone
34
- git:
35
- repo: "{{ GITHUB_PROJECT_URL }}"
36
- dest: "{{ project_dest_dir }}"
37
- version: "{{ GITHUB_BRANCH }}"
38
- depth: 1
39
- become: yes
@@ -1,16 +0,0 @@
1
- - name: Project Service Playbook
2
- block:
3
- - name: Set service_file_path variable
4
- set_fact:
5
- service_file_path: /etc/systemd/system/project.service
6
-
7
- - name: Create Docker Service
8
- include_tasks: docker/create_docker_service.yml
9
-
10
- - name: Enable and start project service
11
- ansible.builtin.systemd:
12
- name: project
13
- state: started
14
- enabled: yes
15
- become: yes
16
- ignore_errors: yes
File without changes
File without changes
File without changes
File without changes
File without changes