-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add exec_restorecon to hiera calls #243
Conversation
Also add type definitions for hiera values and replace hiera_hash with the new lookup variant (fixing voxpupuli#238)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Fabian
Thanks for your contribution. If you move the lookup_options to hiera data itself this can be merged IMHO:
manifests/init.pp
Outdated
$module = undef, | ||
$permissive = undef, | ||
$port = undef, | ||
Optional[Hash] $boolean = lookup('selinux::boolean', { 'default_value' => undef, 'merge' => 'hash' }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not work IMHO. lookup()
will never be used because automatic parameter lookup will see selinux::boolean defined and then the default is not applicable. The defaults for the lookup need to be defined in hiera data itself. see https://puppet.com/docs/puppet/5.0/hiera_merging.html#configuring-merge-behavior-in-hiera-data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. i think you're right.
But i'm not sure what a good solution would be.
Would lookup options defined in a module hiera be actually used if hiera finds the key in global/environment hiera? I would be surprised if it did.
Normally i would simply remove the merge options and leave that up to the user. But that might break backwards compatibility in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, forget what i wrote ;)
i've looked up the documentation and lookup_options is a special case for which puppet actually does a merge to cover this use-case we have here explicitly.
i'll add it to hiera
lookup options are now configured in hiera
$module = undef, | ||
$permissive = undef, | ||
$port = undef, | ||
Optional[Hash] $boolean = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense (and work) to just make this (and the other ones below it) Hash $boolean = {}
and still use hiera?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be a problem and i prefer to have simple datatypes too. But it would break for users explicitly passing "undef" to the class (to override hiera values from higher up) which would no longer be valid (no idea if anyone actually does this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a valid point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does passing undef work to not trigger automatic parameter lookup? I think there was a discussion about that some time ago.
But I prefer undef over an empty hash as it shows that nothing needs to be passed and Optional describes this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've run the acceptance tests . they don't use hiera data but at least it doesn't break passing things by param. 👍
yeah, the hiera data stuff is always hard to test properly... (especially if it involves merge strategies) |
ok. so hiera also works as expected. tested the hash merge as well If i'd like to change the default values of the exec_restorecon define how would i implement that? As exec_restorecon is a define and the params get hash merged i can't set defaults via hiera. And the onlyif default is even trickier as it would include the the path as well...
But i'm open for other ideas. |
You would define a resource default: Selinux::Exec_restorecon { somewhere on top or node scope. ("$env/manifest/site.pp") |
Ah right. Didn't think about that. Thanks! Still the onlyif_contexts_change or 'exec_on_changes' would be a nice addition. Otherwise you'll have a puppet exec show up in the logs on every run no matter if it had to change contexts or not. |
Add exec_restorecon to hiera calls
Also add type definitions for hiera values and replace hiera_hash with the new lookup variant (fixing #238)