vm-tool 1.0.27__tar.gz → 1.0.29__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 (33) hide show
  1. vm_tool-1.0.29/PKG-INFO +169 -0
  2. vm_tool-1.0.29/README.md +119 -0
  3. {vm_tool-1.0.27 → vm_tool-1.0.29}/setup.py +1 -6
  4. vm_tool-1.0.29/vm_tool/cli.py +9 -0
  5. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/runner.py +26 -12
  6. vm_tool-1.0.29/vm_tool/vm_setup/github/git_configuration.yml +73 -0
  7. vm_tool-1.0.29/vm_tool/vm_setup/project_service.yml +17 -0
  8. vm_tool-1.0.29/vm_tool.egg-info/PKG-INFO +169 -0
  9. vm_tool-1.0.27/PKG-INFO +0 -193
  10. vm_tool-1.0.27/README.md +0 -139
  11. vm_tool-1.0.27/vm_tool/cli.py +0 -14
  12. vm_tool-1.0.27/vm_tool/vm_setup/github/git_configuration.yml +0 -46
  13. vm_tool-1.0.27/vm_tool/vm_setup/project_service.yml +0 -16
  14. vm_tool-1.0.27/vm_tool.egg-info/PKG-INFO +0 -193
  15. {vm_tool-1.0.27 → vm_tool-1.0.29}/LICENSE +0 -0
  16. {vm_tool-1.0.27 → vm_tool-1.0.29}/MANIFEST.in +0 -0
  17. {vm_tool-1.0.27 → vm_tool-1.0.29}/setup.cfg +0 -0
  18. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/__init__.py +0 -0
  19. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/ssh.py +0 -0
  20. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/cleanup.yml +0 -0
  21. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/docker/create_docker_service.yml +0 -0
  22. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/docker/docker_setup.yml +0 -0
  23. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
  24. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/docker/login_to_docker_hub.yml +0 -0
  25. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/dynamic_inventory.yml +0 -0
  26. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/inventory.yml +0 -0
  27. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/main.yml +0 -0
  28. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool/vm_setup/setup.yml +0 -0
  29. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool.egg-info/SOURCES.txt +0 -0
  30. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool.egg-info/dependency_links.txt +0 -0
  31. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool.egg-info/entry_points.txt +0 -0
  32. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool.egg-info/requires.txt +0 -0
  33. {vm_tool-1.0.27 → vm_tool-1.0.29}/vm_tool.egg-info/top_level.txt +0 -0
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: vm_tool
3
+ Version: 1.0.29
4
+ Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
+ Home-page: https://github.com/thesunnysinha/vm_tool
6
+ Author: Sunny Sinha
7
+ Author-email: thesunnysinha@gmail.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://github.com/thesunnysinha/vm_tool/README.md
10
+ Project-URL: Source, https://github.com/thesunnysinha/vm_tool
11
+ Project-URL: Tracker, https://github.com/thesunnysinha/vm_tool/issues
12
+ Keywords: virtual machine setup ansible automation
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Build Tools
23
+ Classifier: Topic :: System :: Systems Administration
24
+ Requires-Python: >=3.6
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: ansible
28
+ Requires-Dist: ansible-runner
29
+ Requires-Dist: paramiko
30
+ Requires-Dist: pydantic
31
+ Requires-Dist: pyyaml
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: flake8; extra == "dev"
35
+ Requires-Dist: bump2version; extra == "dev"
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description
40
+ Dynamic: description-content-type
41
+ Dynamic: home-page
42
+ Dynamic: keywords
43
+ Dynamic: license
44
+ Dynamic: license-file
45
+ Dynamic: project-url
46
+ Dynamic: provides-extra
47
+ Dynamic: requires-dist
48
+ Dynamic: requires-python
49
+ Dynamic: summary
50
+
51
+ # 🚀 VM Setup Tool
52
+
53
+ [![PyPI version](https://img.shields.io/pypi/v/vm-tool.svg)](https://pypi.org/project/vm-tool/) [![Python versions](https://img.shields.io/pypi/pyversions/vm-tool.svg)](https://pypi.org/project/vm-tool/)
54
+
55
+ [**PyPI**](https://pypi.org/project/vm-tool/) • [**GitHub**](https://github.com/thesunnysinha/vm_tool) • [**Contributing**](CONTRIBUTING) • [**License**](LICENSE)
56
+
57
+ A modern, user-friendly solution for automating and managing virtual machine (VM) setup and configuration using Ansible.
58
+
59
+ ---
60
+
61
+ ## ✨ Features
62
+ - Automated VM setup with Docker & Docker Compose
63
+ - Cloud VM provisioning via SSH
64
+ - SSH key management and configuration
65
+ - Simple Python API for integration
66
+ - One-command version check: `vm_tool --version`
67
+
68
+ ---
69
+
70
+ ## ⚡️ Installation
71
+ Install the latest version from PyPI:
72
+
73
+ ```bash
74
+ pip install vm-tool
75
+ ```
76
+
77
+ ---
78
+
79
+ ## 🛠️ Usage Examples
80
+
81
+ ### Automated Local VM Setup
82
+ ```python
83
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
84
+
85
+ config = SetupRunnerConfig(
86
+ github_username='your_github_username',
87
+ github_token='your_github_token',
88
+ github_project_url='your_github_project_url',
89
+ github_branch='your_branch_name',
90
+ docker_compose_file_path='path_to_your_docker_compose_file',
91
+ dockerhub_username='your_dockerhub_username',
92
+ dockerhub_password='your_dockerhub_password'
93
+ )
94
+
95
+ runner = SetupRunner(config)
96
+ runner.run_setup()
97
+ ```
98
+
99
+ ### Cloud VM Setup (via SSH)
100
+ ```python
101
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
102
+
103
+ config = SetupRunnerConfig(
104
+ github_username='your_github_username',
105
+ github_token='your_github_token',
106
+ github_project_url='your_github_project_url',
107
+ github_branch='your_branch_name',
108
+ docker_compose_file_path='path_to_your_docker_compose_file',
109
+ dockerhub_username='your_dockerhub_username',
110
+ dockerhub_password='your_dockerhub_password'
111
+ )
112
+
113
+ runner = SetupRunner(config)
114
+
115
+ ssh_configs = [
116
+ SSHConfig(
117
+ ssh_username='your_ssh_username',
118
+ ssh_password='your_ssh_password',
119
+ ssh_hostname='your_ssh_hostname',
120
+ ssh_identity_file='/path/to/your/ssh_key' # Optional
121
+ )
122
+ ]
123
+
124
+ runner.run_cloud_setup(ssh_configs)
125
+ ```
126
+
127
+ ### SSH Key Management
128
+ ```python
129
+ from vm_tool.ssh import SSHSetup
130
+
131
+ ssh_setup = SSHSetup(
132
+ hostname='your_vm_hostname',
133
+ username='your_vm_username',
134
+ password='your_vm_password',
135
+ email='your_email_for_ssh_key'
136
+ )
137
+
138
+ ssh_setup.setup()
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 🖥️ Command Line Version Check
144
+
145
+ Check your installed version at any time:
146
+
147
+ ```bash
148
+ vm_tool --version
149
+ ```
150
+
151
+ ---
152
+
153
+ ## ⚙️ Configuration Options
154
+ - `github_username`: GitHub username (for private repos)
155
+ - `github_token`: GitHub token (for private repos)
156
+ - `github_project_url`: GitHub repository URL
157
+ - `github_branch`: Branch to use (default: main)
158
+ - `docker_compose_file_path`: Path to Docker Compose file (default: docker-compose.yml)
159
+ - `dockerhub_username`: Docker Hub username (if login needed)
160
+ - `dockerhub_password`: Docker Hub password (if login needed)
161
+
162
+ ---
163
+
164
+ ## 📚 Learn More
165
+ See the [PyPI page](https://pypi.org/project/vm-tool/) for more details, or visit the [GitHub repository](https://github.com/thesunnysinha/vm_tool) for full documentation, issues, and contributions.
166
+
167
+ ---
168
+
169
+ Empower your infrastructure automation with **VM Setup Tool** – fast, reliable, and developer-friendly!
@@ -0,0 +1,119 @@
1
+ # 🚀 VM Setup Tool
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/vm-tool.svg)](https://pypi.org/project/vm-tool/) [![Python versions](https://img.shields.io/pypi/pyversions/vm-tool.svg)](https://pypi.org/project/vm-tool/)
4
+
5
+ [**PyPI**](https://pypi.org/project/vm-tool/) • [**GitHub**](https://github.com/thesunnysinha/vm_tool) • [**Contributing**](CONTRIBUTING) • [**License**](LICENSE)
6
+
7
+ A modern, user-friendly solution for automating and managing virtual machine (VM) setup and configuration using Ansible.
8
+
9
+ ---
10
+
11
+ ## ✨ Features
12
+ - Automated VM setup with Docker & Docker Compose
13
+ - Cloud VM provisioning via SSH
14
+ - SSH key management and configuration
15
+ - Simple Python API for integration
16
+ - One-command version check: `vm_tool --version`
17
+
18
+ ---
19
+
20
+ ## ⚡️ Installation
21
+ Install the latest version from PyPI:
22
+
23
+ ```bash
24
+ pip install vm-tool
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 🛠️ Usage Examples
30
+
31
+ ### Automated Local VM Setup
32
+ ```python
33
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
34
+
35
+ config = SetupRunnerConfig(
36
+ github_username='your_github_username',
37
+ github_token='your_github_token',
38
+ github_project_url='your_github_project_url',
39
+ github_branch='your_branch_name',
40
+ docker_compose_file_path='path_to_your_docker_compose_file',
41
+ dockerhub_username='your_dockerhub_username',
42
+ dockerhub_password='your_dockerhub_password'
43
+ )
44
+
45
+ runner = SetupRunner(config)
46
+ runner.run_setup()
47
+ ```
48
+
49
+ ### Cloud VM Setup (via SSH)
50
+ ```python
51
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
52
+
53
+ config = SetupRunnerConfig(
54
+ github_username='your_github_username',
55
+ github_token='your_github_token',
56
+ github_project_url='your_github_project_url',
57
+ github_branch='your_branch_name',
58
+ docker_compose_file_path='path_to_your_docker_compose_file',
59
+ dockerhub_username='your_dockerhub_username',
60
+ dockerhub_password='your_dockerhub_password'
61
+ )
62
+
63
+ runner = SetupRunner(config)
64
+
65
+ ssh_configs = [
66
+ SSHConfig(
67
+ ssh_username='your_ssh_username',
68
+ ssh_password='your_ssh_password',
69
+ ssh_hostname='your_ssh_hostname',
70
+ ssh_identity_file='/path/to/your/ssh_key' # Optional
71
+ )
72
+ ]
73
+
74
+ runner.run_cloud_setup(ssh_configs)
75
+ ```
76
+
77
+ ### SSH Key Management
78
+ ```python
79
+ from vm_tool.ssh import SSHSetup
80
+
81
+ ssh_setup = SSHSetup(
82
+ hostname='your_vm_hostname',
83
+ username='your_vm_username',
84
+ password='your_vm_password',
85
+ email='your_email_for_ssh_key'
86
+ )
87
+
88
+ ssh_setup.setup()
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 🖥️ Command Line Version Check
94
+
95
+ Check your installed version at any time:
96
+
97
+ ```bash
98
+ vm_tool --version
99
+ ```
100
+
101
+ ---
102
+
103
+ ## ⚙️ Configuration Options
104
+ - `github_username`: GitHub username (for private repos)
105
+ - `github_token`: GitHub token (for private repos)
106
+ - `github_project_url`: GitHub repository URL
107
+ - `github_branch`: Branch to use (default: main)
108
+ - `docker_compose_file_path`: Path to Docker Compose file (default: docker-compose.yml)
109
+ - `dockerhub_username`: Docker Hub username (if login needed)
110
+ - `dockerhub_password`: Docker Hub password (if login needed)
111
+
112
+ ---
113
+
114
+ ## 📚 Learn More
115
+ See the [PyPI page](https://pypi.org/project/vm-tool/) for more details, or visit the [GitHub repository](https://github.com/thesunnysinha/vm_tool) for full documentation, issues, and contributions.
116
+
117
+ ---
118
+
119
+ Empower your infrastructure automation with **VM Setup Tool** – fast, reliable, and developer-friendly!
@@ -11,7 +11,7 @@ else:
11
11
 
12
12
  setup(
13
13
  name='vm_tool',
14
- version='1.0.27', # This will be updated by bump2version
14
+ version='1.0.29', # 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.29')
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
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: vm_tool
3
+ Version: 1.0.29
4
+ Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
+ Home-page: https://github.com/thesunnysinha/vm_tool
6
+ Author: Sunny Sinha
7
+ Author-email: thesunnysinha@gmail.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://github.com/thesunnysinha/vm_tool/README.md
10
+ Project-URL: Source, https://github.com/thesunnysinha/vm_tool
11
+ Project-URL: Tracker, https://github.com/thesunnysinha/vm_tool/issues
12
+ Keywords: virtual machine setup ansible automation
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Build Tools
23
+ Classifier: Topic :: System :: Systems Administration
24
+ Requires-Python: >=3.6
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: ansible
28
+ Requires-Dist: ansible-runner
29
+ Requires-Dist: paramiko
30
+ Requires-Dist: pydantic
31
+ Requires-Dist: pyyaml
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: flake8; extra == "dev"
35
+ Requires-Dist: bump2version; extra == "dev"
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description
40
+ Dynamic: description-content-type
41
+ Dynamic: home-page
42
+ Dynamic: keywords
43
+ Dynamic: license
44
+ Dynamic: license-file
45
+ Dynamic: project-url
46
+ Dynamic: provides-extra
47
+ Dynamic: requires-dist
48
+ Dynamic: requires-python
49
+ Dynamic: summary
50
+
51
+ # 🚀 VM Setup Tool
52
+
53
+ [![PyPI version](https://img.shields.io/pypi/v/vm-tool.svg)](https://pypi.org/project/vm-tool/) [![Python versions](https://img.shields.io/pypi/pyversions/vm-tool.svg)](https://pypi.org/project/vm-tool/)
54
+
55
+ [**PyPI**](https://pypi.org/project/vm-tool/) • [**GitHub**](https://github.com/thesunnysinha/vm_tool) • [**Contributing**](CONTRIBUTING) • [**License**](LICENSE)
56
+
57
+ A modern, user-friendly solution for automating and managing virtual machine (VM) setup and configuration using Ansible.
58
+
59
+ ---
60
+
61
+ ## ✨ Features
62
+ - Automated VM setup with Docker & Docker Compose
63
+ - Cloud VM provisioning via SSH
64
+ - SSH key management and configuration
65
+ - Simple Python API for integration
66
+ - One-command version check: `vm_tool --version`
67
+
68
+ ---
69
+
70
+ ## ⚡️ Installation
71
+ Install the latest version from PyPI:
72
+
73
+ ```bash
74
+ pip install vm-tool
75
+ ```
76
+
77
+ ---
78
+
79
+ ## 🛠️ Usage Examples
80
+
81
+ ### Automated Local VM Setup
82
+ ```python
83
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
84
+
85
+ config = SetupRunnerConfig(
86
+ github_username='your_github_username',
87
+ github_token='your_github_token',
88
+ github_project_url='your_github_project_url',
89
+ github_branch='your_branch_name',
90
+ docker_compose_file_path='path_to_your_docker_compose_file',
91
+ dockerhub_username='your_dockerhub_username',
92
+ dockerhub_password='your_dockerhub_password'
93
+ )
94
+
95
+ runner = SetupRunner(config)
96
+ runner.run_setup()
97
+ ```
98
+
99
+ ### Cloud VM Setup (via SSH)
100
+ ```python
101
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
102
+
103
+ config = SetupRunnerConfig(
104
+ github_username='your_github_username',
105
+ github_token='your_github_token',
106
+ github_project_url='your_github_project_url',
107
+ github_branch='your_branch_name',
108
+ docker_compose_file_path='path_to_your_docker_compose_file',
109
+ dockerhub_username='your_dockerhub_username',
110
+ dockerhub_password='your_dockerhub_password'
111
+ )
112
+
113
+ runner = SetupRunner(config)
114
+
115
+ ssh_configs = [
116
+ SSHConfig(
117
+ ssh_username='your_ssh_username',
118
+ ssh_password='your_ssh_password',
119
+ ssh_hostname='your_ssh_hostname',
120
+ ssh_identity_file='/path/to/your/ssh_key' # Optional
121
+ )
122
+ ]
123
+
124
+ runner.run_cloud_setup(ssh_configs)
125
+ ```
126
+
127
+ ### SSH Key Management
128
+ ```python
129
+ from vm_tool.ssh import SSHSetup
130
+
131
+ ssh_setup = SSHSetup(
132
+ hostname='your_vm_hostname',
133
+ username='your_vm_username',
134
+ password='your_vm_password',
135
+ email='your_email_for_ssh_key'
136
+ )
137
+
138
+ ssh_setup.setup()
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 🖥️ Command Line Version Check
144
+
145
+ Check your installed version at any time:
146
+
147
+ ```bash
148
+ vm_tool --version
149
+ ```
150
+
151
+ ---
152
+
153
+ ## ⚙️ Configuration Options
154
+ - `github_username`: GitHub username (for private repos)
155
+ - `github_token`: GitHub token (for private repos)
156
+ - `github_project_url`: GitHub repository URL
157
+ - `github_branch`: Branch to use (default: main)
158
+ - `docker_compose_file_path`: Path to Docker Compose file (default: docker-compose.yml)
159
+ - `dockerhub_username`: Docker Hub username (if login needed)
160
+ - `dockerhub_password`: Docker Hub password (if login needed)
161
+
162
+ ---
163
+
164
+ ## 📚 Learn More
165
+ See the [PyPI page](https://pypi.org/project/vm-tool/) for more details, or visit the [GitHub repository](https://github.com/thesunnysinha/vm_tool) for full documentation, issues, and contributions.
166
+
167
+ ---
168
+
169
+ Empower your infrastructure automation with **VM Setup Tool** – fast, reliable, and developer-friendly!
vm_tool-1.0.27/PKG-INFO DELETED
@@ -1,193 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: vm_tool
3
- Version: 1.0.27
4
- Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
- Home-page: https://github.com/thesunnysinha/vm_tool
6
- Author: Sunny Sinha
7
- Author-email: thesunnysinha@gmail.com
8
- License: MIT
9
- Project-URL: Documentation, https://github.com/thesunnysinha/vm_tool/README.md
10
- Project-URL: Source, https://github.com/thesunnysinha/vm_tool
11
- Project-URL: Tracker, https://github.com/thesunnysinha/vm_tool/issues
12
- Keywords: virtual machine setup ansible automation
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Intended Audience :: System Administrators
16
- Classifier: License :: OSI Approved :: MIT License
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
- Classifier: Programming Language :: Python :: 3.10
24
- Classifier: Programming Language :: Python :: 3.11
25
- Classifier: Programming Language :: Python :: 3.12
26
- Classifier: Programming Language :: Python :: 3.13
27
- Classifier: Topic :: Software Development :: Build Tools
28
- Classifier: Topic :: System :: Systems Administration
29
- Requires-Python: >=3.6
30
- Description-Content-Type: text/markdown
31
- License-File: LICENSE
32
- Requires-Dist: ansible
33
- Requires-Dist: ansible-runner
34
- Requires-Dist: paramiko
35
- Requires-Dist: pydantic
36
- Requires-Dist: pyyaml
37
- Provides-Extra: dev
38
- Requires-Dist: pytest; extra == "dev"
39
- Requires-Dist: flake8; extra == "dev"
40
- Requires-Dist: bump2version; extra == "dev"
41
- Dynamic: author
42
- Dynamic: author-email
43
- Dynamic: classifier
44
- Dynamic: description
45
- Dynamic: description-content-type
46
- Dynamic: home-page
47
- Dynamic: keywords
48
- Dynamic: license
49
- Dynamic: project-url
50
- Dynamic: provides-extra
51
- Dynamic: requires-dist
52
- Dynamic: requires-python
53
- Dynamic: summary
54
-
55
- # **VM Setup Tool**
56
- ### **A Comprehensive Solution for Streamlining Virtual Machine Configuration**
57
-
58
- ## **Overview**
59
- 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.
60
-
61
- ---
62
-
63
- ## **Pre-requisites**
64
- This tool supports projects utilizing **Docker Compose**.
65
-
66
- ---
67
-
68
- ## **Installation**
69
- Install the VM Setup Tool using **pip**, the Python package manager:
70
-
71
- ```bash
72
- pip install vm-tool
73
- ```
74
-
75
- ---
76
-
77
- ## **Example Usage**
78
-
79
- ### **Automated VM Setup**
80
- Use the following example to configure and run the VM setup:
81
-
82
- ```python
83
- from vm_tool.runner import SetupRunner, SetupRunnerConfig
84
-
85
- config = SetupRunnerConfig(
86
- github_username='your_github_username', # Required if the repository is private, e.g., username
87
- github_token='your_github_token', # Required if the repository is private, e.g., token
88
- github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
89
- github_branch='your_branch_name', # Optional, defaults to 'main'
90
- docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
91
- dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
92
- dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
93
- )
94
-
95
- runner = SetupRunner(config)
96
-
97
- runner.run_setup()
98
- ```
99
-
100
- ### **What Happens During Setup**
101
- The VM Setup Tool will:
102
- 1. Configure Git with GitHub token if provided.
103
- 2. Clone the specified GitHub repository to your local machine.
104
- 3. Install **Docker** if it’s not already available on the target machine.
105
- 4. Install **Docker Compose** for managing multi-container applications.
106
- 5. Log in to Docker Hub if credentials are provided.
107
- 6. Create, enable, and start the Docker service.
108
- 7. Ensure the Docker container remains active, providing a robust environment for your applications.
109
-
110
- By automating these tasks, the tool minimizes errors and saves time, allowing you to focus on development and deployment.
111
-
112
- ---
113
-
114
- ## **Cloud Setup**
115
- The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
116
-
117
- ```python
118
- from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
119
-
120
- config = SetupRunnerConfig(
121
- github_username='your_github_username', # Required if the repository is private, e.g., username
122
- github_token='your_github_token', # Required if the repository is private, e.g., token
123
- github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
124
- github_branch='your_branch_name', # Optional, defaults to 'main'
125
- docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
126
- dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
127
- dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
128
- )
129
-
130
- runner = SetupRunner(config)
131
-
132
- ssh_configs = [
133
- SSHConfig(
134
- ssh_username='your_ssh_username_1', # e.g., ssh_user_1
135
- ssh_password='your_ssh_password_1', # Optional, only use if you don’t want to use SSH key
136
- ssh_hostname='your_ssh_hostname_1', # e.g., ssh1.example.com
137
- ssh_identity_file='/path/to/your/ssh_key_1' # Optional, path to SSH Identity file
138
- ),
139
- SSHConfig(
140
- ssh_username='your_ssh_username_2', # e.g., ssh_user_2
141
- ssh_password='your_ssh_password_2', # Optional, only use if you don’t want to use SSH key
142
- ssh_hostname='your_ssh_hostname_2', # e.g., ssh2.example.com
143
- ssh_identity_file='/path/to/your/ssh_key_2' # Optional, path to SSH Identity file
144
- )
145
- # Add more SSHConfig instances as needed
146
- ]
147
-
148
- runner.run_cloud_setup(ssh_configs)
149
- ```
150
-
151
- ### **What Happens During Cloud Setup**
152
- When you run the cloud setup, the tool will:
153
- 1. Connect to the specified cloud VM using SSH.
154
- 2. Configure Git with GitHub token if provided.
155
- 3. Clone the specified GitHub repository to the VM.
156
- 4. Install **Docker** if it’s not already available on the VM.
157
- 5. Install **Docker Compose** for managing multi-container applications.
158
- 6. Log in to Docker Hub if credentials are provided.
159
- 7. Create, enable, and start the Docker service on the VM.
160
- 8. Ensure the Docker container remains active, providing a robust environment for your applications.
161
-
162
- ---
163
-
164
- ## **SSH Client Feature**
165
- 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.
166
-
167
- ### **Example Usage**
168
-
169
- ```python
170
- from vm_tool.ssh import SSHSetup
171
-
172
- ssh_setup = SSHSetup(
173
- hostname='your_vm_hostname', # e.g., vm.example.com
174
- username='your_vm_username', # e.g., user
175
- password='your_vm_password', # e.g., password
176
- email='your_email_for_ssh_key' # e.g., user@example.com
177
- )
178
-
179
- ssh_setup.setup()
180
- ```
181
-
182
- ### **What Happens During SSH Setup**
183
- When you run the SSH setup, the tool will:
184
- 1. Generate an SSH key pair if none exists.
185
- 2. Read the public SSH key or create a new one if necessary.
186
- 3. Configure the VM by adding the public key to the VM's **authorized_keys** file.
187
- 4. Update the local SSH configuration file with the VM's details.
188
- 5. Establish an SSH connection to verify the setup.
189
- 6. Close the connection once setup is complete.
190
-
191
- ---
192
-
193
- 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.
vm_tool-1.0.27/README.md DELETED
@@ -1,139 +0,0 @@
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**.
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, SetupRunnerConfig
30
-
31
- config = SetupRunnerConfig(
32
- github_username='your_github_username', # Required if the repository is private, e.g., username
33
- github_token='your_github_token', # Required if the repository is private, e.g., token
34
- github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
35
- github_branch='your_branch_name', # Optional, defaults to 'main'
36
- docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
37
- dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
38
- dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
39
- )
40
-
41
- runner = SetupRunner(config)
42
-
43
- runner.run_setup()
44
- ```
45
-
46
- ### **What Happens During Setup**
47
- The VM Setup Tool will:
48
- 1. Configure Git with GitHub token if provided.
49
- 2. Clone the specified GitHub repository to your local machine.
50
- 3. Install **Docker** if it’s not already available on the target machine.
51
- 4. Install **Docker Compose** for managing multi-container applications.
52
- 5. Log in to Docker Hub if credentials are provided.
53
- 6. Create, enable, and start the Docker service.
54
- 7. Ensure the Docker container remains active, providing a robust environment for your applications.
55
-
56
- By automating these tasks, the tool minimizes errors and saves time, allowing you to focus on development and deployment.
57
-
58
- ---
59
-
60
- ## **Cloud Setup**
61
- The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
62
-
63
- ```python
64
- from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
65
-
66
- config = SetupRunnerConfig(
67
- github_username='your_github_username', # Required if the repository is private, e.g., username
68
- github_token='your_github_token', # Required if the repository is private, e.g., token
69
- github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
70
- github_branch='your_branch_name', # Optional, defaults to 'main'
71
- docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
72
- dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
73
- dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
74
- )
75
-
76
- runner = SetupRunner(config)
77
-
78
- ssh_configs = [
79
- SSHConfig(
80
- ssh_username='your_ssh_username_1', # e.g., ssh_user_1
81
- ssh_password='your_ssh_password_1', # Optional, only use if you don’t want to use SSH key
82
- ssh_hostname='your_ssh_hostname_1', # e.g., ssh1.example.com
83
- ssh_identity_file='/path/to/your/ssh_key_1' # Optional, path to SSH Identity file
84
- ),
85
- SSHConfig(
86
- ssh_username='your_ssh_username_2', # e.g., ssh_user_2
87
- ssh_password='your_ssh_password_2', # Optional, only use if you don’t want to use SSH key
88
- ssh_hostname='your_ssh_hostname_2', # e.g., ssh2.example.com
89
- ssh_identity_file='/path/to/your/ssh_key_2' # Optional, path to SSH Identity file
90
- )
91
- # Add more SSHConfig instances as needed
92
- ]
93
-
94
- runner.run_cloud_setup(ssh_configs)
95
- ```
96
-
97
- ### **What Happens During Cloud Setup**
98
- When you run the cloud setup, the tool will:
99
- 1. Connect to the specified cloud VM using SSH.
100
- 2. Configure Git with GitHub token if provided.
101
- 3. Clone the specified GitHub repository to the VM.
102
- 4. Install **Docker** if it’s not already available on the VM.
103
- 5. Install **Docker Compose** for managing multi-container applications.
104
- 6. Log in to Docker Hub if credentials are provided.
105
- 7. Create, enable, and start the Docker service on the VM.
106
- 8. Ensure the Docker container remains active, providing a robust environment for your applications.
107
-
108
- ---
109
-
110
- ## **SSH Client Feature**
111
- 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.
112
-
113
- ### **Example Usage**
114
-
115
- ```python
116
- from vm_tool.ssh import SSHSetup
117
-
118
- ssh_setup = SSHSetup(
119
- hostname='your_vm_hostname', # e.g., vm.example.com
120
- username='your_vm_username', # e.g., user
121
- password='your_vm_password', # e.g., password
122
- email='your_email_for_ssh_key' # e.g., user@example.com
123
- )
124
-
125
- ssh_setup.setup()
126
- ```
127
-
128
- ### **What Happens During SSH Setup**
129
- When you run the SSH setup, the tool will:
130
- 1. Generate an SSH key pair if none exists.
131
- 2. Read the public SSH key or create a new one if necessary.
132
- 3. Configure the VM by adding the public key to the VM's **authorized_keys** file.
133
- 4. Update the local SSH configuration file with the VM's details.
134
- 5. Establish an SSH connection to verify the setup.
135
- 6. Close the connection once setup is complete.
136
-
137
- ---
138
-
139
- 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.27')
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,46 +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: Ensure project directory is empty
34
- file:
35
- path: "{{ project_dest_dir }}"
36
- state: directory
37
- mode: '0755'
38
- become: yes
39
-
40
- - name: Clone the Project repository with shallow clone
41
- git:
42
- repo: "{{ GITHUB_PROJECT_URL }}"
43
- dest: "{{ project_dest_dir }}"
44
- version: "{{ GITHUB_BRANCH }}"
45
- depth: 1
46
- 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
@@ -1,193 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: vm_tool
3
- Version: 1.0.27
4
- Summary: A Comprehensive Tool for Setting Up Virtual Machines.
5
- Home-page: https://github.com/thesunnysinha/vm_tool
6
- Author: Sunny Sinha
7
- Author-email: thesunnysinha@gmail.com
8
- License: MIT
9
- Project-URL: Documentation, https://github.com/thesunnysinha/vm_tool/README.md
10
- Project-URL: Source, https://github.com/thesunnysinha/vm_tool
11
- Project-URL: Tracker, https://github.com/thesunnysinha/vm_tool/issues
12
- Keywords: virtual machine setup ansible automation
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Intended Audience :: System Administrators
16
- Classifier: License :: OSI Approved :: MIT License
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
- Classifier: Programming Language :: Python :: 3.10
24
- Classifier: Programming Language :: Python :: 3.11
25
- Classifier: Programming Language :: Python :: 3.12
26
- Classifier: Programming Language :: Python :: 3.13
27
- Classifier: Topic :: Software Development :: Build Tools
28
- Classifier: Topic :: System :: Systems Administration
29
- Requires-Python: >=3.6
30
- Description-Content-Type: text/markdown
31
- License-File: LICENSE
32
- Requires-Dist: ansible
33
- Requires-Dist: ansible-runner
34
- Requires-Dist: paramiko
35
- Requires-Dist: pydantic
36
- Requires-Dist: pyyaml
37
- Provides-Extra: dev
38
- Requires-Dist: pytest; extra == "dev"
39
- Requires-Dist: flake8; extra == "dev"
40
- Requires-Dist: bump2version; extra == "dev"
41
- Dynamic: author
42
- Dynamic: author-email
43
- Dynamic: classifier
44
- Dynamic: description
45
- Dynamic: description-content-type
46
- Dynamic: home-page
47
- Dynamic: keywords
48
- Dynamic: license
49
- Dynamic: project-url
50
- Dynamic: provides-extra
51
- Dynamic: requires-dist
52
- Dynamic: requires-python
53
- Dynamic: summary
54
-
55
- # **VM Setup Tool**
56
- ### **A Comprehensive Solution for Streamlining Virtual Machine Configuration**
57
-
58
- ## **Overview**
59
- 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.
60
-
61
- ---
62
-
63
- ## **Pre-requisites**
64
- This tool supports projects utilizing **Docker Compose**.
65
-
66
- ---
67
-
68
- ## **Installation**
69
- Install the VM Setup Tool using **pip**, the Python package manager:
70
-
71
- ```bash
72
- pip install vm-tool
73
- ```
74
-
75
- ---
76
-
77
- ## **Example Usage**
78
-
79
- ### **Automated VM Setup**
80
- Use the following example to configure and run the VM setup:
81
-
82
- ```python
83
- from vm_tool.runner import SetupRunner, SetupRunnerConfig
84
-
85
- config = SetupRunnerConfig(
86
- github_username='your_github_username', # Required if the repository is private, e.g., username
87
- github_token='your_github_token', # Required if the repository is private, e.g., token
88
- github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
89
- github_branch='your_branch_name', # Optional, defaults to 'main'
90
- docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
91
- dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
92
- dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
93
- )
94
-
95
- runner = SetupRunner(config)
96
-
97
- runner.run_setup()
98
- ```
99
-
100
- ### **What Happens During Setup**
101
- The VM Setup Tool will:
102
- 1. Configure Git with GitHub token if provided.
103
- 2. Clone the specified GitHub repository to your local machine.
104
- 3. Install **Docker** if it’s not already available on the target machine.
105
- 4. Install **Docker Compose** for managing multi-container applications.
106
- 5. Log in to Docker Hub if credentials are provided.
107
- 6. Create, enable, and start the Docker service.
108
- 7. Ensure the Docker container remains active, providing a robust environment for your applications.
109
-
110
- By automating these tasks, the tool minimizes errors and saves time, allowing you to focus on development and deployment.
111
-
112
- ---
113
-
114
- ## **Cloud Setup**
115
- The **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
116
-
117
- ```python
118
- from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
119
-
120
- config = SetupRunnerConfig(
121
- github_username='your_github_username', # Required if the repository is private, e.g., username
122
- github_token='your_github_token', # Required if the repository is private, e.g., token
123
- github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
124
- github_branch='your_branch_name', # Optional, defaults to 'main'
125
- docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
126
- dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
127
- dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
128
- )
129
-
130
- runner = SetupRunner(config)
131
-
132
- ssh_configs = [
133
- SSHConfig(
134
- ssh_username='your_ssh_username_1', # e.g., ssh_user_1
135
- ssh_password='your_ssh_password_1', # Optional, only use if you don’t want to use SSH key
136
- ssh_hostname='your_ssh_hostname_1', # e.g., ssh1.example.com
137
- ssh_identity_file='/path/to/your/ssh_key_1' # Optional, path to SSH Identity file
138
- ),
139
- SSHConfig(
140
- ssh_username='your_ssh_username_2', # e.g., ssh_user_2
141
- ssh_password='your_ssh_password_2', # Optional, only use if you don’t want to use SSH key
142
- ssh_hostname='your_ssh_hostname_2', # e.g., ssh2.example.com
143
- ssh_identity_file='/path/to/your/ssh_key_2' # Optional, path to SSH Identity file
144
- )
145
- # Add more SSHConfig instances as needed
146
- ]
147
-
148
- runner.run_cloud_setup(ssh_configs)
149
- ```
150
-
151
- ### **What Happens During Cloud Setup**
152
- When you run the cloud setup, the tool will:
153
- 1. Connect to the specified cloud VM using SSH.
154
- 2. Configure Git with GitHub token if provided.
155
- 3. Clone the specified GitHub repository to the VM.
156
- 4. Install **Docker** if it’s not already available on the VM.
157
- 5. Install **Docker Compose** for managing multi-container applications.
158
- 6. Log in to Docker Hub if credentials are provided.
159
- 7. Create, enable, and start the Docker service on the VM.
160
- 8. Ensure the Docker container remains active, providing a robust environment for your applications.
161
-
162
- ---
163
-
164
- ## **SSH Client Feature**
165
- 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.
166
-
167
- ### **Example Usage**
168
-
169
- ```python
170
- from vm_tool.ssh import SSHSetup
171
-
172
- ssh_setup = SSHSetup(
173
- hostname='your_vm_hostname', # e.g., vm.example.com
174
- username='your_vm_username', # e.g., user
175
- password='your_vm_password', # e.g., password
176
- email='your_email_for_ssh_key' # e.g., user@example.com
177
- )
178
-
179
- ssh_setup.setup()
180
- ```
181
-
182
- ### **What Happens During SSH Setup**
183
- When you run the SSH setup, the tool will:
184
- 1. Generate an SSH key pair if none exists.
185
- 2. Read the public SSH key or create a new one if necessary.
186
- 3. Configure the VM by adding the public key to the VM's **authorized_keys** file.
187
- 4. Update the local SSH configuration file with the VM's details.
188
- 5. Establish an SSH connection to verify the setup.
189
- 6. Close the connection once setup is complete.
190
-
191
- ---
192
-
193
- 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.
File without changes
File without changes
File without changes
File without changes
File without changes