Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active May 29, 2018 22:32
Show Gist options
  • Save natemccurdy/985823c2d0c9cc716c09ab07404831b9 to your computer and use it in GitHub Desktop.
Save natemccurdy/985823c2d0c9cc716c09ab07404831b9 to your computer and use it in GitHub Desktop.
Show nodes where certname and fqdn are not the same
#!/opt/puppetlabs/puppet/bin/ruby
#
# This script will find any Puppet agent whose certname does NOT match the agent's FQDN.
#
require 'json'
fqdn_values = JSON.parse(`/opt/puppetlabs/puppet/bin/puppet query 'facts[certname,value] { name = "fqdn" }'`)
fqdn_values.each do |result|
puts result['certname'] if result['certname'] != result['value']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment