CentOS 6
Sponsored Link

Puppet - How to Use [user resource]2014/01/26

 
This is the exmaples for user resource.
[1] It manages the configuration to keep "cent" user exists.
# generate a crypted password for a user

[root@dlp ~]#
grub-crypt --sha-512

Password:
# set password

Retype password:
$6$0XTc2rjlxxxxxxxx
[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,
}
Matched Content