Skip to content

Instantly share code, notes, and snippets.

@happymcplaksin
Last active September 29, 2020 20:54
Show Gist options
  • Save happymcplaksin/8e262e98db6bd28d0ce9 to your computer and use it in GitHub Desktop.
Save happymcplaksin/8e262e98db6bd28d0ce9 to your computer and use it in GitHub Desktop.
pupcat.rb
#!/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