Puppet - removing user who is logged in?

1

I've just started learning puppet and have came across a problem I was wondering if anyone knew how to fix.I m trying to remove a user I get an error message stating that they are logged in so can't be removed.

Now in this case I know what server they're logged into so I could simply just log the user out and proceed from there.My question is however what do you do when you don't know what servers they're logged into? Keeping in mind it could be many servers.

Is there a force remove option or a way to log users out in puppet?

Code below:

user {'art':

ensure => absent,

}

Errors:

Error: Could not delete user art: Execution of '/usr/sbin/userdel art' returned 8: userdel: user art is currently logged in

Error: /Stage[main]/Main/Node[demo]/User[art]/ensure: change from present to absent failed: Could not delete user art: Execution of '/usr/sbin/userdel art' returned 8: userdel: user art is currently logged in

user3329963

Posted 2014-07-18T11:05:56.520

Reputation: 51

Answers

1

You could create an exec resource that kills all the processes owned by the user.

Would look something like:

   exec {'kill-art':
     command => 'pkill -u art',
     onlyif  => 'pgrep -u art',
   }

   user {'art':
     ensure  => absent,
     require => Exec['kill-art'],
   }

rojs

Posted 2014-07-18T11:05:56.520

Reputation: 121