-
-
Save op-ct/4e901c75a86fbff157a52ce6f5ba15d0 to your computer and use it in GitHub Desktop.
pupcat.rb
This file contains 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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'json' | |
require 'yaml' | |
user = ARGV[0] || %x{id -u -n}.strip | |
if user == 'root' | |
dir = '/opt/puppetlabs/puppet/cache/client_data/catalog/' | |
else | |
dir = "/home/#{user}/.puppetlabs/var/client_data/catalog/" | |
end | |
unless File.directory? dir | |
fail "Sorry, I don't know where to find the catalog for user '#{user}'" | |
end | |
cat = JSON.load(File.readlines("#{dir}/#{ENV['HOSTNAME']}.json").join) | |
print cat.to_yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment