Last active
September 29, 2020 20:54
-
-
Save happymcplaksin/8e262e98db6bd28d0ce9 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 = "/var/lib/puppet/client_data/catalog" | |
elsif user == 'oracle' | |
dir = "/home/oracle/.puppet/var/client_data/catalog" | |
else | |
puts "Sorry I don't know where to find the catalog for #{user}" | |
exit 1 | |
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