Created
December 10, 2018 02:59
-
-
Save GeoffWilliams/8fb58678d15c4fbe45189f7a22bb42b6 to your computer and use it in GitHub Desktop.
Dump the class parameters given to a class in puppet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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