Upload
yoshitake-takata
View
256
Download
2
Embed Size (px)
Citation preview
自己紹介@takatayoshitake
あけましておめでとうございます
広島を中心に勉強会に出没。オープンソースカンファレンス広島の
お手伝いやいろんな勉強会でUstとかやってます。
広島サーバユーザ友の会(仮称)や日本CloudStackユーザ会 広島支部等
も最近はじめました。一応・・・OSC広島の公式キャラクター
「あきちゃん」http://j.mp/osc14hiaki
インストール準備下記の公式サイトの情報よりリポジトリ情報をインストールhttps://docs.puppetlabs.com/guides/puppetlabs_package_repositories.html
例: RHEL6 (or CentOS 6)$ sudo rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
スタンドアローンインストール
Puppetはスタンドアロン構成と、クライアント/サーバー構成が可能ですが、まずはスタンドアローンから
インストールyum install puppet -y
設定ファイル(マニフィスト)保存フォルダ作成mkdir -p /etc/puppet/manifests/
1) /etc/puppet/manifests/centos-mirror.pp
# httpdパッケージをインストールpackage { "httpd":
provider => "yum",
ensure => "installed"
}
# httpdサービスを起動するservice { "httpd":
name => "httpd",
ensure => running,
require => Package["httpd"]
}
2) /etc/puppet/manifests/centos-mirror.pp# /var/www/html/centos ディレクトリを作成する
file { "/var/www/html/centos":
ensure => directory,
owner => "root",
group => "root",
require => Package["httpd"]
}
# /var/www/html/centos/6 ディレクトリを作成する
file { "/var/www/html/centos/6":
ensure => directory,
owner => "root",
group => "root",
require => Package["httpd"],
subscribe => File["/var/www/html/centos"]
}
3) /etc/puppet/manifests/centos-mirror.pp# /var/www/html/centos/6/updates ディレクトリを作成する
file { "/var/www/html/centos/6/updates":
ensure => directory,
owner => "root",
group => "root",
require => Package["httpd"],
subscribe => File["/var/www/html/centos/6"]
}
# /var/www/html/centos/6/updates/x86_64 ディレクトリを作成する
file { "/var/www/html/centos/6/updates/x86_64":
ensure => directory,
owner => "root",
group => "root",
require => Package["httpd"],
subscribe => File["/var/www/html/centos/6/updates"]
}
4) /etc/puppet/manifests/centos-mirror.pp# /var/www/html/centos/6/extras ディレクトリを作成する
file { "/var/www/html/centos/6/extras":
ensure => directory,
owner => "root",
group => "root",
require => Package["httpd"],
subscribe => File["/var/www/html/centos/6"]
}
# /var/www/html/centos/6/extras/x86_64 ディレクトリを作成する
file { "/var/www/html/centos/6/extras/x86_64":
ensure => directory,
owner => "root",
group => "root",
require => Package["httpd"],
subscribe => File["/var/www/html/centos/6/extras"]
}
5) /etc/puppet/manifests/centos-mirror.pp
# httpd用の設定ファイルを作成するfile { "/etc/httpd/conf.d/centos-mirror.conf" :
content => "
<directory '/var/www/html/centos'>
Options +Indexes +FollowSymLinks
</directory>",
mode => "0644",
owner => "root",
group => "root",
subscribe => Service["httpd"]
}
6) /etc/puppet/manifests/centos-mirror.pp
# updates の更新をftpでダウンロードするexec { '/usr/bin/lftp -e "mirror --delete --only-newer /Linux/centos/6/updates/x86_64 /var/www/html/centos/6/updates/x86_64 && exit" ftp.riken.jp':
group => "root",
user => "root",
refreshonly => true
}
# extras の更新をftpでダウンロードするexec { '/usr/bin/lftp -e "mirror --delete --only-newer /Linux/centos/6/extras/x86_64 /var/www/html/centos/6/extras/x86_64 && exit" ftp.riken.jp':
group => "root",
user => "root",
refreshonly => true
}
実行結果(1/2)# puppet apply /etc/puppet/manifests/centos-mirror.pp
Notice: Compiled catalog for localhost in environment production in 1.11 seconds
Warning: The package type's allow_virtual parameter will be changing its default value from false to true in a future release. If you do not want to allow virtual packages, please explicitly set allow_virtual to false.
(at /usr/lib/ruby/site_ruby/1.8/puppet/type/package.rb:430:in `default')
Notice: /Stage[main]/Main/Package[httpd]/ensure: created
Notice: /Stage[main]/Main/Service[httpd]/ensure: ensure changed 'stopped' to 'running'
Notice: /Stage[main]/Main/File[/etc/httpd/conf.d/centos-mirror.conf]/ensure: defined content as '{md5}562d61c3e8dc9015abe0f9857429bc3d'
実行結果(2/2)Notice: /Stage[main]/Main/File[/var/www/html/centos]/ensure: created
Notice: /Stage[main]/Main/File[/var/www/html/centos/6]/ensure: created
Notice: /Stage[main]/Main/File[/var/www/html/centos/6/updates]/ensure: created
Notice: /Stage[main]/Main/File[/var/www/html/centos/6/extras]/ensure: created
Notice: /Stage[main]/Main/File[/var/www/html/centos/6/extras/x86_64]/ensure: created
Notice: /Stage[main]/Main/File[/var/www/html/centos/6/updates/x86_64]/ensure: created
Notice: Finished catalog run in 6.83 seconds