1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

puppet入門2 パッケージをインストールしてみる

Last updated at Posted at 2013-11-21

puppet入門1 準備編の続き。
今回も1台構成(自分自身がmasterでありclient)で。

流れ

  • /etc/puppet/manifests/site.ppを作成する。
  • puppet実行してsite.ppに書いてある内容を実行してもらう。

パッケージのインストール

site.pp
node 'puppetmaster.safe' {
  package { ['w3m',
             'nkf']:
    ensure => installed,
  } 
}
# 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 '1385076612'
Notice: /Stage[main]//Node[puppetmaster.safe]/Package[nkf]/ensure: created
Notice: /Stage[main]//Node[puppetmaster.safe]/Package[w3m]/ensure: created
Notice: Finished catalog run in 4.23 seconds
/var/log/messages
Nov 22 02:30:11 puppetmaster puppet-agent[1712]: Starting Puppet client version 3.3.2
Nov 22 02:30:11 puppetmaster puppet-agent[1717]: Retrieving plugin
Nov 22 02:30:12 puppetmaster puppet-master[916]: Compiled catalog for puppetmaster.safe in environment production in 0.31 seconds
Nov 22 02:30:13 puppetmaster puppet-agent[1717]: Caching catalog for puppetmaster.safe
Nov 22 02:30:13 puppetmaster puppet-agent[1717]: Applying configuration version '1385076612'
Nov 22 02:30:14 puppetmaster yum: Installed: nkf-2.07-1.1.fc6.i386
Nov 22 02:30:14 puppetmaster puppet-agent[1717]: (/Stage[main]//Node[puppetmaster.safe]/Package[nkf]/ensure) created
Nov 22 02:30:17 puppetmaster yum: Installed: w3m-0.5.1-18.el5.i386
Nov 22 02:30:17 puppetmaster puppet-agent[1717]: (/Stage[main]//Node[puppetmaster.safe]/Package[w3m]/ensure) created
Nov 22 02:30:17 puppetmaster puppet-agent[1717]: Finished catalog run in 4.23 seconds
  • w3mとnkfがインストールされたことを確認。

ホストごとに処理を分ける

site.pp
node 'puppetmaster.safe' {
  package { ['w3m',
             'nkf',
             'ctags']:
    ensure => installed,
  } 
}

node 'www.safe' {
  package { ['php53-cli']:
    ensure => installed,
  } 
}

node default {
  package { ['ntp']:
    ensure => installed,
  } 
}
  • puppetmaster.safe に nkfw3mctagsがインストール
  • www.safephp53-cliがインストール
  • ホスト名がpuppetmaster.safewww.safeにマッチしない場合、ntpがインストール。
# 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 '1385077372'
Notice: /Stage[main]//Node[puppetmaster.safe]/Package[ctags]/ensure: created
Notice: Finished catalog run in 1.98 seconds
/var/log/messages
Nov 22 02:42:51 puppetmaster puppet-agent[2171]: Starting Puppet client version 3.3.2
Nov 22 02:42:51 puppetmaster puppet-agent[2176]: Retrieving plugin
Nov 22 02:42:52 puppetmaster puppet-master[916]: Compiled catalog for puppetmaster.safe in environment production in 0.01 seconds
Nov 22 02:42:52 puppetmaster puppet-agent[2176]: Caching catalog for puppetmaster.safe
Nov 22 02:42:52 puppetmaster puppet-agent[2176]: Applying configuration version '1385077372'
Nov 22 02:42:54 puppetmaster yum: Installed: ctags-5.6-1.1.i386
Nov 22 02:42:54 puppetmaster puppet-agent[2176]: (/Stage[main]//Node[puppetmaster.safe]/Package[ctags]/ensure) created
Nov 22 02:42:54 puppetmaster puppet-agent[2176]: Finished catalog run in 1.98 seconds

注意点

同じnodeを2つ書いてはいけない

node node 'puppetmaster.safe' {
}
node node 'puppetmaster.safe' {
}
/var/log/messages
Nov 22 02:51:28 puppetmaster puppet-agent[2732]: Could not retrieve catalog from remote server: Error 400 on SERVER: Node 'puppetmaster.safe' is already defined at /etc/puppet/manifests/site.pp:7; cannot redefine at /etc/puppet/manifests/site.pp:15 on node puppetmaster.safe

facter

$ facter

を実行するとpuppetで使える変数一覧を取得できる。
処理を分岐させるのに必須。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?