cluster-builder 0.5.2__tar.gz → 0.6.0__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.
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/PKG-INFO +12 -14
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/README.md +11 -13
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/config/__init__.py +2 -2
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/config/cluster.py +80 -7
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/infrastructure/executor.py +7 -4
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/infrastructure/templates.py +2 -33
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/swarmchestrate.py +233 -39
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/aws/main.tf +31 -11
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/deploy_manifest.tf +12 -2
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/edge/main.tf +32 -11
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/k3s_provider.tf +1 -1
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/openstack/main.tf +139 -41
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/registry_secret.tf +12 -2
- cluster_builder-0.6.0/cluster_builder/templates/remove_manifest.tf +43 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/utils/hcl.py +36 -15
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/utils/logging.py +1 -4
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder.egg-info/PKG-INFO +12 -14
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder.egg-info/SOURCES.txt +1 -3
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/pyproject.toml +1 -1
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/tests/test_hcl.py +5 -3
- cluster_builder-0.5.2/cluster_builder/templates/ha_user_data.sh.tpl +0 -33
- cluster_builder-0.5.2/cluster_builder/templates/master_user_data.sh.tpl +0 -37
- cluster_builder-0.5.2/cluster_builder/templates/worker_user_data.sh.tpl +0 -34
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/LICENSE +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/__init__.py +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/config/postgres.py +1 -1
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/infrastructure/__init__.py +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/aws_provider.tf +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/edge_provider.tf +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/templates/openstack_provider.tf +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder/utils/__init__.py +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder.egg-info/dependency_links.txt +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder.egg-info/requires.txt +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/cluster_builder.egg-info/top_level.txt +0 -0
- {cluster_builder-0.5.2 → cluster_builder-0.6.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cluster-builder
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Swarmchestrate cluster builder
|
|
5
5
|
Author-email: Gunjan <G.Kotak@westminster.ac.uk>, Jay <J.Deslauriers@westminster.ac.uk>
|
|
6
6
|
License: Apache2
|
|
@@ -107,8 +107,7 @@ from cluster_builder import Swarmchestrate
|
|
|
107
107
|
|
|
108
108
|
# Initialise the orchestrator
|
|
109
109
|
orchestrator = Swarmchestrate(
|
|
110
|
-
template_dir="/path/to/templates",
|
|
111
|
-
output_dir="/path/to/output"
|
|
110
|
+
template_dir="/path/to/templates", output_dir="/path/to/output"
|
|
112
111
|
)
|
|
113
112
|
```
|
|
114
113
|
|
|
@@ -122,7 +121,7 @@ You may define it directly as a Python dictionary or load it from a separate fil
|
|
|
122
121
|
#### 2. Load the configuration in Python:
|
|
123
122
|
|
|
124
123
|
```python
|
|
125
|
-
config ={
|
|
124
|
+
config = {
|
|
126
125
|
# your config fields here
|
|
127
126
|
}
|
|
128
127
|
|
|
@@ -144,8 +143,8 @@ To remove a specific node from a cluster:
|
|
|
144
143
|
```python
|
|
145
144
|
# Remove a node by its resource name
|
|
146
145
|
orchestrator.remove_node(
|
|
147
|
-
cluster_name="
|
|
148
|
-
resource_name="
|
|
146
|
+
cluster_name="your_cluster_name",
|
|
147
|
+
resource_name="eloquent-feynman", # The resource identifier of the node
|
|
149
148
|
)
|
|
150
149
|
```
|
|
151
150
|
|
|
@@ -159,9 +158,7 @@ To completely destroy a cluster and all its nodes:
|
|
|
159
158
|
|
|
160
159
|
```python
|
|
161
160
|
# Destroy the entire cluster
|
|
162
|
-
orchestrator.destroy(
|
|
163
|
-
cluster_name="your-cluster-name"
|
|
164
|
-
)
|
|
161
|
+
orchestrator.destroy(cluster_name="your_cluster_name")
|
|
165
162
|
```
|
|
166
163
|
|
|
167
164
|
The **destroy** method:
|
|
@@ -179,8 +176,10 @@ The deploy_manifests method copies Kubernetes manifests to the target cluster no
|
|
|
179
176
|
orchestrator.deploy_manifests(
|
|
180
177
|
manifest_folder="path/to/manifests",
|
|
181
178
|
master_ip="MASTER_NODE_IP",
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
ssh_user="USERNAME",
|
|
180
|
+
ssh_key="path/to/key.pem", # for key auth
|
|
181
|
+
ssh_auth_method="key", # or "password"
|
|
182
|
+
ssh_password="", # required when ssh_auth_method="password"
|
|
184
183
|
)
|
|
185
184
|
```
|
|
186
185
|
---
|
|
@@ -240,7 +239,7 @@ By default, cluster names are generated automatically. To specify a custom name:
|
|
|
240
239
|
|
|
241
240
|
```python
|
|
242
241
|
config = {
|
|
243
|
-
"cluster_name": "
|
|
242
|
+
"cluster_name": "production_cluster",
|
|
244
243
|
# ... other configuration ...
|
|
245
244
|
}
|
|
246
245
|
```
|
|
@@ -250,8 +249,7 @@ config = {
|
|
|
250
249
|
|
|
251
250
|
Templates should be organised as follows:
|
|
252
251
|
- `templates/` - Base directory for templates
|
|
253
|
-
- `templates/{cloud}/` -
|
|
254
|
-
- `templates/{role}_user_data.sh.tpl` - Node initialisation scripts
|
|
252
|
+
- `templates/{cloud}/` - Opentofu modules for each cloud provider
|
|
255
253
|
- `templates/{cloud}_provider.tf` - Provider configuration templates
|
|
256
254
|
|
|
257
255
|
---
|
|
@@ -90,8 +90,7 @@ from cluster_builder import Swarmchestrate
|
|
|
90
90
|
|
|
91
91
|
# Initialise the orchestrator
|
|
92
92
|
orchestrator = Swarmchestrate(
|
|
93
|
-
template_dir="/path/to/templates",
|
|
94
|
-
output_dir="/path/to/output"
|
|
93
|
+
template_dir="/path/to/templates", output_dir="/path/to/output"
|
|
95
94
|
)
|
|
96
95
|
```
|
|
97
96
|
|
|
@@ -105,7 +104,7 @@ You may define it directly as a Python dictionary or load it from a separate fil
|
|
|
105
104
|
#### 2. Load the configuration in Python:
|
|
106
105
|
|
|
107
106
|
```python
|
|
108
|
-
config ={
|
|
107
|
+
config = {
|
|
109
108
|
# your config fields here
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -127,8 +126,8 @@ To remove a specific node from a cluster:
|
|
|
127
126
|
```python
|
|
128
127
|
# Remove a node by its resource name
|
|
129
128
|
orchestrator.remove_node(
|
|
130
|
-
cluster_name="
|
|
131
|
-
resource_name="
|
|
129
|
+
cluster_name="your_cluster_name",
|
|
130
|
+
resource_name="eloquent-feynman", # The resource identifier of the node
|
|
132
131
|
)
|
|
133
132
|
```
|
|
134
133
|
|
|
@@ -142,9 +141,7 @@ To completely destroy a cluster and all its nodes:
|
|
|
142
141
|
|
|
143
142
|
```python
|
|
144
143
|
# Destroy the entire cluster
|
|
145
|
-
orchestrator.destroy(
|
|
146
|
-
cluster_name="your-cluster-name"
|
|
147
|
-
)
|
|
144
|
+
orchestrator.destroy(cluster_name="your_cluster_name")
|
|
148
145
|
```
|
|
149
146
|
|
|
150
147
|
The **destroy** method:
|
|
@@ -162,8 +159,10 @@ The deploy_manifests method copies Kubernetes manifests to the target cluster no
|
|
|
162
159
|
orchestrator.deploy_manifests(
|
|
163
160
|
manifest_folder="path/to/manifests",
|
|
164
161
|
master_ip="MASTER_NODE_IP",
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
ssh_user="USERNAME",
|
|
163
|
+
ssh_key="path/to/key.pem", # for key auth
|
|
164
|
+
ssh_auth_method="key", # or "password"
|
|
165
|
+
ssh_password="", # required when ssh_auth_method="password"
|
|
167
166
|
)
|
|
168
167
|
```
|
|
169
168
|
---
|
|
@@ -223,7 +222,7 @@ By default, cluster names are generated automatically. To specify a custom name:
|
|
|
223
222
|
|
|
224
223
|
```python
|
|
225
224
|
config = {
|
|
226
|
-
"cluster_name": "
|
|
225
|
+
"cluster_name": "production_cluster",
|
|
227
226
|
# ... other configuration ...
|
|
228
227
|
}
|
|
229
228
|
```
|
|
@@ -233,8 +232,7 @@ config = {
|
|
|
233
232
|
|
|
234
233
|
Templates should be organised as follows:
|
|
235
234
|
- `templates/` - Base directory for templates
|
|
236
|
-
- `templates/{cloud}/` -
|
|
237
|
-
- `templates/{role}_user_data.sh.tpl` - Node initialisation scripts
|
|
235
|
+
- `templates/{cloud}/` - Opentofu modules for each cloud provider
|
|
238
236
|
- `templates/{cloud}_provider.tf` - Provider configuration templates
|
|
239
237
|
|
|
240
238
|
---
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Configuration management for the Cluster Builder.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from cluster_builder.config.postgres import PostgresConfig
|
|
6
5
|
from cluster_builder.config.cluster import ClusterConfig
|
|
6
|
+
from cluster_builder.config.postgres import PostgresConfig
|
|
7
7
|
|
|
8
|
-
__all__ = ["
|
|
8
|
+
__all__ = ["ClusterConfig", "PostgresConfig"]
|
|
@@ -2,17 +2,27 @@
|
|
|
2
2
|
Cluster configuration management.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import os
|
|
6
5
|
import logging
|
|
6
|
+
import os
|
|
7
|
+
import re
|
|
7
8
|
import secrets
|
|
8
9
|
import string
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
9
12
|
from names_generator import generate_name
|
|
10
13
|
|
|
11
|
-
from typing import Any
|
|
12
14
|
from cluster_builder.infrastructure import TemplateManager
|
|
13
15
|
|
|
14
16
|
logger = logging.getLogger("swarmchestrate")
|
|
15
17
|
|
|
18
|
+
# RFC 1123 label: lowercase alphanumerics or '-', starting/ending with an alphanumeric, max 63 chars
|
|
19
|
+
RFC_1123_LABEL_RE = re.compile(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
|
|
20
|
+
RFC_1123_MAX_LENGTH = 63
|
|
21
|
+
|
|
22
|
+
# Unquoted PostgreSQL identifier: starts with a letter or underscore, followed
|
|
23
|
+
# by letters, digits, or underscores, max 63 characters. No hyphens allowed.
|
|
24
|
+
PG_IDENTIFIER_RE = re.compile(r"^[a-z_][a-z0-9_]{0,62}$")
|
|
25
|
+
|
|
16
26
|
|
|
17
27
|
class ClusterConfig:
|
|
18
28
|
"""Manages cluster configuration and preparation."""
|
|
@@ -32,6 +42,55 @@ class ClusterConfig:
|
|
|
32
42
|
self.template_manager = template_manager
|
|
33
43
|
self.output_dir = output_dir
|
|
34
44
|
|
|
45
|
+
@staticmethod
|
|
46
|
+
def validate_rfc1123_name(name: str, field_name: str) -> None:
|
|
47
|
+
"""
|
|
48
|
+
Validate that a name is RFC 1123 compliant (used for k8s resource names).
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
name: The name to validate
|
|
52
|
+
field_name: Name of the field, used in the error message
|
|
53
|
+
|
|
54
|
+
Raises:
|
|
55
|
+
ValueError: If the name is not RFC 1123 compliant
|
|
56
|
+
"""
|
|
57
|
+
if (
|
|
58
|
+
not name
|
|
59
|
+
or len(name) > RFC_1123_MAX_LENGTH
|
|
60
|
+
or not RFC_1123_LABEL_RE.match(name)
|
|
61
|
+
):
|
|
62
|
+
error_msg = (
|
|
63
|
+
f"Invalid {field_name} '{name}': must be RFC 1123 compliant "
|
|
64
|
+
f"(lowercase alphanumeric characters or '-', start/end with an "
|
|
65
|
+
f"alphanumeric character, max {RFC_1123_MAX_LENGTH} characters). "
|
|
66
|
+
"Underscores are not permitted."
|
|
67
|
+
)
|
|
68
|
+
logger.error(error_msg)
|
|
69
|
+
raise ValueError(error_msg)
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def validate_pg_identifier_name(name: str, field_name: str) -> None:
|
|
73
|
+
"""
|
|
74
|
+
Validate that a name is a valid, unquoted PostgreSQL identifier (used
|
|
75
|
+
for cluster_name, which doubles as the Terraform state schema name).
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
name: The name to validate
|
|
79
|
+
field_name: Name of the field, used in the error message
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
ValueError: If the name is not a valid PostgreSQL identifier
|
|
83
|
+
"""
|
|
84
|
+
if not name or not PG_IDENTIFIER_RE.match(name):
|
|
85
|
+
error_msg = (
|
|
86
|
+
f"Invalid {field_name} '{name}': must start with a lowercase "
|
|
87
|
+
"letter or underscore and contain only lowercase letters, "
|
|
88
|
+
"digits, and underscores (max 63 characters). Hyphens are not "
|
|
89
|
+
"permitted."
|
|
90
|
+
)
|
|
91
|
+
logger.error(error_msg)
|
|
92
|
+
raise ValueError(error_msg)
|
|
93
|
+
|
|
35
94
|
def get_cluster_output_dir(self, cluster_name: str) -> str:
|
|
36
95
|
"""
|
|
37
96
|
Get the output directory path for a specific cluster.
|
|
@@ -46,7 +105,8 @@ class ClusterConfig:
|
|
|
46
105
|
|
|
47
106
|
def generate_random_name(self) -> str:
|
|
48
107
|
"""
|
|
49
|
-
Generate a readable random string
|
|
108
|
+
Generate a readable, RFC 1123 compliant random string (hyphen-separated)
|
|
109
|
+
using names-generator. Used for resource_name.
|
|
50
110
|
|
|
51
111
|
Returns:
|
|
52
112
|
A randomly generated name
|
|
@@ -56,6 +116,18 @@ class ClusterConfig:
|
|
|
56
116
|
logger.debug(f"Generated random name: {name}")
|
|
57
117
|
return name
|
|
58
118
|
|
|
119
|
+
def generate_cluster_name(self) -> str:
|
|
120
|
+
"""
|
|
121
|
+
Generate a readable, PostgreSQL-safe random string (underscore-separated)
|
|
122
|
+
using names-generator. Used for cluster_name.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
A randomly generated cluster name
|
|
126
|
+
"""
|
|
127
|
+
name = generate_name()
|
|
128
|
+
logger.debug(f"Generated cluster name: {name}")
|
|
129
|
+
return name
|
|
130
|
+
|
|
59
131
|
def generate_k3s_token(self, length: int = 16) -> str:
|
|
60
132
|
"""
|
|
61
133
|
Generate a secure random alphanumeric token for K3s.
|
|
@@ -120,13 +192,16 @@ class ClusterConfig:
|
|
|
120
192
|
|
|
121
193
|
# Generate a cluster name if not provided
|
|
122
194
|
if "cluster_name" not in prepared_config:
|
|
123
|
-
cluster_name = self.
|
|
195
|
+
cluster_name = self.generate_cluster_name()
|
|
124
196
|
prepared_config["cluster_name"] = cluster_name
|
|
125
197
|
logger.debug(f"Creating new cluster: {cluster_name}")
|
|
126
198
|
else:
|
|
127
199
|
logger.debug(
|
|
128
200
|
f"Adding node to existing cluster: {prepared_config['cluster_name']}"
|
|
129
201
|
)
|
|
202
|
+
self.validate_pg_identifier_name(
|
|
203
|
+
prepared_config["cluster_name"], "cluster_name"
|
|
204
|
+
)
|
|
130
205
|
|
|
131
206
|
cluster_dir = self.get_cluster_output_dir(prepared_config["cluster_name"])
|
|
132
207
|
logger.debug(f"Cluster directory: {cluster_dir}")
|
|
@@ -140,6 +215,7 @@ class ClusterConfig:
|
|
|
140
215
|
logger.debug(
|
|
141
216
|
f" Using provided Resource name: {prepared_config['resource_name']}"
|
|
142
217
|
)
|
|
218
|
+
self.validate_rfc1123_name(prepared_config["resource_name"], "resource_name")
|
|
143
219
|
|
|
144
220
|
# Create the cluster directory
|
|
145
221
|
try:
|
|
@@ -150,7 +226,4 @@ class ClusterConfig:
|
|
|
150
226
|
logger.error(error_msg)
|
|
151
227
|
raise RuntimeError(error_msg)
|
|
152
228
|
|
|
153
|
-
# Copy user data template
|
|
154
|
-
self.template_manager.copy_user_data_template(role, cloud)
|
|
155
|
-
|
|
156
229
|
return cluster_dir, prepared_config
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Command execution utilities for infrastructure management.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import subprocess
|
|
6
5
|
import logging
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
7
8
|
|
|
8
9
|
from yaspin import yaspin
|
|
9
10
|
from yaspin.spinners import Spinners
|
|
@@ -19,8 +20,8 @@ class CommandExecutor:
|
|
|
19
20
|
command: list,
|
|
20
21
|
cwd: str,
|
|
21
22
|
description: str = "command",
|
|
22
|
-
timeout: int = None,
|
|
23
|
-
env: dict = None, # <-- Add optional env param
|
|
23
|
+
timeout: int | None = None,
|
|
24
|
+
env: dict | None = None, # <-- Add optional env param
|
|
24
25
|
) -> str:
|
|
25
26
|
"""
|
|
26
27
|
Execute a shell command with proper logging and error handling.
|
|
@@ -62,8 +63,10 @@ class CommandExecutor:
|
|
|
62
63
|
pass # Still running → spinner starts
|
|
63
64
|
|
|
64
65
|
# Either timeout <= 5s, or process still running after 5s
|
|
66
|
+
# color is only supported on a real terminal (avoids yaspin UserWarning in Jupyter)
|
|
67
|
+
spinner_kwargs = {"color": "cyan"} if sys.stdout.isatty() else {}
|
|
65
68
|
spinner = (
|
|
66
|
-
yaspin(Spinners.point, text=f"Running {description}...",
|
|
69
|
+
yaspin(Spinners.point, text=f"Running {description}...", **spinner_kwargs)
|
|
67
70
|
if show_spinner
|
|
68
71
|
else None
|
|
69
72
|
)
|
|
@@ -3,9 +3,9 @@ Template management for cluster deployments.
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import filecmp
|
|
6
|
+
import logging
|
|
6
7
|
import os
|
|
7
8
|
import shutil
|
|
8
|
-
import logging
|
|
9
9
|
|
|
10
10
|
from cluster_builder.utils.hcl import extract_template_variables
|
|
11
11
|
|
|
@@ -90,7 +90,7 @@ class TemplateManager:
|
|
|
90
90
|
try:
|
|
91
91
|
shutil.copy2(src_path, dst_path)
|
|
92
92
|
logger.debug(f"Copied provider template {template_file} to {dst_path}")
|
|
93
|
-
except Exception as e:
|
|
93
|
+
except Exception as e: # noqa: BLE001 - wrap any copy failure into a RuntimeError
|
|
94
94
|
error_msg = f"Failed to copy provider template {template_file}: {e}"
|
|
95
95
|
logger.error(error_msg)
|
|
96
96
|
raise RuntimeError(error_msg)
|
|
@@ -99,37 +99,6 @@ class TemplateManager:
|
|
|
99
99
|
f"✅ Provider configurations ensured in cluster directory {cluster_dir}"
|
|
100
100
|
)
|
|
101
101
|
|
|
102
|
-
def copy_user_data_template(self, role: str, cloud: str) -> None:
|
|
103
|
-
"""
|
|
104
|
-
Copy the user data template for a specific role to the cloud provider directory.
|
|
105
|
-
|
|
106
|
-
Args:
|
|
107
|
-
role: K3s role (master, worker, etc.)
|
|
108
|
-
cloud: Cloud provider name
|
|
109
|
-
|
|
110
|
-
Raises:
|
|
111
|
-
RuntimeError: If the template file doesn't exist or can't be copied
|
|
112
|
-
"""
|
|
113
|
-
user_data_src = os.path.join(self.templates_dir, f"{role}_user_data.sh.tpl")
|
|
114
|
-
user_data_dst = os.path.join(
|
|
115
|
-
self.templates_dir, cloud, f"{role}_user_data.sh.tpl"
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
if not os.path.exists(user_data_src):
|
|
119
|
-
error_msg = f"User data template not found: {user_data_src}"
|
|
120
|
-
logger.error(error_msg)
|
|
121
|
-
raise RuntimeError(error_msg)
|
|
122
|
-
|
|
123
|
-
try:
|
|
124
|
-
shutil.copy2(user_data_src, user_data_dst)
|
|
125
|
-
logger.debug(
|
|
126
|
-
f"Copied user data template from {user_data_src} to {user_data_dst}"
|
|
127
|
-
)
|
|
128
|
-
except (OSError, shutil.Error) as e:
|
|
129
|
-
error_msg = f"Failed to copy user data template: {e}"
|
|
130
|
-
logger.error(error_msg)
|
|
131
|
-
raise RuntimeError(error_msg)
|
|
132
|
-
|
|
133
102
|
def get_required_variables(self, cloud: str) -> dict:
|
|
134
103
|
"""
|
|
135
104
|
Get the variables required for a specific cloud provider's templates.
|