Sha256: 38ccb8208b7d3738fafb167dc3487841e9b071abe3065383c441195a379ceb3e
Contents?: true
Size: 1.18 KB
Versions: 74
Compression:
Stored size: 1.18 KB
Contents
# Onering Facts - Chef Properties # provides collection of Chef metadata # require 'json' chef = Facter::Util::Resolution.exec("knife node show $(hostname -f) -c /etc/chef/client.rb -k /etc/chef/client.pem -u $(hostname -f) -F json 2> /dev/null | grep -v 'json_class' 2> /dev/null") if chef begin chef = (JSON.load(chef) rescue {}) unless chef.empty? Facter.add('chef_nodename') do setcode { chef['name'].to_s.strip.chomp.downcase rescue nil } end Facter.add('chef_version') do setcode { %x{chef-client --version}.chomp.split(' ').last.strip rescue nil } end Facter.add('chef_environment') do setcode { chef['environment'].to_s.strip.chomp.downcase rescue nil } end Facter.add('chef_runlist') do setcode { chef['run_list'].collect{|i| i.gsub('[','-').gsub(']','').gsub('::','-') } rescue nil } end Facter.add('chef_enabled') do setcode { !File.exists?('/outbrain/no_chef_run') } end Facter.add('chef_lastrun') do setcode { File.mtime('/etc/chef/last_ran_at').to_i rescue nil } end end rescue Exception => e STDERR.puts "#{e.name}: #{e.message}" end end
Version data entries
74 entries across 74 versions & 2 rubygems