Puppet : How to use [user Resource]2025/10/15 |
|
This is the examples for [user] resource. |
|
| [1] | It manages the configuration to keep [trixie] user exists. |
|
# generate encrypted password for a user root@dlp:~# echo "userpassword" | openssl passwd -6 -stdin $6$9GoE2liT6.P.U/aS$44JDdwgw/vdf48gqhuff2Jkct3zn3oj75e/91i2Jy/RSciTZTa5QKo.FAwqew7Lk/lckWQ6QqNSScQWfTset71
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/user01.pp
user { 'trixie':
ensure => present,
home => '/home/trixie',
managehome => true,
password => '$6$9GoE2liT6.P.U/a*****',
}
|
| [2] | Specify UID or GID of group explicitly. |
|
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/user01.pp
group { 'trixie':
ensure => present,
gid => 2001,
}
user { 'trixie':
ensure => present,
home => '/home/trixie',
managehome => true,
uid => 2001,
gid => 2001,
groups => ['trixie', 'adm'],
password => '$6$0XTc2rjlxxxxxxxx',
}
|
| [3] | Specify maxage or minage of password and comment explicitly. |
|
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/user01.pp
group { 'trixie':
ensure => present,
gid => 2001,
}
user { 'trixie':
ensure => present,
home => '/home/trixie',
managehome => true,
uid => 2001,
gid => 2001,
groups => ['trixie', 'adm'],
password => '$6$0XTc2rjlxxxxxxxx',
password_max_age => 90,
password_min_age => 1,
comment => 'trixie User',
}
|
| [4] | It manages the configuration to keep [trixie] user does not exist. (If exists, it is deleted included home directory.) |
|
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/user01.pp
user { 'trixie':
ensure => absent,
home => '/home/trixie',
managehome => true,
}
|
| Sponsored Link |
|
|