Puppet : How to use [user Resource]2015/07/22 |
This is the examples for user resource.
|
|
[1] | It manages the configuration to keep "cent" user exists. |
# generate a crypted password for a user [root@dlp ~]# python -c 'import crypt,getpass; \ print(crypt.crypt(getpass.getpass(), \ crypt.mksalt(crypt.METHOD_SHA512)))' Password: $6$Fb2fpm8Vctsxxxxxxxxxx
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp user { 'cent': ensure => present, home => '/home/cent', managehome => true, password => '$6$0XTc2rjlxxxxxxxx', } |
[2] | Specify UID or GID or group explicitly. |
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp group { 'cent': ensure => present, gid => 1000, } user { 'cent': ensure => present, home => '/home/cent', managehome => true, uid => 1000, gid => 1000, groups => ['cent', 'wheel'], password => '$6$0XTc2rjlxxxxxxxx', } |
[3] | Specify maxage or minage of password or comment explicitly. |
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp group { 'cent': ensure => present, gid => 1000, } user { 'cent': ensure => present, home => '/home/cent', managehome => true, uid => 1000, gid => 1000, groups => ['cent', 'wheel'], password_max_age => 90, password_min_age => 1, password => '$6$0XTc2rjlxxxxxxxx', comment => 'Cent User', } |
[4] | It manages the configuration to keep "cent" user does not exist. (If exists, it is deleted included home directory.) |
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp user { 'cent': ensure => absent, home => '/home/cent', managehome => true, } |
Sponsored Link |
|