hiera 0.3.0 → 1.0.0rc4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of hiera might be problematic. Click here for more details.

@@ -0,0 +1,112 @@
1
+ 1.0.0rc4
2
+ ===
3
+ 6887137 (maint) Add Getting Started tutorial
4
+ 091fea3 Overhaul Hiera packaging
5
+ 7947dd6 Consolidate changelog, update erb templates
6
+ 4698cf1 (#15105) Update README YAML examples
7
+ fcd3d2c (maint) Hiera now has a LICENSE file
8
+ ca47463 Remove datadir value in hiera.yaml
9
+ 92a148f (maint) Fix failing Hiera::Util specs
10
+ 07366d8 Use File::ALT_SEPARATOR to test platform
11
+ 1b7f787 Add specs for Hiera::Util
12
+ cdd7364 (#14867) Add windows support
13
+ 16c3dd3 (#12122) Merge arrays and hashes across backends
14
+ 480d86c (#12122) Correctly fall through backends during loop
15
+ d0fcc57 Add default config to hiera
16
+ 3ec4165 match data in puppet ${::fact} style to get rid of puppet deprecation warnings
17
+
18
+ 1.0.0rc3
19
+ ===
20
+ a1a885a Adding package task liberally copied from puppet-dashboard.
21
+ 3527443 Updating apple pkg task to refer to ext directory.
22
+ 445a6f2 ext is more appropriate than conf for a dirname.
23
+ ade5567 Adding debian packaging to hiera.
24
+ 3ef4f96 Move redhat spec into conf dir, to standardize packaging.
25
+ b6218b9 (maint) Hiera should raise an error when config is missing
26
+ 1df7201 Update mac packaging to dynamically generate preflight
27
+ 10f930f Add mac packaging to hiera
28
+ 22a98ee Remove Puppet parser functions
29
+ 0067cd2 (maint) Additional tests for Hiera array and hash lookups
30
+ 7312a95 (maint) Add Hiera acceptance tests
31
+ 9808a64 (#14514) Use default config when hiera.yaml is missing
32
+ fd644b6 Add require hiera/backend to test
33
+ fe3d509 Remove empty Puppet class definition
34
+
35
+ 1.0.0rc2
36
+ ===
37
+ fa3081c Updating hiera.spec, CHANGELOG for Hiera 1.0.0rc1
38
+ 6de3d4c Moving CHANGES.txt to CHANGELOG. Updating CHANGELOG with git log from initial commit to v0.3.0 tag.
39
+ dbf9fe3 Update README to reference deb and rpm packages
40
+ f697b7f Updated hiera.spec to include puppet functions and put in the right place.
41
+ 540d2d6 (#14460) Add Puppet parser functions
42
+ 29c5ad7 Add hiera.spec for building hiera on redhat
43
+ 24ef7b9 (#13600) Monkey patch mktmpdir on ruby 1.8.5
44
+ b7b3280 (maint) Make noop logger work on Ruby 1.9.x
45
+ 602c526 (maint) Fix failing spec test on Ruby 1.9.3
46
+ 82881e3 (#14150) Use tar_gz instead of tar
47
+ 7ef2821 (#14148) Add docs to Hiera packaging
48
+ 67f91d6 (#14147) Handle lack of rubygems gracefully
49
+ f6c9f5d (#14124) Load rake tasks directly to fix tests for Ruby 1.9.x
50
+ 122b891 (#13641) Fix Hiera::Backend#parse_string to support :undefined in extra_data
51
+ e6dea8e Commit caching on YAML Backend
52
+ ddd5b66 Fix VERSION contant in lib/hiera.rb
53
+ 50f9771 hiera working on ruby 1.9.2/1.9.3, issue #10975 (http://projects.puppetlabs.com/issues/10975)
54
+ 794265f (maint) Code base cleanup, use 2 space indention.
55
+
56
+ v0.3.0
57
+ ===
58
+
59
+ d3b9c41 Fixes a quoting string issue
60
+ 2b6c3e7 Change Rakefile to autoversion
61
+ 1e7affb Rspec 2.7 has introduced some non backwards compatible changes that is exposed by using require with full paths.
62
+ d136fc2 Switch branding to Puppet Labs
63
+ 731f2ef Fix warnings for rake
64
+ 0a53e96 fix failing test after sort was removed
65
+ 15fb3bd Do not sort arrays after building them as array data with complex data in them like hashes will fail to sort and raise exceptions
66
+ f296a18 Test cases for #21
67
+ dcf51ce Fixes: Hiera errors on empty yaml files
68
+ d2d59d7 Revising backend bool spec test that nil /= false
69
+ 3cd4cec Fixes #15 Hiera return nil for false value
70
+ 17a2a98 Adding inventory_service option to scope.
71
+ 6ecab35 (#13) Hierarchy includes sub-hierarchy
72
+ 79b0d4b Corrected invalid YAML markup.
73
+ c05823a Add specs to verify datatypes are being retained
74
+ dedeb8c Make hiera handle boolean/numeric values correctly instead of just returning nil
75
+ b78b3e4 Add type mismatch error output and test cases
76
+ 95e60ce Added additional spec tests for hash.
77
+ f078414 Revising spec test for hash merge.
78
+ 9d72afa Hash was merged wrong direction.
79
+ b4a90ba Adding hashes to CHANGES.txt
80
+ 90a23be Adding hash spec unit tests
81
+ d1171d7 Adding hash support to hiera and yaml backend
82
+ aa6af39 Fix logic around handling of defaults in array searches. It used to always return [nil] for unknown data in array searches now it returns the supplied default.
83
+ 51a0a57 Fix versioning and autoload the Puppet logger
84
+ fb88a3b Removed :json type from load_scope when parsing YAML format
85
+ 3839126 Fix typo
86
+ 8b7e036 More 0.2.0 update information
87
+ 93711a9 Fix spacing
88
+ e804daf Update readme with information for 0.2.0
89
+ 4c990e1 Release 0.2.0
90
+ 1977a1e Improve tests based on recent changes
91
+ 3683a62 Simplify plugins that reads serialized data from files by moving more to the Backend module
92
+ 9d92041 Update changes file
93
+ 61e3574 Add Puppet logger plugin
94
+ 98a9525 Add array merge searches to the framework and the yaml backend Add array search to the command line Parse %{var}s in Strings, Arrays and Hashes correctly
95
+ 19cbf04 Update doco
96
+ 0f0837c Add querying facts via mcollective for scope of the CLI
97
+ aeaef32 Remove some stray whitespace Turn a warn message into a debug message to avoid spamming logs
98
+ 27d6fd9 Fix /bin/env to /usr/bin/env (#1) Improve gem file
99
+ dde5997 Release 0.1.0
100
+ f69ebb2 Fix verbose checking in the cli Do not return empty sources Improve tests
101
+ 6d8130f Small language fix
102
+ 23ef93d Show variable expansion in string results
103
+ 362710c Add sample data to the readme
104
+ dcc2ad2 Add a CLI query tool
105
+ e3eb8de More todo items
106
+ ced8d33 Add licence and readme
107
+ e5d0106 avoid some debug noise
108
+ dc41bcd Add comments and tests
109
+ 19e27c2 Small changes to the yaml backend, add a pluggable logging system and a console logger
110
+ 28cdd56 - simplify language by changing precedence with hierarchy - add gem bits - fall through to multiple backends till one provides an answer - make the backend writing process a bit easier
111
+ 19e03a7 Working YAML backend
112
+ ca3efeb Add Readme
data/COPYING ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2010, 2011 R.I.Pienaar, Puppet Labs
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,237 @@
1
+ # Hiera
2
+
3
+ A simple pluggable Hierarchical Database.
4
+
5
+ -
6
+ **Tutorials:** Check the docs directory for tutorials.
7
+
8
+ ## Why?
9
+
10
+ Hierarchical data is a good fit for the representation of infrastructure information.
11
+ Consider the example of a typical company with 2 datacenters and on-site development,
12
+ staging etc.
13
+
14
+ All machines need:
15
+
16
+ - ntp servers
17
+ - sysadmin contacts
18
+
19
+ By thinking about the data in a hierarchical manner you can resolve these to the most
20
+ correct answer easily:
21
+
22
+ <pre>
23
+ /------------- DC1 -------------\ /------------- DC2 -------------\
24
+ | ntpserver: ntp1.dc1.example.com | | ntpserver: ntp1.dc2.example.com |
25
+ | sysadmin: dc1noc@example.com | | |
26
+ | classes: users::dc1 | | classes: users::dc2 |
27
+ \-------------------------------/ \-------------------------------/
28
+ \ /
29
+ \ /
30
+ /------------- COMMON -------------\
31
+ | ntpserver: 1.pool.ntp.org |
32
+ | sysadmin: "sysadmin@%{domain}" |
33
+ | classes: users::common |
34
+ \----------------------------------/
35
+ </pre>
36
+
37
+ In this simple example machines in DC1 and DC2 have their own NTP servers, additionaly
38
+ DC1 has its own sysadmin contact - perhaps because its a remote DR site - while DC2
39
+ and all the other environments would revert to the common contact that would have the
40
+ machines domain fact expanded into the result.
41
+
42
+ The _classes_ variable can be searched using the array method which would build up a
43
+ list of classes to include on a node based on the hierarchy. Machines in DC1 would have
44
+ the classes _users::common_ and _users::dc1_.
45
+
46
+ The other environment like development and staging would all use the public NTP infrastructure.
47
+
48
+ This is the data model that extlookup() have promoted in Puppet, Hiera has taken this
49
+ data model and extracted it into a standalone project that is pluggable and have a few
50
+ refinements over extlookup.
51
+
52
+ ## Enhancements over Extlookup
53
+
54
+ Extlookup had just one backend, Hiera can be extended with your own backends and represent
55
+ a few enhancements over the base Extlookup approach thanks to this.
56
+
57
+ ### Multiple backends are queried
58
+
59
+ If you have a YAML and Puppet backend loaded and your users provide module defaults in the
60
+ Puppet backend you can use your YAML data to override the Puppet data. If the YAML doesnt
61
+ provide an answer the Puppet backend will get an oppertunity to provide an answer.
62
+
63
+ ### More scope based variable expansion
64
+
65
+ Extlookup could parse data like %{foo} into a scope lookup for the variable foo. Hiera
66
+ retains this ability and any Arrays or Hashes will be recursively searched for all strings
67
+ that will then be parsed.
68
+
69
+ The datadir and defaults are now also subject to variable parsing based on scope.
70
+
71
+ ### No CSV support by default
72
+
73
+ We have not at present provided a backward compatible CSV backend. A converter to
74
+ YAML or JSON should be written. When the CSV backend was first chosen for Puppet the
75
+ Puppet language only supports strings and arrays of strings which mapped well to CSV.
76
+ Puppet has become (a bit) better wrt data and can now handle hashes and arrays of hashes
77
+ so it's a good time to retire the old data format.
78
+
79
+ ### Array Searches
80
+
81
+ Hiera can search through all the tiers in a hierarchy and merge the result into a single
82
+ array. This is used in the hiera-puppet project to replace External Node Classifiers by
83
+ creating a Hiera compatible include function.
84
+
85
+ ## Future Enhancements
86
+
87
+ * More backends should be created
88
+ * A webservice that exposes the data
89
+ * Tools to help maintain the data files. Ideally this would be Foreman and Dashboard
90
+ with their own backends
91
+
92
+ ## Installation
93
+
94
+ Hiera is available as a Gem called _hiera_ and out of the box it comes with just a single
95
+ YAML backend.
96
+
97
+ Hiera is also available as a native package via apt (http://apt.puppetlabs.com) and yum (http://yum.puppetlabs.com). Instructions for adding these repositories can be found at http://docs.puppetlabs.com/guides/installation.html#debian-and-ubuntu and http://docs.puppetlabs.com/guides/installation.html#enterprise-linux respectively.
98
+
99
+ At present JSON (github/ripienaar/hiera-json) and Puppet (hiera-puppet) backends are availble.
100
+
101
+ ## Configuration
102
+
103
+ You can configure Hiera using a YAML file or by providing it Hash data in your code. There
104
+ isn't a default config path - the CLI script will probably assume _/etc/hiera.yaml_ though.
105
+ The default data directory for file based storage is _/var/lib/hiera_.
106
+
107
+ A sample configuration file can be seen here:
108
+
109
+ <pre>
110
+ ---
111
+ :backends:
112
+ - yaml
113
+ - puppet
114
+
115
+ :logger: console
116
+
117
+ :hierarchy:
118
+ - "%{location}"
119
+ - common
120
+
121
+ :yaml:
122
+ :datadir: /etc/puppet/hieradata
123
+
124
+ :puppet:
125
+ :datasource: data
126
+ </pre>
127
+
128
+ This configuration will require YAML files in _/etc/puppet/hieradata_ these need to contain
129
+ Hash data, sample files matching the hierarchy described in the _Why?_ section are below:
130
+
131
+ _/etc/puppet/hieradata/dc1.yaml_:
132
+ <pre>
133
+ ---
134
+ ntpserver: ntp1.dc1.example.com
135
+ sysadmin: dc1noc@example.com
136
+ </pre>
137
+
138
+ _/etc/puppet/hieradata/dc2.yaml_:
139
+ <pre>
140
+ ---
141
+ ntpserver: ntp1.dc2.example.com
142
+ </pre>
143
+
144
+ _/etc/puppet/hieradata/common.yaml_:
145
+ <pre>
146
+ ---
147
+ sysadmin: "sysadmin@%{domain}"
148
+ ntpserver: 1.pool.ntp.org
149
+ </pre>
150
+
151
+ ## Querying from CLI
152
+
153
+ You can query your data from the CLI. By default the CLI expects a config file in _/etc/hiera.yaml_
154
+ but you can pass _--config_ to override that.
155
+
156
+ This example searches Hiera for node data. Scope is loaded from a Puppet created YAML facts
157
+ store as found on your Puppet Masters.
158
+
159
+ If no data is found and the facts had a location=dc1 fact the default would be _sites/dc1_
160
+
161
+ <pre>
162
+ $ hiera acme_version 'sites/%{location}' --yaml /var/lib/puppet/yaml/facts/example.com.yaml
163
+ </pre>
164
+
165
+ You can also supply extra facts on the CLI, assuming Puppet facts did not have a location fact:
166
+
167
+ <pre>
168
+ $ hiera acme_version 'sites/%{location}' location=dc1 --yaml /var/lib/puppet/yaml/facts/example.com.yaml
169
+ </pre>
170
+
171
+ Or if you use MCollective you can fetch the scope from a remote node's facts:
172
+
173
+ <pre>
174
+ $ hiera acme_version 'sites/%{location}' -m box.example.com
175
+ </pre>
176
+
177
+ You can also do array merge searches on the CLI:
178
+
179
+ <pre>
180
+ $ hiera -a classes location=dc1
181
+ ["users::common", "users::dc1"]
182
+ </pre>
183
+
184
+ ## Querying from code
185
+
186
+ This is the same query programatically as in the above CLI example:
187
+
188
+ <pre>
189
+ require 'rubygems'
190
+ require 'hiera'
191
+ require 'puppet'
192
+
193
+ # load the facts for example.com
194
+ scope = YAML.load_file("/var/lib/puppet/yaml/facts/example.com.yaml").values
195
+
196
+ # create a new instance based on config file
197
+ hiera = Hiera.new(:config => "/etc/puppet/hiera.yaml")
198
+
199
+ # resolve the 'acme_version' variable based on scope
200
+ #
201
+ # given a fact location=dc1 in the facts file this will default to a branch sites/dc1
202
+ # and allow hierarchical overrides based on the hierarchy defined in the config file
203
+ puts "ACME Software Version: %s" % [ hiera.lookup("acme_version", "sites/%{location}", scope) ]
204
+ </pre>
205
+
206
+ ## Extending
207
+
208
+ There exist 2 backends at present in addition to the bundled YAML one.
209
+
210
+ ### JSON
211
+
212
+ This can be found on github under _ripienaar/hiera-json_. This is a good example
213
+ of file based backends as Hiera provides a number of helpers to make writing these
214
+ trivial.
215
+
216
+ ### Puppet
217
+
218
+ This is much more complex and queries the data from the running Puppet state, it's found
219
+ on GitHub under _ripienaar/hiera-puppet_.
220
+
221
+ This is a good example to learn how to map your internal program state into what Hiera
222
+ wants as I needed to do with the Puppet Scope.
223
+
224
+ It includes a Puppet Parser Function to query the data from within Puppet.
225
+
226
+ When used in Puppet you'd expect Hiera to log using the Puppet infrastructure, this
227
+ plugin includes a Puppet Logger plugin for Hiera that uses the normal Puppet logging
228
+ methods for all logging.
229
+
230
+ ## License
231
+
232
+ See LICENSE file.
233
+
234
+ ## Support
235
+
236
+ Please log tickets and issues at our [Projects site](http://projects.puppetlabs.com)
237
+