saz / puppet-sudo

Manage sudo with Puppet on Debian-, RedHat- and SUSE-based linux distributions and some BSDs
Other
105 stars 215 forks source link

unable to use hiera.yaml with module profile #256

Closed gerbdla closed 4 years ago

gerbdla commented 4 years ago

I believe this a is a problem or at least I am unable to get hiera to work. Here is my setup

inside module_profile class mc_profiles::sudo () {

class { "::sudo":

leave sudoers as is

purge => false, config_file_replace => false, } } I tried several configurations none of which worked

hiera.yaml in module_profile sudo::configs: 'dave': 'ensure' : 'absent' 'source' : 'puppet:///files/etc/sudoers.d/users/dave'

or sudo::configs: 'module_profile::dave': 'ensure' : 'absent' 'source' : 'puppet:///files/etc/sudoers.d/users/dave'

Any ideas about how to use sudo module hiera.yaml.

gerbdla commented 4 years ago

Question: Is it possible to use sudo with a parent class that instantiates sudo and uses hiera.yaml?

saz commented 4 years ago

I'm not sure, if I get that right, but I think you're trying to use data in modules? If that's the case, I'd guess that you have to add parameters to your class and pass them on to the sudo module.

gerbdla commented 4 years ago

If I understand this correctly you can put the user data into your a hiera file such as common.yaml and it will automatically create the users without having to use sudo::conf resource? The key name has to be sudo::configs correct?
If so, I guess I will have to make them params in the class and pass them to the sudo::config resource.
It would be nice to be able to put everything in the hiera data if I use a parent class structure example like class mc_profiles { class sudo }}

I see this line in init.pp initializing $configs equal to an empty hash. How does it get the values from a hiera data file? Hash $configs = {}, Is it these lines that convert the data to hash?
lookup_options: sudo::configs: merge: strategy: deep merge_hash_arrays: true

Can you offer some guidance as to how $configs gets set. I am fairly new to hiera.

Thanks

Dave

saz commented 4 years ago

Have you found a solution for your issue?