OLD | NEW |
1 #!/usr/bin/env ruby | 1 #!/usr/bin/ruby |
2 # This script is a node classifier for Puppet that operates on top of Hiera | 2 # This script is a node classifier for Puppet that operates on top of Hiera |
3 # and uses a custom hosts.yaml config to map host roles. | 3 # and uses a custom hosts.yaml config to map host roles. |
4 | 4 |
5 require 'getoptlong' | 5 require 'getoptlong' |
6 require 'hiera' | 6 require 'hiera' |
7 require 'socket' | 7 require 'socket' |
8 require 'yaml' | 8 require 'yaml' |
9 | 9 |
10 # Where to search for the Hiera configuration | 10 # Where to search for the Hiera configuration |
11 HIERA_CONFIG = ENV.fetch('PUPPET_HIERA_CONFIG', '/etc/puppet/hiera.yaml') | 11 HIERA_CONFIG = ENV.fetch('PUPPET_HIERA_CONFIG', '/etc/puppet/hiera.yaml') |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 parameters = hiera.lookup('parameters', {}, scope, nil, :hash) | 81 parameters = hiera.lookup('parameters', {}, scope, nil, :hash) |
82 parameters['role'] = role | 82 parameters['role'] = role |
83 result = { 'classes' => classes, 'parameters' => parameters } | 83 result = { 'classes' => classes, 'parameters' => parameters } |
84 rescue Exception => error | 84 rescue Exception => error |
85 STDERR.puts "#{BASENAME}: #{error.message}: #{HIERA_CONFIG}" | 85 STDERR.puts "#{BASENAME}: #{error.message}: #{HIERA_CONFIG}" |
86 exit 1 | 86 exit 1 |
87 end | 87 end |
88 | 88 |
89 puts result.to_yaml | 89 puts result.to_yaml |
90 | 90 |
OLD | NEW |