- puppet入門1 準備編
- puppet入門2 パッケージをインストールしてみる
- puppet入門3 ファイルを配布
- puppet入門4 ハマった場合の対処とか
- puppet入門5 ユーザー、グループの追加
- puppet入門6 puppetのclientを追加する
- puppet入門7 ファイルに変更があった時にサービスをrestartさせる
ユーザーとグループを追加してみよう。
今回はmysqlユーザーを作ってみた。
設定
site.pp
node 'puppetmaster.safe' {
group { "mysql":
gid => 518,
ensure => present
}
user { "mysql":
ensure => present,
home => "/opt/mysql",
managehome => true,
uid => 518,
gid => 518,
shell => "/bin/bash",
password => '!!'
}
}
配布
# id mysql
id: mysql: No such user
# puppet agent --server=puppetmaster.safe --no-daemonize --verbose
Notice: Starting Puppet client version 3.3.2
Info: Retrieving plugin
Info: Caching catalog for puppetmaster.safe
Info: Applying configuration version '1385177049'
Notice: /Stage[main]//Node[puppetmaster.safe]/Group[mysql]/ensure: created
Notice: /Stage[main]//Node[puppetmaster.safe]/User[mysql]/ensure: created
Notice: Finished catalog run in 0.27 seconds
^CNotice: Caught INT; calling stop
# id mysql
uid=518(mysql) gid=518(mysql) groups=518(mysql)
# grep mysql /etc/shadow
mysql:!!:16032:0:99999:7:::
# grep mysql /etc/passwd
mysql:x:518:518::/opt/mysql:/bin/bash
/var/log/messages
Nov 23 06:24:08 puppetmaster puppet-agent[24182]: Starting Puppet client version 3.3.2
Nov 23 06:24:08 puppetmaster puppet-agent[24187]: Retrieving plugin
Nov 23 06:24:09 puppetmaster puppet-master[916]: Compiled catalog for puppetmaster.safe in environment production in 0.02 seconds
Nov 23 06:24:09 puppetmaster puppet-agent[24187]: Caching catalog for puppetmaster.safe
Nov 23 06:24:09 puppetmaster puppet-agent[24187]: Applying configuration version '1385177049'
Nov 23 06:24:09 puppetmaster puppet-agent[24187]: (/Stage[main]//Node[puppetmaster.safe]/Group[mysql]/ensure) created
Nov 23 06:24:09 puppetmaster puppet-agent[24187]: (/Stage[main]//Node[puppetmaster.safe]/User[mysql]/ensure) created
Nov 23 06:24:09 puppetmaster puppet-agent[24187]: Finished catalog run in 0.27 seconds