vm-tool 1.0.29__tar.gz → 1.0.30__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 (38) hide show
  1. {vm_tool-1.0.29/vm_tool.egg-info → vm_tool-1.0.30}/PKG-INFO +1 -1
  2. vm_tool-1.0.30/examples/__init__.py +1 -0
  3. vm_tool-1.0.30/examples/cloud/__init__.py +1 -0
  4. vm_tool-1.0.30/examples/cloud/ssh_identity_file.py +24 -0
  5. vm_tool-1.0.30/examples/cloud/ssh_password.py +24 -0
  6. vm_tool-1.0.30/examples/cloud/template_cloud_setup.py +33 -0
  7. vm_tool-1.0.30/examples/local/__init__.py +1 -0
  8. vm_tool-1.0.30/examples/local/template_local_setup.py +24 -0
  9. vm_tool-1.0.30/examples/ssh_key_management.py +22 -0
  10. {vm_tool-1.0.29 → vm_tool-1.0.30}/setup.py +1 -1
  11. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/cli.py +1 -1
  12. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/runner.py +29 -4
  13. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/github/git_configuration.yml +0 -5
  14. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/main.yml +3 -0
  15. vm_tool-1.0.30/vm_tool/vm_setup/setup.yml +17 -0
  16. vm_tool-1.0.30/vm_tool/vm_setup/setup_project_env.yml +7 -0
  17. {vm_tool-1.0.29 → vm_tool-1.0.30/vm_tool.egg-info}/PKG-INFO +1 -1
  18. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool.egg-info/SOURCES.txt +9 -1
  19. vm_tool-1.0.30/vm_tool.egg-info/top_level.txt +2 -0
  20. vm_tool-1.0.29/vm_tool/vm_setup/dynamic_inventory.yml +0 -8
  21. vm_tool-1.0.29/vm_tool/vm_setup/setup.yml +0 -11
  22. vm_tool-1.0.29/vm_tool.egg-info/top_level.txt +0 -1
  23. {vm_tool-1.0.29 → vm_tool-1.0.30}/LICENSE +0 -0
  24. {vm_tool-1.0.29 → vm_tool-1.0.30}/MANIFEST.in +0 -0
  25. {vm_tool-1.0.29 → vm_tool-1.0.30}/README.md +0 -0
  26. {vm_tool-1.0.29 → vm_tool-1.0.30}/setup.cfg +0 -0
  27. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/__init__.py +0 -0
  28. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/ssh.py +0 -0
  29. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/cleanup.yml +0 -0
  30. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/create_docker_service.yml +0 -0
  31. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/docker_setup.yml +0 -0
  32. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
  33. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/login_to_docker_hub.yml +0 -0
  34. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/inventory.yml +0 -0
  35. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool/vm_setup/project_service.yml +0 -0
  36. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool.egg-info/dependency_links.txt +0 -0
  37. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool.egg-info/entry_points.txt +0 -0
  38. {vm_tool-1.0.29 → vm_tool-1.0.30}/vm_tool.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vm_tool
