Created
September 11, 2014 13:59
-
-
Save nikolaik/9595feee6230fae9eb33 to your computer and use it in GitHub Desktop.
Use puppetmaster to fetch facts (JSON) from all puppet nodes without puppetdb
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
#!/bin/bash | |
NODES=`sudo puppet cert list --all|awk '{print $2}'` # Get all node names | |
echo '{"facts": [' > facts_tmp.json | |
# for node in node: get facts | |
echo -n $NODES | xargs -d " " -i sh -c 'sudo puppet facts find {} --terminus rest | tr "\n" "," >> facts_tmp.json' | |
sed -ie 's/,$//' facts_tmp.json # Remove last comma | |
echo ']}' >> facts_tmp.json | |
# optionally format and filter json (requires jq) | |
cat facts_tmp.json | jq -r '.facts[] | { name: .name, osrelease: .values.lsbdistrelease }' > facts_releases.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment