c2d23aaeae
- 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
51 lines
1.6 KiB
Python
Executable File
51 lines
1.6 KiB
Python
Executable File
#!/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]))
|