vm-tool 1.0.28__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 (41) hide show
  1. vm_tool-1.0.30/PKG-INFO +169 -0
  2. vm_tool-1.0.30/README.md +119 -0
  3. vm_tool-1.0.30/examples/__init__.py +1 -0
  4. vm_tool-1.0.30/examples/cloud/__init__.py +1 -0
  5. vm_tool-1.0.30/examples/cloud/ssh_identity_file.py +24 -0
  6. vm_tool-1.0.30/examples/cloud/ssh_password.py +24 -0
  7. vm_tool-1.0.30/examples/cloud/template_cloud_setup.py +33 -0
  8. vm_tool-1.0.30/examples/local/__init__.py +1 -0
  9. vm_tool-1.0.30/examples/local/template_local_setup.py +24 -0
  10. vm_tool-1.0.30/examples/ssh_key_management.py +22 -0
  11. {vm_tool-1.0.28 → vm_tool-1.0.30}/setup.py +1 -1
  12. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/cli.py +1 -1
  13. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/runner.py +29 -4
  14. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/github/git_configuration.yml +0 -5
  15. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/main.yml +3 -0
  16. vm_tool-1.0.30/vm_tool/vm_setup/setup.yml +17 -0
  17. vm_tool-1.0.30/vm_tool/vm_setup/setup_project_env.yml +7 -0
  18. vm_tool-1.0.30/vm_tool.egg-info/PKG-INFO +169 -0
  19. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool.egg-info/SOURCES.txt +9 -1
  20. vm_tool-1.0.30/vm_tool.egg-info/top_level.txt +2 -0
  21. vm_tool-1.0.28/PKG-INFO +0 -234
  22. vm_tool-1.0.28/README.md +0 -184
  23. vm_tool-1.0.28/vm_tool/vm_setup/dynamic_inventory.yml +0 -8
  24. vm_tool-1.0.28/vm_tool/vm_setup/setup.yml +0 -11
  25. vm_tool-1.0.28/vm_tool.egg-info/PKG-INFO +0 -234
  26. vm_tool-1.0.28/vm_tool.egg-info/top_level.txt +0 -1
  27. {vm_tool-1.0.28 → vm_tool-1.0.30}/LICENSE +0 -0
  28. {vm_tool-1.0.28 → vm_tool-1.0.30}/MANIFEST.in +0 -0
  29. {vm_tool-1.0.28 → vm_tool-1.0.30}/setup.cfg +0 -0
  30. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/__init__.py +0 -0
  31. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/ssh.py +0 -0
  32. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/cleanup.yml +0 -0
  33. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/create_docker_service.yml +0 -0
  34. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/docker_setup.yml +0 -0
  35. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
  36. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/docker/login_to_docker_hub.yml +0 -0
  37. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/inventory.yml +0 -0
  38. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool/vm_setup/project_service.yml +0 -0
  39. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool.egg-info/dependency_links.txt +0 -0
  40. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool.egg-info/entry_points.txt +0 -0
  41. {vm_tool-1.0.28 → vm_tool-1.0.30}/vm_tool.egg-info/requires.txt +0 -0
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: vm_tool
3
+ Version: 1.0.30
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!
@@ -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.28', # 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.28')
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'