Skip to content

Instantly share code, notes, and snippets.

@jmassardo
Last active August 26, 2019 17:19
Show Gist options
  • Save jmassardo/d0903d4e11d47a6e2094001d696cf942 to your computer and use it in GitHub Desktop.
Save jmassardo/d0903d4e11d47a6e2094001d696cf942 to your computer and use it in GitHub Desktop.
This script provides an easy way to count all the nodes in all the orgs on a Chef Server
# Make temp config.rb so we can ignore any ssl errors
echo "ssl_verify_mode :verify_none" > temp_config.rb
# Pull a list of all the orgs on the server
# then loop through each one and make an api call to get the node count
chef-server-ctl org-list -a | while read -r org ; do
echo "Attempting to connect to the $org organization."
/opt/opscode/embedded/bin/knife exec -E "puts api.get('/nodes').size" -s https://127.0.0.1/organizations/$org -u pivotal -k /etc/opscode/pivotal.pem --config temp_config.rb
done
# Remove temp file
rm temp_config.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment