From 4ca41c97989525553058cbe955f18a151f8f880e Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sat, 17 Jun 2023 20:30:19 +1000 Subject: [PATCH] Initial commit --- data/template.yaml | 18 ++++++++++++++++++ enc.py | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 data/template.yaml create mode 100644 enc.py diff --git a/data/template.yaml b/data/template.yaml new file mode 100644 index 0000000..f1c6087 --- /dev/null +++ b/data/template.yaml @@ -0,0 +1,18 @@ +--- +classes: + role::puppet::puppetmaster: + parameter1: value1 + parameter2: value2 +parameters: + global_parameter1: value3 + global_parameter2: value4 +environment: production + + + # In this example, parameter1 and parameter2 are parameters for the role::puppet::puppetmaster class, while global_parameter1 and global_parameter2 are global variables that will be available in your Puppet manifests as $::global_parameter1 and $::global_parameter2. + # + # The parameters key sets top-level variables which are accessible in all classes. The parameters under the classes key are parameters specific to those classes. + # + # You can adapt this template to set any class parameters or global variables you need. + # + # Please note that for Puppet 5 or later, you can access the global variables without the leading :: like so: $global_parameter1. However, the leading :: is needed for compatibility with Puppet 4. diff --git a/enc.py b/enc.py new file mode 100644 index 0000000..efd616c --- /dev/null +++ b/enc.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import yaml +import os +import sys + +# Path to your ENC data directory +enc_data_dir = '/opt/puppetlabs/enc/data' + +# Get the hostname from command line argument +hostname = sys.argv[1] + +# Construct the file path +file_path = os.path.join(enc_data_dir, f'{hostname}.yaml') + +# Check if the file exists +if os.path.exists(file_path): + # If the file exists, open it and load the YAML data + with open(file_path, 'r') as file: + data = yaml.safe_load(file) + print(yaml.dump(data)) +else: + # If the file does not exist, print an error message and exit + sys.stderr.write(f"Error: File {file_path} does not exist.\n") + sys.exit(1)