FreeBSD 14
Sponsored Link

Puppet : How to use [user Resource]2024/09/12

 

This is the examples for [user] resource.

[1] It manages the configuration to keep [freebsd] user exists.
# generate encrypted password for a user

root@dlp:~ #
echo "userpassword" | openssl passwd -6 -stdin

$6$v/Mo7qyDFJU9dVXm$1QlvJbGNPfR4sn80tUdbYzEMte.f2ln.PCd4QS9zdQJTTo53fEj0GSz2B6NyjGCGxeFKxF162FE78/7Pga3YO.
root@dlp:~ #
vi /usr/local/etc/puppet/code/environments/production/manifests/user01.pp
user { 'freebsd':
  ensure     => present,
  home       => '/home/freebsd',
  managehome => true,
  password   => '$6$v/Mo7qyDFJU9d*****',
}
[2] Specify UID or GID of group explicitly.
root@dlp:~ #
vi /usr/local/etc/puppet/code/environments/production/manifests/user02.pp
group { 'netbsd':
  ensure => present,
  gid    => 2001,
}
user { 'netbsd':
  ensure     => present,
  home       => '/home/netbsd',
  managehome => true,
  uid        => 2001,
  gid        => 2001,
  groups     => ['netbsd', 'wheel'],
  password   => '$6$v/Mo7qyDFJU9d*****',
}
[3] It manages the configuration to keep [serverworld] user does not exist. (If exists, it is deleted included home directory.)
root@dlp:~ #
vi /usr/local/etc/puppet/code/environments/production/manifests/user03.pp
user { 'serverworld':
  ensure     => absent,
  home       => '/home/serverworld',
  managehome => true,
}
Matched Content