Puppet : 利用方法 [user リソース]2025/10/15 |
|
マニフェストで宣言できるリソースタイプのうち、[user] リソースを例にします。 |
|
| [1] | [trixie] ユーザーが存在している状態を維持管理する。 |
|
# マニフェスト登録用に暗号化パスワードを生成 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] | UID や GID, 所属グループを明示的に指定する。 |
|
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] | パスワードの [maxage] や [minage], [comment] も明示的に指定する。 |
|
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] | [trixie] ユーザーが存在していない状態を維持管理する。(存在していたらホームディレクトリも含めて削除する) |
|
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/user01.pp
user { 'trixie':
ensure => absent,
home => '/home/trixie',
managehome => true,
}
|
| Sponsored Link |
|
|