Project

General

Profile

« Previous | Next » 

Revision d844d662

Added by maduma over 7 years ago

get environment fact value from puppet node file

Adds a new environment "fact" value from the node file,
e.g $puppetdir/yaml/node/server.example.com

Useful if we just want to send fact with --push-facts option

View differences:

files/external_node_v2.rb
puppet_facts = YAML::load(facts.gsub(/\!ruby\/object.*$/,''))
hostname = puppet_facts['values']['fqdn'] || certname
# if there is no environment in facts
# get it from node file ({puppetdir}/yaml/node/
unless puppet_facts['values'].key?('environment')
node_filename = filename.sub('/facts/', '/node/')
if File.exist?(node_filename)
node_yaml = File.read(node_filename)
node_data = YAML::load(node_yaml.gsub(/\!ruby\/object.*$/,''))
if node_data.key?('environment')
puppet_facts['values']['environment'] = node_data['environment']
end
end
end
begin
require 'facter'
puppet_facts['values']['puppetmaster_fqdn'] = Facter.value(:fqdn).to_s

Also available in: Unified diff