You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 ---------
class network::hiera (
$network_alias = {},
) {
validate_hash($network_alias)
Activity
esalberg commentedon Aug 24, 2015
I am doing something similar to this as well. Would it be helpful to put in a pull request?
razorsedge commentedon Oct 7, 2015
Mentioned in #69, #18, and #10.
razorsedge commentedon Oct 7, 2015
@esalberg See commit 1ee64aa.
esalberg commentedon Oct 7, 2015
@razorsedge - That commit is just a doc change / no code, or am I missing something?
razorsedge commentedon Oct 7, 2015
@esalberg Perhaps throw that commit and ee9aa2b into a PR? Touch things up a bit like we discussed (ie hiera.pp and not init.pp)?
At least it might be a good starting point.
esalberg commentedon Oct 7, 2015
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 ---------
class network::hiera (
$network_alias = {},
) {
validate_hash($network_alias)
Merge hashes from multiple hiera layers
$hiera_network_alias = hiera_hash('network::alias', undef)
$fin_network_alias = $hiera_network_alias ? {
undef => $network_alias,
default => $hiera_network_alias,
}
create_resources('network::alias', $fin_network_alias)
}
--------Option #2: Simplified ---------
class network::hiera {
Merge hashes from multiple hiera layers
$hiera_network_alias = hiera_hash('network::alias', undef)
if $hiera_network_alias {
create_resources('network::alias', $hiera_network_alias)
}
}
esalberg commentedon Oct 7, 2015
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.
esalberg commentedon Oct 8, 2015
Quick update on testing:
With "include network::hiera" in my network.pp and simplified hiera.pp code in the module:
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).
chrisdaish commentedon Jan 15, 2016
Hi chaps,
Any news on the recent PR (#78)?
Would be great to get see this implemented into the module.
Chris
razorsedge commentedon Mar 12, 2016
#78 has been merged.