3
- Version: 1.0.29
3
+ Version: 1.0.30
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
@@ -0,0 +1 @@
1
+ # Example scripts package
@@ -0,0 +1 @@
1
+ # Cloud VM setup examples package
@@ -0,0 +1,24 @@
1
+ """
2
+ Example: Cloud VM setup using SSH key authentication (public GitHub repo).
3
+ - Connects to a remote VM using SSH key and runs setup from a public repo.
4
+ """
5
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
6
+
7
+ def main():
8
+ config = SetupRunnerConfig(
9
+ github_project_url='https://github.com/username/public-repo',
10
+ github_branch='main',
11
+ docker_compose_file_path='docker-compose.yml'
12
+ )
13
+ runner = SetupRunner(config)
14
+ ssh_configs = [
15
+ SSHConfig(
16
+ ssh_username='your_ssh_username',
17
+ ssh_hostname='your_ssh_hostname',
18
+ ssh_identity_file='/path/to/your/ssh_key'
19
+ )
20
+ ]
21
+ runner.run_cloud_setup(ssh_configs)
22
+
23
+ if __name__ == "__main__":
24
+ main()
@@ -0,0 +1,24 @@
1
+ """
2
+ Example: Cloud VM setup using SSH password authentication (public GitHub repo).
3
+ - Connects to a remote VM using SSH username/password and runs setup from a public repo.
4
+ """
5
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
6
+
7
+ def main():
8
+ config = SetupRunnerConfig(
9
+ github_project_url='https://github.com/username/public-repo',
10
+ github_branch='main',
11
+ docker_compose_file_path='docker-compose.yml'
12
+ )
13
+ runner = SetupRunner(config)
14
+ ssh_configs = [
15
+ SSHConfig(
16
+ ssh_username='your_ssh_username',
17
+ ssh_hostname='your_ssh_hostname',
18
+ ssh_password='your_ssh_password'
19
+ )
20
+ ]
21
+ runner.run_cloud_setup(ssh_configs)
22
+
23
+ if __name__ == "__main__":
24
+ main()
@@ -0,0 +1,33 @@
1
+ """
2
+ Template: Cloud VM setup (customize for your use case)
3
+ - Use this template to create your own cloud VM setup script.
4
+ - Supports public/private GitHub, DockerHub, SSH key or password authentication, and multiple VMs.
5
+ - Fill in only the fields you need for your scenario.
6
+ """
7
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
8
+
9
+ def main():
10
+ # Fill in only the fields you need for your use case
11
+ config = SetupRunnerConfig(
12
+ github_username=None, # e.g., 'your_github_username' (for private repos)
13
+ github_token=None, # e.g., 'your_github_token' (for private repos)
14
+ github_project_url='https://github.com/username/your-repo',
15
+ github_branch='main', # Optional, defaults to 'main'
16
+ docker_compose_file_path='docker-compose.yml', # Optional
17
+ dockerhub_username=None, # e.g., 'your_dockerhub_username' (if DockerHub login needed)
18
+ dockerhub_password=None # e.g., 'your_dockerhub_password' (if DockerHub login needed)
19
+ )
20
+ runner = SetupRunner(config)
21
+ ssh_configs = [
22
+ SSHConfig(
23
+ ssh_username='your_ssh_username',
24
+ ssh_hostname='your_ssh_hostname',
25
+ ssh_identity_file=None, # e.g., '/path/to/your/ssh_key' (for SSH key auth)
26
+ ssh_password=None # e.g., 'your_ssh_password' (for SSH password auth)
27
+ )
28
+ # Add more SSHConfig instances for multiple VMs if needed
29
+ ]
30
+ runner.run_cloud_setup(ssh_configs)
31
+
32
+ if __name__ == "__main__":
33
+ main()
@@ -0,0 +1 @@
1
+ # Local VM setup examples package
@@ -0,0 +1,24 @@
1
+ """
2
+ Template: Local VM setup (customize for your use case)
3
+ - Use this template to create your own local VM setup script.
4
+ - Supports public/private GitHub, DockerHub, and custom Docker Compose file path.
5
+ - Fill in only the fields you need for your scenario.
6
+ """
7
+ from vm_tool.runner import SetupRunner, SetupRunnerConfig
8
+
9
+ def main():
10
+ # Fill in only the fields you need for your use case
11
+ config = SetupRunnerConfig(
12
+ github_username=None, # e.g., 'your_github_username' (for private repos)
13
+ github_token=None, # e.g., 'your_github_token' (for private repos)
14
+ github_project_url='https://github.com/username/your-repo',
15
+ github_branch='main', # Optional, defaults to 'main'
16
+ docker_compose_file_path='docker-compose.yml', # Optional
17
+ dockerhub_username=None, # e.g., 'your_dockerhub_username' (if DockerHub login needed)
18
+ dockerhub_password=None # e.g., 'your_dockerhub_password' (if DockerHub login needed)
19
+ )
20
+ runner = SetupRunner(config)
21
+ runner.run_setup()
22
+
23
+ if __name__ == "__main__":
24
+ main()
@@ -0,0 +1,22 @@
1
+ """
2
+ Example: SSH Key Management for a VM.
3
+ - Generates an SSH key pair (if not present), configures the VM for SSH access, and updates local SSH config.
4
+ - Useful for preparing a VM for secure, passwordless SSH access.
5
+ """
6
+
7
+ from vm_tool.ssh import SSHSetup
8
+
9
+
10
+ def main():
11
+ ssh_setup = SSHSetup(
12
+ hostname='your_vm_hostname',
13
+ username='your_vm_username',
14
+ password='your_vm_password',
15
+ email='your_email_for_ssh_key'
16
+ )
17
+
18
+ ssh_setup.setup()
19
+
20
+
21
+ if __name__ == "__main__":
22
+ main()
@@ -11,7 +11,7 @@ else:
11
11
 
12
12
  setup(
13
13
  name='vm_tool',
14
- version='1.0.29', # This will be updated by bump2version
14
+ version='1.0.30', # 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,
@@ -2,7 +2,7 @@ import argparse
2
2
 
3
3
  def main():
4
4
  parser = argparse.ArgumentParser(description='VM Tool version info')
5
- parser.add_argument('--version', action='version', version='1.0.29')
5
+ parser.add_argument('--version', action='version', version='1.0.30')
6
6
  parser.parse_args()
7
7
 
8
8
  if __name__ == '__main__':
@@ -17,6 +17,8 @@ class SetupRunnerConfig(BaseModel):
17
17
  docker_compose_file_path (str): Path to the Docker Compose file (default: 'docker-compose.yml').
18
18
  dockerhub_username (Optional[str]): DockerHub username (optional).
19
19
  dockerhub_password (Optional[str]): DockerHub password (required if username is provided).
20
+ env_path (Optional[str]): Path where the environment file should be created (optional).
21
+ env_data (Optional[dict]): Environment data to dump into the file (optional, should be a dict).
20
22
  """
21
23
 
22
24
  github_username: Optional[str] = Field(
@@ -36,11 +38,26 @@ class SetupRunnerConfig(BaseModel):
36
38
  dockerhub_password: Optional[str] = Field(
37
39
  default=None, description="DockerHub password (required if username is provided)"
38
40
  )
41
+ env_path: Optional[str] = Field(
42
+ default=None, description="Path where the environment file should be created (optional)"
43
+ )
44
+ env_data: Optional[dict] = Field(
45
+ default=None, description="Environment data to dump into the file (optional, should be a dict)"
46
+ )
39
47
 
40
- @validator('docker_compose_file_path', pre=True, always=True)
41
- def set_default_docker_compose_file_path(cls, v):
42
- """Ensures a default value for the Docker Compose file path."""
43
- return v or 'docker-compose.yml'
48
+ @validator('env_path', always=True)
49
+ def check_env_path_with_env_data(cls, v, values):
50
+ """If env_data is provided, env_path must also be provided."""
51
+ if values.get('env_data') is not None and not v:
52
+ raise ValueError("env_path must be provided if env_data is specified")
53
+ return v
54
+
55
+ @validator('env_data', always=True)
56
+ def check_env_data_with_env_path(cls, v, values):
57
+ """If env_path is provided, env_data must also be provided."""
58
+ if values.get('env_path') is not None and v is None:
59
+ raise ValueError("env_data must be provided if env_path is specified")
60
+ return v
44
61
 
45
62
  @validator('dockerhub_password', always=True)
46
63
  def check_dockerhub_password(cls, v, values):
@@ -122,6 +139,8 @@ class SetupRunner:
122
139
  self.docker_compose_file_path = config.docker_compose_file_path
123
140
  self.dockerhub_username = config.dockerhub_username
124
141
  self.dockerhub_password = config.dockerhub_password
142
+ self.env_path = config.env_path
143
+ self.env_data = config.env_data
125
144
 
126
145
  def _run_ansible_playbook(self, extravars, inventory_file):
127
146
  """Executes an Ansible playbook with the given variables and inventory."""
@@ -160,6 +179,9 @@ class SetupRunner:
160
179
 
161
180
  if self.docker_compose_file_path:
162
181
  extravars["DOCKER_COMPOSE_FILE_PATH"] = self.docker_compose_file_path
182
+ if self.env_path and self.env_data:
183
+ extravars["ENV_PATH"] = self.env_path
184
+ extravars["ENV_DATA"] = self.env_data
163
185
 
164
186
  self._run_ansible_playbook(extravars, 'inventory.yml')
165
187
 
@@ -204,5 +226,8 @@ class SetupRunner:
204
226
 
205
227
  if self.docker_compose_file_path:
206
228
  extravars["DOCKER_COMPOSE_FILE_PATH"] = self.docker_compose_file_path
229
+ if self.env_path and self.env_data:
230
+ extravars["ENV_PATH"] = self.env_path
231
+ extravars["ENV_DATA"] = self.env_data
207
232
 
208
233
  self._run_ansible_playbook(extravars, 'dynamic_inventory.yml')
@@ -6,11 +6,6 @@
6
6
  state: present
7
7
  become: yes
8
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
9
  # --- Git Credential Setup ---
15
10
  - name: Check if Git credentials file exists
16
11
  stat:
@@ -9,6 +9,9 @@
9
9
  - name: Git Configuration
10
10
  include_tasks: github/git_configuration.yml
11
11
 
12
+ - name: Setup Project Environment File
13
+ include_tasks: setup_project_env.yml
14
+
12
15
  - name: Docker Setup
13
16
  include_tasks: docker/docker_setup.yml
14
17
 
@@ -0,0 +1,17 @@
1
+ - name: Setup VM
2
+ block:
3
+ # --- Extract Project Name from GITHUB_PROJECT_URL ---
4
+ - name: Extract project name from GITHUB_PROJECT_URL
5
+ set_fact:
6
+ project_name: "{{ GITHUB_PROJECT_URL | basename | regex_replace('\\.git$', '') }}"
7
+
8
+ # --- Set project_dest_dir based on EXECUTION_TYPE ---
9
+ - name: Set project_dest_dir variable for cloud
10
+ set_fact:
11
+ project_dest_dir: "{{ ansible_user_dir }}/{{ project_name }}"
12
+ when: EXECUTION_TYPE == "cloud"
13
+
14
+ - name: Set project_dest_dir variable for normal
15
+ set_fact:
16
+ project_dest_dir: "{{ playbook_dir }}/{{ project_name }}"
17
+ when: EXECUTION_TYPE == "normal"
@@ -0,0 +1,7 @@
1
+ ---
2
+ - name: Create environment file if env_path and env_data are provided
3
+ when: ENV_PATH is defined and ENV_DATA is defined and PROJECT_PATH is defined
4
+ copy:
5
+ dest: "{{ project_dest_dir }}/{{ ENV_PATH }}"
6
+ content: "{{ ENV_DATA | to_nice_yaml }}"
7
+ mode: '0644'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vm_tool
3
- Version: 1.0.29
3
+ Version: 1.0.30
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
@@ -2,6 +2,14 @@ LICENSE
2
2
  MANIFEST.in
3
3
  README.md
4
4
  setup.py
5
+ examples/__init__.py
6
+ examples/ssh_key_management.py
7
+ examples/cloud/__init__.py
8
+ examples/cloud/ssh_identity_file.py
9
+ examples/cloud/ssh_password.py
10
+ examples/cloud/template_cloud_setup.py
11
+ examples/local/__init__.py
12
+ examples/local/template_local_setup.py
5
13
  vm_tool/__init__.py
6
14
  vm_tool/cli.py
7
15
  vm_tool/runner.py
@@ -13,11 +21,11 @@ vm_tool.egg-info/entry_points.txt
13
21
  vm_tool.egg-info/requires.txt
14
22
  vm_tool.egg-info/top_level.txt
15
23
  vm_tool/vm_setup/cleanup.yml
16
- vm_tool/vm_setup/dynamic_inventory.yml
17
24
  vm_tool/vm_setup/inventory.yml
18
25
  vm_tool/vm_setup/main.yml
19
26
  vm_tool/vm_setup/project_service.yml
20
27
  vm_tool/vm_setup/setup.yml
28
+ vm_tool/vm_setup/setup_project_env.yml
21
29
  vm_tool/vm_setup/docker/create_docker_service.yml
22
30
  vm_tool/vm_setup/docker/docker_setup.yml
23
31
  vm_tool/vm_setup/docker/install_docker_and_compose.yml
@@ -0,0 +1,2 @@
1
+ examples
2
+ vm_tool
@@ -1,8 +0,0 @@
1
- all:
2
- hosts:
3
- cloud_host_0:
4
- ansible_host: 172.105.49.244
5
- ansible_ssh_pass: Sunny@27072000@
6
- ansible_user: root
7
- vars:
8
- ansible_python_interpreter: /usr/bin/python3
@@ -1,11 +0,0 @@
1
- - name: Setup VM
2
- block:
3
- - name: Set project_dest_dir variable for cloud
4
- set_fact:
5
- project_dest_dir: "{{ ansible_user_dir }}/project"
6
- when: EXECUTION_TYPE == "cloud"
7
-
8
- - name: Set project_dest_dir variable for normal
9
- set_fact:
10
- project_dest_dir: "{{ playbook_dir }}/project"
11
- when: EXECUTION_TYPE == "normal"
@@ -1 +0,0 @@
1
- vm_tool
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes