Merge pull request 'Changed prodinf01n01 to testing environment' (#6) from change_prodinf01n01_to_testing into master
Reviewed-on: #6
This commit is contained in:
commit
a3aa5d0b64
@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
classes:
|
classes:
|
||||||
- role::puppet::puppetmaster
|
- role::puppet::puppetmaster
|
||||||
environment: develop
|
environment: testing
|
||||||
|
|||||||
29
enc.py
29
enc.py
@ -1,4 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
External Node Classifier (ENC) for Puppet.
|
||||||
|
|
||||||
|
It reads in YAML files located at '/opt/puppetlabs/enc/data'.
|
||||||
|
|
||||||
|
If the environment specified in the YAML file is 'testing',
|
||||||
|
the environment is not included in the output.
|
||||||
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
@ -17,18 +26,20 @@ def main():
|
|||||||
# Try to open and read the YAML file
|
# Try to open and read the YAML file
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
file_content = f.read()
|
data = yaml.safe_load(f)
|
||||||
try:
|
|
||||||
# Parse the YAML file
|
# If the environment is 'testing', remove it from the output
|
||||||
yaml.safe_load(file_content)
|
if data.get("environment") == "testing":
|
||||||
# If correctly parsed, print the raw content
|
data.pop("environment", None)
|
||||||
print(file_content)
|
|
||||||
except yaml.YAMLError as e:
|
# Print the YAML without the 'environment' if it was 'testing'
|
||||||
print("Error in {}: {}".format(file_path, e), file=sys.stderr)
|
print(yaml.dump(data))
|
||||||
sys.exit(1)
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("Could not open {}: {}".format(file_path, e), file=sys.stderr)
|
print("Could not open {}: {}".format(file_path, e), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
except yaml.YAMLError as e:
|
||||||
|
print("Error in {}: {}".format(file_path, e), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
|
|
||||||
# open a subshell and pull enc data
|
|
||||||
(
|
|
||||||
cd /opt/puppetlabs/enc/
|
|
||||||
git reset --hard master
|
|
||||||
git clean -fd
|
|
||||||
git pull
|
|
||||||
)
|
|
||||||
Loading…
Reference in New Issue
Block a user