Puppet : How to use [user Resource]2023/10/12 |
This is the examples for [user] resource. |
|
[1] | It manages the configuration to keep [jammy] user exists. |
# generate encrypted password for a user root@dlp:~# python3 -c 'import crypt,getpass; \ print(crypt.crypt(getpass.getpass(), \ crypt.mksalt(crypt.METHOD_SHA512)))' Password: $6$Fb2fpm8Vctsxxxxxxxxxx
root@dlp:~#
vi /etc/puppetlabs/code/environments/production/manifests/user01.pp user { 'jammy': ensure => present, home => '/home/jammy', managehome => true, password => '$6$0XTc2rjlxxxxxxxx', } |
[2] | Specify UID or GID of group explicitly. |
root@dlp:~#
vi /etc/puppetlabs/code/environments/production/manifests/user01.pp group { 'jammy': ensure => present, gid => 2001, } user { 'jammy': ensure => present, home => '/home/jammy', managehome => true, uid => 2001, gid => 2001, groups => ['jammy', 'adm'], password => '$6$0XTc2rjlxxxxxxxx', } |
[3] | Specify maxage or minage of password and comment explicitly. |
root@dlp:~#
vi /etc/puppetlabs/code/environments/production/manifests/user01.pp group { 'jammy': ensure => present, gid => 2001, } user { 'jammy': ensure => present, home => '/home/jammy', managehome => true, uid => 2001, gid => 2001, groups => ['jammy', 'adm'], password => '$6$0XTc2rjlxxxxxxxx', password_max_age => 90, password_min_age => 1, comment => 'jammy User', } |
[4] | It manages the configuration to keep [jammy] user does not exist. (If exists, it is deleted included home directory.) |
root@dlp:~#
vi /etc/puppetlabs/code/environments/production/manifests/user01.pp user { 'jammy': ensure => absent, home => '/home/jammy', managehome => true, } |
Sponsored Link |