Skip to content
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

What happens when ensure is set to "absent"? #5

Open
dsnyder0pc opened this issue Oct 23, 2013 · 2 comments
Open

What happens when ensure is set to "absent"? #5

dsnyder0pc opened this issue Oct 23, 2013 · 2 comments

Comments

@dsnyder0pc
Copy link

When I change "ensure: present" to "ensure: absent" for one of my users, I see that Puppet removes the user, but the puppet-users extension then errors out when trying to process the removed users's SSH authorized_keys file:

Notice: /User[bmcmillan]/ensure: removed
Error: /Stage[main]/Common/Users[sysadmins]/Users::Setup[test_user]/Users::Ssh_authorized_keys[[email protected]]/Ssh_authorized_key[[email protected]]: Could not evaluate: No such file or directory - /home/test_user/.ssh/authorized_keys

Please let me know if this is just unique to my setup or if you see the same thing. Be sure to test with a user that actually has an authorized_keys file.

The workaround for me seems to be to comment out the "ssh_authorized_keys:" section in hiera, but it would be nice if I didn't have to do so. It probably does not make sense for the module to attempt to manage keys for a user that has been purged. Thanks.

@pr0xr
Copy link

pr0xr commented Apr 24, 2014

You hove to specify ensure for each key to make it work.

@noemif
Copy link

noemif commented May 23, 2014

Hi,

I had the same problem. My solution was to add another if condition to the second part of the setup.pp manifest, line 34:

the original line below:

if($hash[$name]['ssh_authorized_keys']) {

becomes:

if ($hash[$name]['ssh_authorized_keys']) and ($hash[$name]['ensure'] != 'absent') {

so that puppet only attempts to process ssh keys if the user is not set to ensure => absent.

Of course you can still specify ensure => absent for individual keys if you want them removed but do not want to remove the user.

Otherwise great module, simple and useful - thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants