Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: hiera/puppet_node_classifier.rb

Issue 6269682487132160: Issue 2151 - Drop hiera/private in favor of modules/private/hiera (Closed)
Patch Set: Created March 17, 2015, 9:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« hiera/install_precise.py ('K') | « hiera/install_precise.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env ruby 1 #!/usr/bin/env 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')
12 # Where to search for the Hosts configuration 12 # Where to search for the Hosts configuration
13 HOSTS_CONFIG = ENV.fetch('PUPPET_HOSTS_CONFIG', '/etc/puppet/infrastructure/hier a/private/hosts.yaml') 13 HOSTS_CONFIG = ENV.fetch('PUPPET_HOSTS_CONFIG', '/etc/puppet/infrastructure/modu les/private/hiera/hosts.yaml')
14 14
15 # For logging and usage hints 15 # For logging and usage hints
16 BASENAME = File.basename($0) 16 BASENAME = File.basename($0)
17 17
18 # There's no need for any options beside the commonly exepected ones yet 18 # There's no need for any options beside the commonly exepected ones yet
19 GetoptLong.new( 19 GetoptLong.new(
20 ['--help', '-h', GetoptLong::NO_ARGUMENT] 20 ['--help', '-h', GetoptLong::NO_ARGUMENT]
21 ).each do |opt, arg| 21 ).each do |opt, arg|
22 case opt 22 case opt
23 23
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« hiera/install_precise.py ('K') | « hiera/install_precise.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld