Puppet : How to use [user Resource]2023/10/17 |
This is the examples for [user] resource. |
|
[1] | It manages the configuration to keep [centos] 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 { 'centos': ensure => present, home => '/home/centos', 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 { 'centos': ensure => present, gid => 2001, } user { 'centos': ensure => present, home => '/home/centos', managehome => true, uid => 2001, gid => 2001, groups => ['centos', 'wheel'], 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 { 'centos': ensure => present, gid => 2001, } user { 'centos': ensure => present, home => '/home/centos', managehome => true, uid => 2001, gid => 2001, groups => ['centos', 'wheel'], password => '$6$0XTc2rjlxxxxxxxx', password_max_age => 90, password_min_age => 1, comment => 'centos User', } |
[4] | It manages the configuration to keep [centos] user does not exist. (If exists, it is deleted included home directory.) |
[root@dlp ~]#
vi /etc/puppetlabs/code/environments/production/manifests/user01.pp user { 'centos': ensure => absent, home => '/home/centos', managehome => true, } |
Sponsored Link |