前回に引き続き,
puppetrunの使い方
Puppetのデフォルトの動作は,
- Puppetクライアントが数百台あるいはそれ以上の規模になった場合に,
Puppetサーバへのアクセスが同時間帯に集中する恐れがある - 新しいマニフェストをとりあえず1台だけに適用してテストしてみたい,
といった場合でも, 全サーバに勝手に適用されてしまう恐れがある
この問題に対処するためには,
puppetrunはPuppet付属のコマンドラインツールで,
puppetrunを利用するためには,
事前に必要な設定
- Puppetサーバ側の設定
- Puppetサーバ側では特に設定の必要はありません。
- Puppetクライアント側の設定
- Puppetクライアント側では,
puppetrunを実行してpuppetdへ接続してくるホストに対し, 以下のように/etc/ puppet/ namespaceauth. confで, アクセスの許可/拒否を設定します。 [puppetrunner] allow server.
example. org allow *.example. com deny *.example. net
puppetd/ puppetmasterdの起動とpuppetrunの実行
- puppetdの起動
- Puppetクライアント側で以下のようにpuppetdを起動します。--listenオプションをつけることで,
puppetrunからの接続を受け付けます。--no-clientオプションをつけることで, puppetrunから始動されない限り, puppetmasterdに接続しに行かなくなります。 $ sudo puppetd --verbose --server server.
example. org --listen --no-client - puppetmasterdの起動
- Puppetサーバ側でpuppetmasterdを起動します。特別なオプションは必要ありません。
$ sudo puppetmasterd --verbose
- puppetrunの実行
- Puppetサーバ側でpuppetrunを実行します。特にエラーがなければ,
exit code 0と表示して終了します。 $ sudo puppetrun --host client.
example. org Triggering client. example. org client. example. org finished with exit code 0 Finished
puppetrunのオプション
puppetrunの代表的なオプションは以下の通りです。
オプション名 | 説明 | 利用例 |
---|---|---|
host | 始動する対象となるホスト。複数指定可。 | --host a. |
all | 管理対象のホストすべてを始動します。 | --all |
class | 特定のクラスをインクルードしているホストのみ始動します。 | --class web |
parallel | 同時に始動するホストの数。デフォルトは1。 | --parallel 5 |
tag | 特定のタグがついたリソースのみを適用する。 | --tag maintenance |
テンプレート
前回解説したファイルサーバ機能では,
テンプレートの利用例として,
まず,
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName <%= fqdn %>:80
ERBテンプレートファイルには,
テンプレートファイルが用意できたら,
file { '/etc/httpd/conf/httpd.conf':
content => template('etc/httpd/conf/httpd.conf'),
}