User-creation and removing with Puppet

User Creation & Removal:

To create local user with puppet we need to follow below steps.

  • Prepare a user creation file using sample file (replace sampleser with original username) “/etc/puppet/manifests/users/sample_user.pp”.



















We need to update public key of the user in “/etc/puppet/files/ubuntu/home/sampleuser/.ssh/authorized_keys2”.

Removing a Local user:

  • If the user created by puppet, then we need to edit user creation file as below

From  ensure =>  present,   to   ensure => absent,

  • If user is not created by the puppet, one method removing by logging into the server, another method creating simple class and include it in node definition in site.pp.