Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
Created December 10, 2018 02:59
Show Gist options
  • Save GeoffWilliams/8fb58678d15c4fbe45189f7a22bb42b6 to your computer and use it in GitHub Desktop.
Save GeoffWilliams/8fb58678d15c4fbe45189f7a22bb42b6 to your computer and use it in GitHub Desktop.
Dump the class parameters given to a class in puppet
import json
import pprint
import subprocess
clientcert = subprocess.check_output(['puppet', 'config', 'print', 'certname']).strip()
catalog_file = '/opt/puppetlabs/puppet/cache/client_data/catalog/' + clientcert + '.json'
with open(catalog_file) as f:
data = json.load(f)
pp = pprint.PrettyPrinter(indent=4)
for res in data['resources']:
if res['type'] == 'Class':
print(res['title'])
print("================================================================================")
if 'parameters' in res:
for param in res['parameters']:
print(param + " => " + str(res['parameters'][param]))
else:
print "_none_"
print "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment