QIQJOGPΛදࣔ͢Δ
wTQFDXXXQIQJOGP@TQFDSC
describe file('/var/www/html/index.php') do
it { should be_file }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end
IUUQTFSWFSTQFDPSHSFTPVSDF@UZQFTIUNMpMF
Slide 26
Slide 26 text
QIQJOGPΛදࣔ͢Δ
wDPPLCPPLTXXXQIQJOGPSC
remote_file '/var/www/html/index.php' do
owner 'root'
group 'root'
mode '755'
end
IUUQTHJUIVCDPNJUBNBFLJUDIFOJUBNBFXJLJSFNPUF@pMFSFTPVSDF
OHJOYΛΠϯετʔϧ͢Δ
wTQFDQSPYZOHJOY@TQFDSC
require 'spec_helper'
%w(
nginx
).each do |n|
describe package(n) do
it { should be_installed }
end
end
describe service('nginx') do
it { should be_enabled }
it { should be_running }
end
describe port(80) do
it { should be_listening }
end
OHJOYͷઃఆΛ͢Δ
% vagrant ssh proxy-1
ubuntu@proxy-1:~$ sudo su -
root@proxy-1:~# cd /etc/nginx/
root@proxy-1:/etc/nginx# ls -ltr
root@proxy-1:/etc/nginx# more nginx.conf
…
include /etc/nginx/conf.d/*.conf; # nginxͷconfigʹincludeػߏ͕͋Δ
…
wQSPYZαʔόͷதΛ͘
VQTUSFBNͷఆٛΛߦ͏
describe file('/etc/nginx/conf.d/www.conf') do
its(:content) { should match /server 172.18.1.31/ }
its(:content) { should match /server 172.18.1.32/ }
end
describe file('/etc/nginx/sites-enabled') do
it { should_not exist }
end
describe file('/etc/nginx/sites-available') do
it { should_not exist }
end
wTQFDQSPYZOHJOY@TQFDSC
Slide 43
Slide 43 text
UFNQMBUFΛར༻͢Δ
template '/etc/nginx/conf.d/www.conf' do
owner 'root'
group 'root'
notifies :restart, 'service[nginx]'
end
IUUQTHJUIVCDPNJUBNBFLJUDIFOJUBNBFXJLJUFNQMBUFSFTPVSDF
Slide 44
Slide 44 text
UFNQMBUFΛར༻͢Δ
upstream app {
<% node['proxy']['app']['servers'].each do |s| %>
server <%= s %>;
<% end %>
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://app/;
}
}
DPPLCPPLTQSPYZUFNQMBUFTXXXDPOGFSC
LFFQBMJWFEΛΠϯετʔϧ͢Δ
wTQFDMCLFFQBMJWFE@TQFDSC
require 'spec_helper'
%w(
keepalived
).each do |n|
describe package(n) do
it { should be_installed }
end
end
describe service('keepalived') do
it { should be_enabled }
it { should be_running }
end
describe port(80) do
it { should be_listening }
end
Slide 53
Slide 53 text
ϦΞϧαʔόςετ
describe file(‘/etc/keepalived/keepalived.conf’) do
its(:content) { should match /real_server 172.18.1.21 80/ }
its(:content) { should match /real_server 172.18.1.22 80/ }
end
wTQFDMCLFFQBMJWFE@TQFDSC
LFFQBMJWFEͷΠϯετʔϧ
package 'keepalived'
service ‘keepalived’ do
%w(enable start)
end
template '/etc/keepalived/keepalived.conf' do
owner 'root'
group 'root'
notifies :restart, 'service[keepalived]'
end
wDPPLCPPLTMCLFFQBMJWFESC