Skip to content

Instantly share code, notes, and snippets.

@nikolaik
Created September 11, 2014 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nikolaik/9595feee6230fae9eb33 to your computer and use it in GitHub Desktop.
Save nikolaik/9595feee6230fae9eb33 to your computer and use it in GitHub Desktop.
Use puppetmaster to fetch facts (JSON) from all puppet nodes without puppetdb
#!/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