Last active
August 22, 2017 20:46
-
-
Save heliocentric/e5967377279ce5518a9055fd7fc8bad1 to your computer and use it in GitHub Desktop.
file_backend.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Puppet::Functions.create_function(:'file_backend') do | |
dispatch :file_backend do | |
param "String", :key | |
param "Hash", :options | |
param "Puppet::LookupContext", :context | |
end | |
def file_backend(key, options, context) | |
if (options.key?("directory")) | |
dir = context.interpolate(options["directory"]) | |
if (File.exists?("#{dir}/#{key}") | |
data = File.read("#{dir}/#{key}") | |
else | |
context.not_found | |
end | |
else | |
context.not_found | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
version: 5 | |
defaults: | |
datadir: "data" | |
data_hash: "yaml_data" | |
hierarchy: | |
- name: "File Backend" | |
lookup_key: "file_backend" | |
options: | |
directory: '/data/hiera' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment