hiera_explain 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62b43e9bbbd325c266ea3353f8117437d9e28aa9
4
- data.tar.gz: f1265853cac0fe2d6c164edf2d8a2f3572937eb0
3
+ metadata.gz: e67aa6217b53556efee930920050fbcf1a195e97
4
+ data.tar.gz: f12d603ac9217d24754bc5d0c1d04fc0d40f597f
5
5
  SHA512:
6
- metadata.gz: ea1959e7315819eaefd3f77aef057a9da2b1d3e423cebf859a93c7e37e152fc2849f535d49c050d1b805b34bad499945ce203dcddfb4d79ce65d4c7ada8add06
7
- data.tar.gz: 5c75677b4298ae512b46008c9b2c81ce3e28e92806ce28378fd550501118d6ad4f9a1cb19060ea77bcc26b6ac41b3cbb34c2585e79be142c379c32a25065ff66
6
+ metadata.gz: 6b7821c3f08d5bfdb88924eeaa2cd25b48b27498aec8d83c70feff9aaf782ef4874566648b96fcd37be11271f6a613a8a0f9edd455ecb21e1acaf6988a7d03a6
7
+ data.tar.gz: 71e6727925cfabc651e9c800050bb29d786ad666b15e48a34b490da13a998a8de9721ae950eb4a9f7a9e2bc2127a91c69887b385f09f3c72f7bf3e37d70e94ee
data/README.md CHANGED
@@ -142,6 +142,7 @@ Usage : hiera_explain [--json PATH] [--yaml PATH] [--mcollective IDENTITY] [--pu
142
142
  -v, --verbose Show verbose datasource details.
143
143
  -j, --json PATH Load scope from a JSON file.
144
144
  -y, --yaml PATH Load scope from a YAML file.
145
+ -C, --cached IDENTITY Use the Puppet Master's cached facts file for an identity.
145
146
  -m, --mcollective IDENTITY Use MCollective to retrieve scope for an identity.
146
147
  -p, --puppetdb IDENTITY Use PuppetDB to retrieve scope for an identity.
147
148
  -i, --inventory IDENTITY Use Puppet's inventory service to retrieve scope (deprecated!)
@@ -273,8 +274,9 @@ marshal
273
274
  ## Disclaimer
274
275
 
275
276
  This is early in development, although the script this is based on has been used
276
- in the classroom for quite a while now. This currently only supports Hiera
277
- version 1.x.
277
+ in the classroom for quite a while now. This currently only supports version 1.x.
278
+ of the `hiera.yaml` config file. (It will work with current Hiera, but doesn't
279
+ understand the new data plugins.)
278
280
 
279
281
  Contact
280
282
  -------
@@ -48,6 +48,10 @@ optparse = OptionParser.new { |opts|
48
48
  scope.load_scope(arg, :yaml)
49
49
  end
50
50
 
51
+ opts.on("-C IDENTITY", "--cached IDENTITY", "Use the Puppet Master's cached facts file for an identity.") do |arg|
52
+ scope.load_scope(arg, :cached)
53
+ end
54
+
51
55
  opts.on("-m IDENTITY", "--mcollective IDENTITY", "Use MCollective to retrieve scope for an identity.") do |arg|
52
56
  scope.load_scope(arg, :mcollective)
53
57
  end
@@ -73,8 +73,30 @@ class HieraExplain::Scope
73
73
  Puppet::Node::Facts.indirection.terminus_class = :puppetdb
74
74
  scope = YAML.load(Puppet::Node::Facts.indirection.find(source).to_yaml)
75
75
  rescue Exception => e
76
- STDERR.puts "PuppetDB fact lookup failed: #{e.class}: #{e}"
77
- exit 1
76
+ STDERR.puts "PuppetDB fact lookup failed: #{e.class}: #{e}"
77
+ exit 1
78
+ end
79
+
80
+ when :cached
81
+ require 'puppet'
82
+ require 'yaml'
83
+
84
+ path = "#{Puppet.settings[:vardir]}/yaml/facts/#{source}.yaml"
85
+ unless File.exist? path
86
+ require 'hocon'
87
+ data = {}
88
+ # I hate hardcoding this path, but I don't know how to retreive it programatically.
89
+ Dir['/etc/puppetlabs/puppetserver/conf.d/*'].each do |conf|
90
+ data.merge! Hocon.load conf
91
+ end
92
+ path = "#{data['jruby-puppet']['master-var-dir']}/yaml/facts/#{source}.yaml"
93
+ end
94
+
95
+ begin
96
+ scope = YAML.load_file(path)
97
+ rescue Exception => e
98
+ STDERR.puts "No cached facts file for client #{source}"
99
+ exit 1
78
100
  end
79
101
 
80
102
  when :inventory_service
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera_explain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Ford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-24 00:00:00.000000000 Z
11
+ date: 2016-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hocon
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: |2
56
70
  Hiera lookups have always been hard for people to understand. This tool will
57
71
  display the entire lookup hierarchy, including filenames, exactly as Hiera will