-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hiera Support #45
Comments
I am doing something similar to this as well. Would it be helpful to put in a pull request? |
@razorsedge - That commit is just a doc change / no code, or am I missing something? |
Here's what I've been working on so far. I started using Saz's puppet-ssh code as inspiration, but I think we can simplify with the decision to create a new hiera.pp file instead of putting the hiera_hash entries into init.pp. I'm hoping that means we can remove the pass-in parameters and checks for undef (since if the hiera entries are undef, they should still be handled via the default module method). I'm hoping that Option #2 (simplified) will work, but I need to test it with no hiera entry / passing in from code as well. It should work for hiera only and no entry in hiera. Once this has been finalized, it's just a matter of duplicating another 10-15 times for all the defines. This is what I have so far (for a single define): ----- Option #1: With parameters / extra checks --------- Merge hashes from multiple hiera layers$hiera_network_alias = hiera_hash('network::alias', undef) $fin_network_alias = $hiera_network_alias ? { create_resources('network::alias', $fin_network_alias) --------Option #2: Simplified --------- Merge hashes from multiple hiera layers$hiera_network_alias = hiera_hash('network::alias', undef) if $hiera_network_alias { |
I just re-read the ticket, and instead of duplicating, the original resources array is a much more efficient code structure, so I would try that. |
Quick update on testing:
I think this looks good - I'm going to expand it out to the other defines, update docs, and make a PR (hopefully before EOD tomorrow). |
Hi chaps, Any news on the recent PR (#78)? Chris |
#78 has been merged. |
Hi,
I plan to use hiera for class assosiation in the future. Hiera does not allow calls to puppet defines, but it can be used with the create_resource function.
What I did to make it work is to create a manifest in your network module on my puppetmaster and include this is the nodes hiera file. What it does is simply to ask hiera for a hash containing data about interfaces and realizes them.
class network::hiera {
$resources = ['network::bridge::static', 'network::if::bridge']
define resource() {
$interfaces = hiera_hash($title,false)
if $interfaces {
create_resources($title,$interfaces)
}
}
network::hiera::resource {$resources:}
}
A hiera yaml file looks like this:
network::bridge::static: { "br0": { ensure: "up", ipaddress: "XXX.XXX.XXX.XXX", netmask: "255.255.255.128", stp: true, delay: "0", bridging_opts: "priority=65535" }}
network::if::bridge: { "em1": { ensure: "up", bridge: "br0" }}
I will include the remaining resources in the array and then one should be able to make use of your network module with hiera. At least I will.
regards,
Rüdiger Block
The text was updated successfully, but these errors were encountered: