refactor: convert puppetserver compilers to deployment with configmap integration (#57)
- Convert StatefulSet to Deployment for better scaling flexibility - Add initContainer to copy configmaps to shared RWX volume (10GB) - Integrate puppetserver-compiler-config configmap for environment variables - Configure configMapGenerator with stable names (disableNameSuffixHash) - Update HPA to target Deployment instead of StatefulSet - Simplify puppetboard SSL config to skip verification for internal connections Reviewed-on: #57
This commit was merged in pull request #57.
This commit is contained in:
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env -S uv run --quiet --script
|
||||
# /// script
|
||||
# requires-python = ">=3.11"
|
||||
# dependencies = ['pyyaml','requests']
|
||||
# ///
|
||||
"""
|
||||
External Node Classifier (ENC) for Puppet.
|
||||
|
||||
If the environment specified in the YAML file is 'testing',
|
||||
the environment is not included in the output.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import yaml
|
||||
import requests
|
||||
|
||||
def fetch_enc_data(cobbler_url: str, hostname: str) -> str:
|
||||
"""
|
||||
Fetches and modifies ENC data from a given URL to ensure classes are in list format.
|
||||
"""
|
||||
url = f"{cobbler_url}/cblr/svc/op/puppet/hostname/{hostname}"
|
||||
try:
|
||||
response = requests.get(url, verify='/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem')
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
sys.exit(f"Request failed: {e}")
|
||||
|
||||
data = yaml.safe_load(response.text)
|
||||
data["parameters"] = data.get("parameters", {})
|
||||
|
||||
# Ensure 'classes' is in the desired list format
|
||||
if "classes" in data:
|
||||
if isinstance(data["classes"], dict):
|
||||
data["parameters"]["enc_role"] = list(data["classes"].keys())
|
||||
data["classes"] = list(data["classes"].keys())
|
||||
else:
|
||||
data["parameters"]["enc_role"] = list(data["classes"])
|
||||
data["classes"] = list(data["classes"])
|
||||
|
||||
if "environment" in data:
|
||||
data["parameters"]["enc_env"] = data["environment"]
|
||||
if data["environment"] == "testing":
|
||||
del data["environment"]
|
||||
|
||||
return yaml.dump(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(f"Usage: {sys.argv[0]} <hostname>")
|
||||
print(fetch_enc_data("https://cobbler.main.unkin.net", sys.argv[1]))
|
||||
Reference in New Issue
Block a user