├── PART01 ├── CH01 │ ├── .gitignore │ ├── Gemfile │ ├── cookbooks │ │ ├── yum-epel │ │ │ ├── attributes │ │ │ │ ├── default.rb │ │ │ │ ├── epel-testing.rb │ │ │ │ ├── epel-testing-source.rb │ │ │ │ ├── epel.rb │ │ │ │ ├── epel-testing-debuginfo.rb │ │ │ │ ├── epel-source.rb │ │ │ │ └── epel-debuginfo.rb │ │ │ ├── metadata.rb │ │ │ ├── CHANGELOG.md │ │ │ ├── recipes │ │ │ │ └── default.rb │ │ │ ├── metadata.json │ │ │ └── README.md │ │ └── yum │ │ │ ├── metadata.rb │ │ │ ├── libraries │ │ │ └── matchers.rb │ │ │ ├── providers │ │ │ ├── globalconfig.rb │ │ │ └── repository.rb │ │ │ ├── recipes │ │ │ └── default.rb │ │ │ ├── templates │ │ │ └── default │ │ │ │ ├── repo.erb │ │ │ │ └── main.erb │ │ │ ├── resources │ │ │ ├── repository.rb │ │ │ └── globalconfig.rb │ │ │ ├── attributes │ │ │ └── main.rb │ │ │ ├── CHANGELOG.md │ │ │ ├── metadata.json │ │ │ └── README.md │ ├── README.md │ ├── nodes │ │ └── webdb.json │ ├── site-cookbooks │ │ ├── httpd │ │ │ ├── metadata.rb │ │ │ ├── templates │ │ │ │ └── default │ │ │ │ │ └── httpd.conf.erb │ │ │ ├── recipes │ │ │ │ └── default.rb │ │ │ ├── CHANGELOG.md │ │ │ └── README.md │ │ └── base_packages │ │ │ ├── metadata.rb │ │ │ ├── recipes │ │ │ └── default.rb │ │ │ ├── CHANGELOG.md │ │ │ └── README.md │ ├── Gemfile.lock │ └── Vagrantfile ├── CH02 │ ├── .gitignore │ ├── .rspec │ ├── spec │ │ ├── default │ │ │ ├── git_spec.rb │ │ │ ├── user_spec.rb │ │ │ ├── ntp_spec.rb │ │ │ └── nginx_spec.rb │ │ └── spec_helper.rb │ ├── Gemfile │ ├── Rakefile │ ├── README.md │ ├── nodes │ │ └── webdb.json │ ├── site-cookbooks │ │ ├── git │ │ │ ├── recipes │ │ │ │ └── default.rb │ │ │ ├── metadata.rb │ │ │ ├── CHANGELOG.md │ │ │ └── README.md │ │ ├── ntp │ │ │ ├── metadata.rb │ │ │ ├── recipes │ │ │ │ └── default.rb │ │ │ ├── CHANGELOG.md │ │ │ ├── README.md │ │ │ └── templates │ │ │ │ └── default │ │ │ │ └── ntp.conf.erb │ │ ├── nginx │ │ │ ├── metadata.rb │ │ │ ├── recipes │ │ │ │ └── default.rb │ │ │ ├── CHANGELOG.md │ │ │ └── README.md │ │ └── user │ │ │ ├── metadata.rb │ │ │ ├── recipes │ │ │ └── default.rb │ │ │ ├── CHANGELOG.md │ │ │ └── README.md │ ├── Guardfile │ ├── Gemfile.lock │ └── Vagrantfile └── .DS_Store ├── PART03 ├── CH07 │ ├── .gitignore │ ├── .rspec │ ├── roles │ │ └── app │ │ │ └── manifests │ │ │ └── init.pp │ ├── provision.sh │ ├── Rakefile │ ├── modules │ │ └── ntp │ │ │ └── manifests │ │ │ └── init.pp │ ├── spec │ │ ├── app │ │ │ └── ntp_spec.rb │ │ └── spec_helper.rb │ └── Vagrantfile ├── CH08 │ ├── .gitignore │ ├── .rspec │ ├── roles │ │ └── app │ │ │ └── manifests │ │ │ └── init.pp │ ├── provision.sh │ ├── Rakefile │ ├── modules │ │ └── ntp │ │ │ └── manifests │ │ │ └── init.pp │ ├── spec │ │ ├── app │ │ │ └── ntp_spec.rb │ │ └── spec_helper.rb │ ├── wercker.yml │ └── Vagrantfile ├── CH09 │ ├── .gitignore │ ├── .rspec │ ├── roles │ │ ├── app │ │ │ └── manifests │ │ │ │ └── init.pp │ │ └── proxy │ │ │ └── manifests │ │ │ └── init.pp │ ├── provision.sh │ ├── modules │ │ ├── ntp │ │ │ └── manifests │ │ │ │ └── init.pp │ │ └── nginx │ │ │ └── manifests │ │ │ └── init.pp │ ├── spec │ │ ├── app │ │ │ └── ntp_spec.rb │ │ ├── proxy │ │ │ └── nginx_spec.rb │ │ └── spec_helper.rb │ ├── Rakefile │ ├── wercker.yml │ └── Vagrantfile ├── .DS_Store └── README.md ├── .DS_Store ├── PART04 ├── CH13 │ ├── app │ │ ├── Gemfile │ │ ├── config.ru │ │ ├── app.rb │ │ ├── Dockerfile │ │ ├── test.rb │ │ └── start_www.rb │ ├── git-hooks │ │ └── post-receive │ └── packer │ │ └── ec2.json ├── .DS_Store ├── CH14 │ ├── app.rb │ ├── nginx.conf │ └── callback.rb └── README.md ├── PART02 ├── .DS_Store └── CH06 │ └── .DS_Store ├── PART05 ├── .DS_Store ├── CH15 │ ├── .DS_Store │ └── list1.txt ├── CH16 │ ├── .nginx.conf.swp │ ├── nginx.conf │ └── install.sh ├── CH20 │ └── ngx_http_fizzbuzz_module │ │ ├── config │ │ ├── README.md │ │ ├── COPYING │ │ └── ngx_http_fizzbuzz_module.c ├── CH18 │ ├── nginx.conf │ ├── sites-enabled │ │ ├── unicorn_sample.conf │ │ └── php.example.com.conf │ └── rails │ │ └── config │ │ ├── unicorn │ │ └── production.rb │ │ └── deploy.rb ├── CH17 │ ├── rewrite1.conf │ ├── rewrite2.conf │ ├── rewrite3.conf │ ├── rewrite4.conf │ ├── rewrite5.conf │ ├── rewrite6.conf │ ├── if-set.conf │ └── virtualhost.conf └── CH19 │ └── balancer.conf └── PART07 ├── .DS_Store ├── README.md ├── memcached └── Dockerfile ├── sshd ├── authorized_keys └── Dockerfile └── Vagrantfile /PART01/CH01/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | -------------------------------------------------------------------------------- /PART01/CH02/.gitignore: -------------------------------------------------------------------------------- 1 | /cookbooks/ 2 | -------------------------------------------------------------------------------- /PART01/CH02/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format d -------------------------------------------------------------------------------- /PART03/CH07/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | 3 | -------------------------------------------------------------------------------- /PART03/CH08/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | 3 | -------------------------------------------------------------------------------- /PART03/CH09/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | 3 | -------------------------------------------------------------------------------- /PART03/CH07/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format d 3 | 4 | -------------------------------------------------------------------------------- /PART03/CH08/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format d 3 | 4 | -------------------------------------------------------------------------------- /PART03/CH09/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format d 3 | 4 | -------------------------------------------------------------------------------- /PART01/CH01/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'knife-solo' 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/.DS_Store -------------------------------------------------------------------------------- /PART03/CH07/roles/app/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class app { 2 | include ntp 3 | } 4 | 5 | -------------------------------------------------------------------------------- /PART03/CH08/roles/app/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class app { 2 | include ntp 3 | } 4 | 5 | -------------------------------------------------------------------------------- /PART03/CH09/roles/app/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class app { 2 | include ntp 3 | } 4 | 5 | -------------------------------------------------------------------------------- /PART03/CH09/roles/proxy/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class proxy { 2 | include nginx 3 | } 4 | 5 | -------------------------------------------------------------------------------- /PART04/CH13/app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'sinatra' 3 | gem 'rack-test' 4 | -------------------------------------------------------------------------------- /PART01/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART01/.DS_Store -------------------------------------------------------------------------------- /PART02/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART02/.DS_Store -------------------------------------------------------------------------------- /PART03/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART03/.DS_Store -------------------------------------------------------------------------------- /PART04/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART04/.DS_Store -------------------------------------------------------------------------------- /PART05/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART05/.DS_Store -------------------------------------------------------------------------------- /PART07/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART07/.DS_Store -------------------------------------------------------------------------------- /PART02/CH06/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART02/CH06/.DS_Store -------------------------------------------------------------------------------- /PART05/CH15/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART05/CH15/.DS_Store -------------------------------------------------------------------------------- /PART05/CH16/.nginx.conf.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikibook/building-server-infra/master/PART05/CH16/.nginx.conf.swp -------------------------------------------------------------------------------- /PART03/README.md: -------------------------------------------------------------------------------- 1 | # 서버/인프라 철저 공략 특집2「테스트 주도 인프라와 CI최전선」예제코드 2 | 3 | 기술평론사「서버/인프라 철저 공략」의 특집2「테스트 주도 인프라와 CI 최전선」의 예제코드이다. 4 | -------------------------------------------------------------------------------- /PART04/CH13/app/config.ru: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler' 3 | 4 | Bundler.require 5 | 6 | require './app' 7 | run App -------------------------------------------------------------------------------- /PART01/CH02/spec/default/git_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('git') do 4 | it { should be_installed } 5 | end 6 | -------------------------------------------------------------------------------- /PART07/README.md: -------------------------------------------------------------------------------- 1 | 「서버/인프라 철저 공략」도커를 이용한 경량 가상환경 2 | ======================================== 3 | 4 | 기술평론사「서버/인프라 철저 공략」의 일반 기사「도커를 이용한 경량 가상 환경」의 예제코드이다. -------------------------------------------------------------------------------- /PART03/CH07/provision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | role=$1 4 | 5 | puppet apply --modulepath="/vagrant/modules:/vagrant/roles" \ 6 | -e "include $1" 7 | 8 | -------------------------------------------------------------------------------- /PART03/CH08/provision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | role=$1 4 | 5 | puppet apply --modulepath="/vagrant/modules:/vagrant/roles" \ 6 | -e "include $1" 7 | 8 | -------------------------------------------------------------------------------- /PART03/CH09/provision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | role=$1 4 | 5 | puppet apply --modulepath="/vagrant/modules:/vagrant/roles" \ 6 | -e "include $1" 7 | 8 | -------------------------------------------------------------------------------- /PART01/CH02/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'serverspec' 5 | 6 | gem 'knife-solo' 7 | gem 'guard' 8 | gem 'guard-rspec' 9 | -------------------------------------------------------------------------------- /PART04/CH14/app.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'sinatra/base' 3 | 4 | class App < Sinatra::Base 5 | get '/' do 6 | "hello, kyoto!!" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /PART04/CH13/app/app.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'sinatra/base' 3 | 4 | class App < Sinatra::Base 5 | get '/' do 6 | "hello, world" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['yum-epel']['repositories'] = %w{epel epel-debuginfo epel-source epel-testing epel-testing-debuginfo epel-testing-source} 2 | -------------------------------------------------------------------------------- /PART01/CH02/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rspec/core/rake_task' 3 | 4 | RSpec::Core::RakeTask.new(:spec) do |t| 5 | t.pattern = 'spec/*/*_spec.rb' 6 | end 7 | 8 | task :default => :spec 9 | -------------------------------------------------------------------------------- /PART03/CH07/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rspec/core/rake_task' 3 | 4 | RSpec::Core::RakeTask.new(:spec) do |t| 5 | t.pattern = 'spec/*/*_spec.rb' 6 | end 7 | 8 | task :default => :spec 9 | -------------------------------------------------------------------------------- /PART03/CH08/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rspec/core/rake_task' 3 | 4 | RSpec::Core::RakeTask.new(:spec) do |t| 5 | t.pattern = 'spec/*/*_spec.rb' 6 | end 7 | 8 | task :default => :spec 9 | -------------------------------------------------------------------------------- /PART05/CH20/ngx_http_fizzbuzz_module/config: -------------------------------------------------------------------------------- 1 | ngx_addon_name=ngx_http_fizzbuzz_module 2 | HTTP_MODULES="$HTTP_MODULES ngx_http_fizzbuzz_module" 3 | NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fizzbuzz_module.c" 4 | -------------------------------------------------------------------------------- /PART07/memcached/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y memcached 5 | RUN apt-get clean 6 | 7 | CMD ["/usr/bin/memcached", "-vv"] 8 | USER memcache 9 | 10 | EXPOSE 11211 11 | -------------------------------------------------------------------------------- /PART01/CH01/README.md: -------------------------------------------------------------------------------- 1 | 「サーバ/インフラ徹底攻略」 2 | 巻頭企画「[入門]コードによるインフラ構築」 3 | ChefとVagrantによるインフラのコード化 4 | ======================================== 5 | 6 | 技術評論社刊「サーバ/インフラ徹底攻略」の巻頭企画「[入門]コードによるインフラ構築」第1章「ChefとVagrantによるインフラのコード化」のサンプルコードです。 -------------------------------------------------------------------------------- /PART01/CH02/README.md: -------------------------------------------------------------------------------- 1 | 「サーバ/インフラ徹底攻略」 2 | 巻頭企画「[入門]コードによるインフラ構築」 3 | Serverspecによるテスト駆動インフラ構築 4 | ======================================== 5 | 6 | 技術評論社刊「サーバ/インフラ徹底攻略」の巻頭企画「[入門]コードによるインフラ構築」第2章「Serverspecによるテスト駆動インフラ構築」のサンプルコードです。 -------------------------------------------------------------------------------- /PART03/CH07/modules/ntp/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class ntp { 2 | package { 'ntp': ensure => installed } 3 | 4 | service { 'ntpd': 5 | enable => true, 6 | ensure => running, 7 | require => Package['ntp'], 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /PART03/CH08/modules/ntp/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class ntp { 2 | package { 'ntp': ensure => installed } 3 | 4 | service { 'ntpd': 5 | enable => true, 6 | ensure => running, 7 | require => Package['ntp'], 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /PART03/CH09/modules/ntp/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class ntp { 2 | package { 'ntp': ensure => installed } 3 | 4 | service { 'ntpd': 5 | enable => true, 6 | ensure => running, 7 | require => Package['ntp'], 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /PART04/CH13/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:12.04 2 | RUN apt-get update 3 | RUN apt-get -y install ruby1.9.3 4 | RUN gem install bundler 5 | ADD . /src 6 | RUN cd /src && bundle install 7 | EXPOSE 4567 8 | WORKDIR /src 9 | CMD cd /src && rackup -p4567 10 | -------------------------------------------------------------------------------- /PART03/CH07/spec/app/ntp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('ntp') do 4 | it { should be_installed } 5 | end 6 | 7 | describe service('ntpd') do 8 | it { should be_enabled } 9 | it { should be_running } 10 | end 11 | 12 | -------------------------------------------------------------------------------- /PART03/CH08/spec/app/ntp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('ntp') do 4 | it { should be_installed } 5 | end 6 | 7 | describe service('ntpd') do 8 | it { should be_enabled } 9 | it { should be_running } 10 | end 11 | 12 | -------------------------------------------------------------------------------- /PART03/CH09/spec/app/ntp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('ntp') do 4 | it { should be_installed } 5 | end 6 | 7 | describe service('ntpd') do 8 | it { should be_enabled } 9 | it { should be_running } 10 | end 11 | 12 | -------------------------------------------------------------------------------- /PART01/CH02/nodes/webdb.json: -------------------------------------------------------------------------------- 1 | { 2 | "run_list": [ 3 | "recipe[yum-epel]", 4 | "recipe[nginx]", 5 | "recipe[git]", 6 | "recipe[ntp]", 7 | "recipe[user]" 8 | ], 9 | "automatic": { 10 | "ipaddress": "webdb" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PART03/CH09/spec/proxy/nginx_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('nginx') do 4 | it { should be_installed } 5 | end 6 | 7 | describe service('nginx') do 8 | it { should be_enabled } 9 | it { should be_running } 10 | end 11 | 12 | -------------------------------------------------------------------------------- /PART01/CH01/nodes/webdb.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpd": { 3 | "port": 80 4 | }, 5 | "run_list": [ 6 | "recipe[yum-epel]", 7 | "recipe[base_packages]", 8 | "recipe[httpd]" 9 | ], 10 | "automatic": { 11 | "ipaddress": "webdb" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/git/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: git 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | package "git" do 10 | action :install 11 | end 12 | -------------------------------------------------------------------------------- /PART01/CH02/spec/default/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe user('naoya') do 4 | it { should exist } 5 | it { should belong_to_group 'naoya' } 6 | it { should have_home_directory '/home/naoya' } 7 | it { should have_login_shell '/bin/bash' } 8 | end 9 | -------------------------------------------------------------------------------- /PART05/CH18/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | #user nobody; 3 | 4 | worker_processes 2; 5 | 6 | events { 7 | worker_connections 1024; 8 | } 9 | 10 | http { 11 | include mime.types; 12 | default_type application/octet-stream; 13 | 14 | include sites-enabled/*.conf; 15 | } 16 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/git/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'git' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures git' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/ntp/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'ntp' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures ntp' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/httpd/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'httpd' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures httpd' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/nginx/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'nginx' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures nginx' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/user/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'user' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures user' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | -------------------------------------------------------------------------------- /PART04/README.md: -------------------------------------------------------------------------------- 1 | # サーバ/インフラ徹底攻略 特集3「実践Immutable Infrastructure」サンプルコード 2 | 3 | 技術評論社刊「サーバ/インフラ徹底攻略」の特集3「実践Immutable Infrastructure」のサンプルコードです。 4 | 5 | ## ファイル構成 6 | 7 | - 03 8 | - app 9 | - サンプルアプリケーション 10 | - git-hooks/post-receive 11 | - packer/ec2.json 12 | - 04 13 | - nginx.conf 14 | - callback.rb 15 | - app.rb 16 | 17 | -------------------------------------------------------------------------------- /PART05/CH17/rewrite1.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | # query-string를 무시한다 11 | rewrite ^/test.html/(.*)$ /test.html?test=$1?; 12 | } 13 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/nginx/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | package "nginx" do 10 | action :install 11 | end 12 | 13 | service "nginx" do 14 | action [ :enable, :start ] 15 | end 16 | -------------------------------------------------------------------------------- /PART04/CH13/app/test.rb: -------------------------------------------------------------------------------- 1 | ENV['RACK_ENV'] = 'test' 2 | 3 | require 'app' 4 | require 'test/unit' 5 | require 'rack/test' 6 | 7 | class AppTest < Test::Unit::TestCase 8 | include Rack::Test::Methods 9 | 10 | def app 11 | App 12 | end 13 | 14 | def test_it_returns_ok 15 | get '/' 16 | assert last_response.ok? 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/base_packages/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'base_packages' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures base_packages' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/base_packages/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: base_packages 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | 10 | %w(gcc make git readline readline-devel).each do |pkg| 11 | package pkg do 12 | action :install 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'yum-epel' 2 | maintainer 'Chef' 3 | maintainer_email 'Sean OMeara ' 4 | license 'Apache 2.0' 5 | description 'Installs/Configures yum-epel' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.4.0' 8 | 9 | depends 'yum', '~> 3.0' 10 | -------------------------------------------------------------------------------- /PART05/CH17/rewrite2.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | # /test2.html에 접속할 경우 index.html가 표시된다. 11 | rewrite ^/test2.html$ /test.html; 12 | rewrite ^/test.html$ /index.html; 13 | } 14 | -------------------------------------------------------------------------------- /PART07/sshd/authorized_keys: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAqchoJkgg7U1BLzp+EgBHePi752zr/9XgH/1I9DtpRQdGLuuLqhBKGr4somrEMKaRNXatZBR54SZGW+BPPhxnSNUIqFX7cU0zL2jo4va0IWRko6cjp2gPKqaTbHkR1nWR1lS92v9XdJRYV+nUJWJ45WJ4oMMfbWfWcSN9Awj/0/POGINb8ZZiFFPbYRW/NeX7OqFn5PJnGvdDOvQVnJM6zWzadjFdETdW+nj6SHdheSnm5EFtCMIWuEyJyCAae5JiCIkecoUxWK3yWFK1BwD0+Qm55Mpqdl8UJLTnByGx0wz0f9JnMR2lv8JyNk2uvAxpZC/6U6/JDWNOUHWvSyCa4Q== 2 | -------------------------------------------------------------------------------- /PART01/CH02/spec/default/ntp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('ntp') do 4 | it { should be_installed } 5 | end 6 | 7 | describe service('ntpd') do 8 | it { should be_enabled } 9 | it { should be_running } 10 | end 11 | 12 | describe command('ntpq -p') do 13 | it { should return_exit_status 0 } 14 | it { should return_stdout /\.nict\./ } 15 | end 16 | -------------------------------------------------------------------------------- /PART05/CH17/rewrite3.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | # /test2.html에 접속할 경우 test.html가 표시된다 11 | rewrite ^/test2.html$ /test.html last; 12 | rewrite ^/test.html$ /index.html; 13 | } 14 | -------------------------------------------------------------------------------- /PART05/CH17/rewrite4.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | # /test2.html에 접속할 경우 test.html가 표시된다. 11 | rewrite ^/test2.html$ /test.html break; 12 | rewrite ^/test.html$ /index.html; 13 | } 14 | -------------------------------------------------------------------------------- /PART03/CH09/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rspec/core/rake_task' 3 | 4 | task :spec => "spec:all" 5 | 6 | namespace :spec do 7 | roles = %w( app proxy ) 8 | 9 | task :all => roles 10 | 11 | roles.each do |role| 12 | RSpec::Core::RakeTask.new(role.to_sym) do |t| 13 | ENV["ROLE"] = role 14 | t.pattern = "spec/#{role}/*_spec.rb" 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/user/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: user 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | group 'naoya' do 10 | action :create 11 | end 12 | 13 | user 'naoya' do 14 | group 'naoya' 15 | home "/home/naoya" 16 | shell '/bin/bash' 17 | password nil 18 | supports :manage_home => true 19 | end 20 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'yum' 2 | maintainer 'Chef' 3 | maintainer_email 'cookbooks@getchef.com' 4 | license 'Apache 2.0' 5 | description 'Configures various yum components on Red Hat-like systems' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '3.2.4' 8 | 9 | supports 'redhat' 10 | supports 'centos' 11 | supports 'scientific' 12 | supports 'amazon' 13 | supports 'fedora' 14 | -------------------------------------------------------------------------------- /PART05/CH20/ngx_http_fizzbuzz_module/README.md: -------------------------------------------------------------------------------- 1 | # nginx_http_fizzbuzz_module 2 | 3 | FizzBuzz with nginx 4 | 5 | ``` 6 | location ~ /fizzbuzz$ { 7 | fizzbuzz $arg_number; 8 | } 9 | ``` 10 | 11 | ``` 12 | $ curl -l "http://127.0.0.1:80/fizzbuzz?number=72" 13 | 14 | 15 | 16 | FizzBuzz with nginx! 17 | 18 | 19 |

FizzBuzz(72) = Fizz

20 | 21 | 22 | $ 23 | ``` 24 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/httpd/templates/default/httpd.conf.erb: -------------------------------------------------------------------------------- 1 | ServerRoot "/etc/httpd" 2 | Listen <%= node['httpd']['port'] %> 3 | User apache 4 | Group apache 5 | ServerAdmin root@localhost 6 | ErrorLog "logs/error_log" 7 | TypesConfig /etc/mime.types 8 | Include conf.modules.d/*.conf 9 | DocumentRoot "/var/www/html" 10 | 11 | 12 | Require all granted 13 | 14 | 15 | IncludeOptional conf.d/*.conf -------------------------------------------------------------------------------- /PART07/sshd/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM base 2 | 3 | RUN apt-get install -y openssh-server 4 | RUN mkdir -p /var/run/sshd 5 | 6 | ## Create user 7 | RUN useradd -m naoya 8 | RUN mkdir -p /home/naoya/.ssh; chown naoya /home/naoya/.ssh; chmod 700 /home/naoya/.ssh 9 | ADD ./authorized_keys /home/naoya/.ssh/authorized_keys 10 | RUN chown naoya /home/naoya/.ssh/authorized_keys; chmod 600 /home/naoya/.ssh/authorized_keys 11 | 12 | CMD ["/usr/sbin/sshd","-D"] 13 | EXPOSE 22 14 | -------------------------------------------------------------------------------- /PART05/CH15/list1.txt: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example1.jp; 4 | location / { 5 | proxy_pass http://192.168.0.101; 6 | } 7 | } 8 | server { 9 | listen 80; 10 | server_name example2.jp; 11 | location / { 12 | proxy_pass http://192.168.0.102; 13 | } 14 | } 15 | server { 16 | listen 80; 17 | server_name example3.jp; 18 | location / { 19 | proxy_pass http://192.168.0.103; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PART01/CH02/spec/default/nginx_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('nginx') do 4 | it { should be_installed } 5 | end 6 | 7 | describe service('nginx') do 8 | it { should be_enabled } 9 | it { should be_running } 10 | end 11 | 12 | describe port(80) do 13 | it { should be_listening } 14 | end 15 | 16 | describe file('/etc/nginx/nginx.conf') do 17 | it { should be_file } 18 | it { should contain('nginx').after(/^user/) } 19 | end 20 | -------------------------------------------------------------------------------- /PART05/CH17/rewrite5.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | # /test.html에 접속할 경우 test.html가 표시된다. 11 | rewrite ^/test.html$ /test2.html; 12 | rewrite ^/test2.html$ /test.html; 13 | 14 | location /test2.html { 15 | rewrite ^/test2.html$ /index.html; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PART05/CH17/rewrite6.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | # /test.html에 접속할 경우 index.html가 표시된다. 11 | rewrite ^/test.html$ /test2.html break; 12 | rewrite ^/test2.html$ /test.html; 13 | 14 | location /test2.html { 15 | rewrite ^/test2.html$ /index.html; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/ntp/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ntp 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | package 'ntp' do 10 | action :install 11 | end 12 | 13 | service 'ntpd' do 14 | action [ :enable, :start ] 15 | end 16 | 17 | template '/etc/ntp.conf' do 18 | owner 'root' 19 | group 'root' 20 | mode 0644 21 | notifies :restart, 'service[ntpd]' 22 | end 23 | -------------------------------------------------------------------------------- /PART03/CH09/modules/nginx/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class nginx { 2 | yumrepo { 'nginx': 3 | name => 'nginx', 4 | baseurl => 'http://nginx.org/packages/centos/$releasever/$basearch/', 5 | gpgcheck => 0, 6 | enabled => 1, 7 | } 8 | 9 | package { 'nginx': 10 | ensure => installed, 11 | require => Yumrepo['nginx'], 12 | } 13 | 14 | service { 'nginx': 15 | enable => true, 16 | ensure => running, 17 | require => Package['nginx'], 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /PART05/CH18/sites-enabled/unicorn_sample.conf: -------------------------------------------------------------------------------- 1 | # 2 | # nginx.conf for rails/unicorn server 3 | # 4 | 5 | server { 6 | listen 80; 7 | server_name rails.example.com; 8 | 9 | # rails의 public폴더를 지정 10 | root /home/www/nginx-rails/public; 11 | 12 | location / { 13 | if (!-f $request_filename) { 14 | proxy_pass http://rails-nginx-app; 15 | break; 16 | } 17 | } 18 | } 19 | 20 | upstream rails-nginx-app { 21 | # unicornのsocketファイルを指定 22 | server unix:/var/run/nginx-rails.sock; 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/httpd/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: httpd 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | package "httpd" do 10 | action :install 11 | end 12 | 13 | service "httpd" do 14 | action [ :enable, :start ] 15 | end 16 | 17 | template "/etc/httpd/conf/httpd.conf" do 18 | owner "root" 19 | group "root" 20 | mode 0644 21 | notifies :reload, 'service[httpd]' 22 | end 23 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/git/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | git CHANGELOG 2 | ============= 3 | 4 | This file is used to list changes made in each version of the git cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of git 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/ntp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ntp CHANGELOG 2 | ============= 3 | 4 | This file is used to list changes made in each version of the ntp cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of ntp 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/user/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | user CHANGELOG 2 | ============== 3 | 4 | This file is used to list changes made in each version of the user cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of user 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/httpd/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | httpd CHANGELOG 2 | =============== 3 | 4 | This file is used to list changes made in each version of the httpd cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of httpd 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/nginx/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | nginx CHANGELOG 2 | =============== 3 | 4 | This file is used to list changes made in each version of the nginx cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of nginx 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /PART05/CH16/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | user nobody; 3 | 4 | worker_processes 1; # 작업프로세스수 5 | worker_rlimit_nofile 65535; # 열수 있는 파일 수 6 | 7 | events { 8 | worker_connections 1024; # 받을 수 있는 커넥션 수 9 | } 10 | 11 | 12 | http { 13 | include mime.types; 14 | default_type application/octet-stream; 15 | 16 | server { 17 | listen 80; # 포트번호 18 | server_name localhost; # 호스트명 19 | 20 | location / { 21 | root html; # 루트폴더 22 | index index.html index.htm; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/base_packages/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | base_packages CHANGELOG 2 | ======================= 3 | 4 | This file is used to list changes made in each version of the base_packages cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of base_packages 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /PART05/CH18/sites-enabled/php.example.com.conf: -------------------------------------------------------------------------------- 1 | 2 | server { 3 | listen 80; 4 | server_name php.example.conf; 5 | 6 | root /home/www/html; 7 | 8 | location ~* \.php$ { 9 | include fastcgi_params; 10 | 11 | # TCP소켓으로 통신 할 경우 12 | # fastcgi_pass 127.0.0.1:9000 13 | # UNIX 도메인 소켓으로 통신할 경우 14 | fastcgi_pass unix:/var/run/php5-fpm.sock; 15 | fastcgi_index index.php; 16 | fastcgi_param SCRIPT_FILENAME 17 | $document_root$fastcgi_script_name; 18 | fastcgi_intercept_errors on; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PART03/CH07/Vagrantfile: -------------------------------------------------------------------------------- 1 | VAGRANTFILE_API_VERSION = "2" 2 | 3 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 4 | config.vm.box = "CentOS6.4" 5 | config.vm.box_url = 6 | "https://dl.dropboxusercontent.com/u/515908/CentOS-6.4-x86.box" 7 | 8 | config.vm.provision :shell, inline: <<-EOF 9 | sudo rpm -i \ 10 | http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm 11 | sudo yum install -y puppet 12 | EOF 13 | 14 | config.vm.define :app do |c| 15 | c.vm.provision :shell do |shell| 16 | shell.path = "provision.sh" 17 | shell.args = "app" 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /PART04/CH14/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | pid /run/nginx.pid; 3 | events { 4 | worker_connections 768; 5 | } 6 | 7 | http { 8 | include /etc/nginx/mime.types; 9 | default_type text/plain; 10 | access_log /var/log/nginx/access.log; 11 | error_log /var/log/nginx/error.log; 12 | include /etc/nginx/conf.d/*.conf; 13 | 14 | server { 15 | listen 80; 16 | location / { 17 | if ($host ~ "^ii-([^.]*)\.example\.com$") { 18 | set $upstream $1; 19 | proxy_pass http://$upstream; 20 | } 21 | root /usr/share/nginx/html; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /PART05/CH17/if-set.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html; 9 | 10 | set $mnt false; 11 | if (-e /var/tmp/do_mnt) { 12 | set $mnt true; 13 | } 14 | 15 | if ($remote_addr = 192.168.0.10) { 16 | set $mnt false; 17 | } 18 | 19 | location ^~ / { 20 | if ($mnt = true) { 21 | error_page 503 = @maintenance; 22 | return 503; 23 | } 24 | } 25 | 26 | location @maintenance { 27 | rewrite ^(.*)$ /maintenance.html break; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /PART04/CH13/app/start_www.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby 2 | require 'docker' 3 | 4 | app = ['localhost', 'localhost'] 5 | image = ARGV.shift 6 | 7 | puts < image) 22 | container.start('PortBindings' => {'4567/tcp' => [{}]}) 23 | 24 | container.json["NetworkSettings"]["Ports"].each_value do |v| 25 | port = v[0]["HostPort"] 26 | puts " server srv#{count+=1} #{s}:#{port}" 27 | end 28 | end 29 | 30 | -------------------------------------------------------------------------------- /PART05/CH16/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Install nginx 4 | # 5 | # @author harukasan 6 | 7 | set -e 8 | 9 | NGINX_VERSION=1.2.6 10 | PCRE_VERSION=8.32 11 | 12 | ## for debian/ubuntu: 13 | # sudo aptitude install zlib1g-dev 14 | # sudo aptitude install libssl-dev 15 | 16 | wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz 17 | wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCRE_VERSION}.tar.gz 18 | 19 | tar xvf nginx-${NGINX_VERSION}.tar.gz 20 | cd nginx-${NGINX_VERSION} 21 | 22 | ./configure \ 23 | --prefix=/usr/local/nginx \ 24 | --conf-path=/etc/nginx/nginx.conf \ 25 | --with-pcre=../pcre-${PCRE_VERSION} 26 | 27 | make 28 | sudo make install 29 | -------------------------------------------------------------------------------- /PART03/CH09/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | require 'net/ssh' 3 | 4 | include SpecInfra::Helper::Ssh 5 | include SpecInfra::Helper::DetectOS 6 | 7 | RSpec.configure do |c| 8 | options = {} 9 | user = "" 10 | host = "" 11 | config = `vagrant ssh-config #{ENV["ROLE"]}` 12 | config.each_line do |line| 13 | if match = /HostName (.*)/.match(line) 14 | host = match[1] 15 | elsif match = /User (.*)/.match(line) 16 | user = match[1] 17 | elsif match = /IdentityFile (.*)/.match(line) 18 | options[:keys] = [match[1].gsub(/"/,'')] 19 | elsif match = /Port (.*)/.match(line) 20 | options[:port] = match[1] 21 | end 22 | end 23 | c.ssh = Net::SSH.start(host, user, options) 24 | end 25 | -------------------------------------------------------------------------------- /PART04/CH13/git-hooks/post-receive: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Post receive hook" 3 | export REPO_DIR=/var/tmp/site/ 4 | while read oldrev newrev refname 5 | do 6 | echo args: $oldrev $newrev $refname 7 | branch=`echo $refname | cut -d/ -f3` 8 | if [ "master" == "$branch" ]; then 9 | cd $REPO_DIR 10 | echo $GIT_DIR 11 | unset GIT_DIR 12 | git pull 13 | docker build -t sample-app . 14 | docker tag sample-app localhost:5000/sample-app:$newrev 15 | docker tag sample-app localhost:5000/sample-app:latest 16 | docker push localhost:5000/sample-app 17 | ruby start_www.rb localhost:5000/sample-app:$newrev > haproxy_$newrev.cfg 18 | ln -sf haproxy_$newrev.cfg haproxy_latest.cfg 19 | sudo /etc/init.d/haproxy reload 20 | fi 21 | done 22 | 23 | -------------------------------------------------------------------------------- /PART05/CH17/virtualhost.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 192.168.0.10:80; 3 | server_name example.com; 4 | 5 | access_log /var/log/nginx/example.com-access.log main; 6 | error_log /var/log/nginx/example.com-error.log; 7 | 8 | root /var/www/html/a; 9 | } 10 | 11 | server { 12 | listen 192.168.0.10:80 default_server; 13 | server_name b.example.com d.example.com; 14 | 15 | access_log /var/log/nginx/example-access.log main; 16 | error_log /var/log/nginx/example-error.log; 17 | 18 | root /var/www/html/b; 19 | } 20 | 21 | server { 22 | listen 192.168.0.10:80; 23 | server_name c.example.com; 24 | server_name e.example.com; 25 | server_name f.example.com; 26 | 27 | access_log /var/log/nginx/example.com-access.log main; 28 | error_log /var/log/nginx/example.com-error.log; 29 | 30 | root /var/www/html/c; 31 | } 32 | -------------------------------------------------------------------------------- /PART05/CH18/rails/config/unicorn/production.rb: -------------------------------------------------------------------------------- 1 | worker_processes 8 # 워커프로세스수 2 | listen "/var/run/nginx-rails.sock" # 소켓파일 3 | pid "/var/run/nginx-rails.pid" # pid 파일 4 | 5 | # 표준출력, 표준에러의 출력위치 6 | stdout_path "./log/unicorn/production.log" 7 | stderr_path "./log/unicorn/production.log" 8 | 9 | 10 | # 11 | # preload_app의 설정 12 | # 13 | preload_app true 14 | 15 | before_fork do |server, worker| 16 | # 포크전에 데이터 베이스 접속을 끊는다 17 | if defined?(ActiveRecord::Base) 18 | ActiveRecord::Base.connection.disconnect! 19 | end 20 | 21 | old_pid = "#{server.config[:pid]}.oldbin" 22 | if old_pid != server.pid 23 | begin 24 | sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 25 | Process.kill(sig, File.read(old_pid).to_i) 26 | rescue Errno::ENOENT, Errno::ESRCH 27 | end 28 | end 29 | 30 | sleep 1 31 | end 32 | 33 | after_fork do |server, worker| 34 | if defined?(ActiveRecord::Base) 35 | ActiveRecord::Base.establish_connection 36 | end 37 | end 38 | 39 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | # Matchers for chefspec 3 2 | 3 | if defined?(ChefSpec) 4 | def create_yum_repository(resource_name) 5 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name) 6 | end 7 | 8 | def add_yum_repository(resource_name) 9 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :add, resource_name) 10 | end 11 | 12 | def delete_yum_repository(resource_name) 13 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :delete, resource_name) 14 | end 15 | 16 | def remove_yum_repository(resource_name) 17 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :remove, resource_name) 18 | end 19 | 20 | def create_yum_globalconfig(resource_name) 21 | ChefSpec::Matchers::ResourceMatcher.new(:yum_globalconfig, :create, resource_name) 22 | end 23 | 24 | def delete_yum_globalconfig(resource_name) 25 | ChefSpec::Matchers::ResourceMatcher.new(:yum_globalconfig, :delete, resource_name) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | yum-epel Cookbook CHANGELOG 2 | ====================== 3 | This file is used to list changes made in each version of the yum-centos cookbook. 4 | 5 | v0.4.0 (2014-07-27) 6 | ------------------- 7 | - [#9] Allowing list of repositories to reference configurable. 8 | 9 | 10 | v0.3.6 (2014-04-09) 11 | ------------------- 12 | - [COOK-4509] add RHEL7 support to yum-epel cookbook 13 | 14 | 15 | v0.3.4 (2014-02-19) 16 | ------------------- 17 | COOK-4353 - Fixing typo in readme 18 | 19 | 20 | v0.3.2 (2014-02-13) 21 | ------------------- 22 | Updating README to explain the 'managed' parameter 23 | 24 | 25 | v0.3.0 (2014-02-12) 26 | ------------------- 27 | [COOK-4292] - Do not manage secondary repos by default 28 | 29 | 30 | v0.2.0 31 | ------ 32 | Adding Amazon Linux support 33 | 34 | 35 | v0.1.6 36 | ------ 37 | Fixing up attribute values for EL6 38 | 39 | 40 | v0.1.4 41 | ------ 42 | Adding CHANGELOG.md 43 | 44 | 45 | v0.1.0 46 | ------ 47 | initial release 48 | -------------------------------------------------------------------------------- /PART05/CH20/ngx_http_fizzbuzz_module/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Tatsuhiko Kubo 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /PART05/CH19/balancer.conf: -------------------------------------------------------------------------------- 1 | upstream examples { 2 | ip_hash; 3 | # least_conn; 4 | 5 | server 127.0.0.1:8081 weight=10; 6 | server 127.0.0.1:8082 weight=20; 7 | server 127.0.0.1:8083 weight=30; 8 | } 9 | 10 | server { 11 | listen 8081; 12 | server_name child1.com; 13 | 14 | access_log /var/log/nginx/child1-access.log main; 15 | error_log /var/log/nginx/child1-error.log; 16 | 17 | root /var/www/html; 18 | } 19 | 20 | server { 21 | listen 8082; 22 | server_name child2.com; 23 | 24 | access_log /var/log/nginx/child2-access.log main; 25 | error_log /var/log/nginx/child2-error.log; 26 | 27 | root /var/www/html; 28 | } 29 | 30 | server { 31 | listen 8083; 32 | server_name child3.com; 33 | 34 | access_log /var/log/nginx/child3-access.log main; 35 | error_log /var/log/nginx/child3-error.log; 36 | 37 | root /var/www/html; 38 | } 39 | 40 | server { 41 | listen 80; 42 | server_name example.com; 43 | 44 | access_log /var/log/nginx/example.com-access.log main; 45 | error_log /var/log/nginx/example.com-error.log; 46 | 47 | location / { 48 | proxy_pass http://examples; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/providers/globalconfig.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: yum 3 | # Provider:: repository 4 | # 5 | # Author:: Sean OMeara 6 | # Copyright 2013, Chef 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Allow for Chef 10 support 22 | use_inline_resources if defined?(use_inline_resources) 23 | 24 | action :create do 25 | template new_resource.path do 26 | source 'main.erb' 27 | cookbook 'yum' 28 | mode '0644' 29 | variables(:config => new_resource) 30 | end 31 | end 32 | 33 | action :delete do 34 | file new_resource.path do 35 | action :delete 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /PART04/CH13/packer/ec2.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [{ 3 | "type": "amazon-ebs", 4 | "access_key": "xxx", 5 | "secret_key": "xxxxxx", 6 | "region": "ap-northeast-1", 7 | "source_ami": "ami-9fbec39e", 8 | "instance_type": "t1.micro", 9 | "ssh_username": "ec2-user", 10 | "ssh_timeout": "15m", 11 | "ami_name": "packer-quick-start_v6", 12 | "launch_block_device_mappings": [{ 13 | "device_name": "/dev/sda1", 14 | "volume_size": 10, 15 | "delete_on_termination": true 16 | }], 17 | "ami_block_device_mappings": [{ 18 | "device_name": "/dev/sdb", 19 | "virtual_name": "ephemeral0" 20 | }], 21 | "tags": { 22 | "OS_Version": "Amazon Linux", 23 | "Release": "Latest" 24 | } 25 | }], 26 | "provisioners": [{ 27 | "type": "file", 28 | "source": "app.tar.gz", 29 | "destination": "/tmp/app.tar.gz" 30 | }, 31 | { 32 | "type": "shell", 33 | "inline": [ 34 | "sudo yum -y update", 35 | "sudo yum -y install ruby", 36 | "sudo gem install bundler", 37 | "sudo mkdir /src", 38 | "sudo tar -C/src -xzf /tmp/app.tar.gz", 39 | "sudo chown -R ec2-user:ec2-user /src", 40 | "cd /src/site && bundler install", 41 | "sudo sed -i 's/Defaults/# Defaults/' /etc/sudoers", 42 | "sudo chmod 777 /etc/rc.local", 43 | "echo 'cd /src/site && sudo -u ec2-user /home/ec2-user/bin/rackup -p4567 &' >> /etc/rc.local" 44 | ] 45 | }] 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Sean OMeara () 3 | # Recipe:: yum::default 4 | # 5 | # Copyright 2013, Chef 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | yum_globalconfig '/etc/yum.conf' do 20 | cachedir node['yum']['main']['cachedir'] 21 | keepcache node['yum']['main']['keepcache'] 22 | debuglevel node['yum']['main']['debuglevel'] 23 | exclude node['yum']['main']['exclude'] 24 | logfile node['yum']['main']['logfile'] 25 | exactarch node['yum']['main']['exactarch'] 26 | obsoletes node['yum']['main']['obsoletes'] 27 | proxy node['yum']['main']['proxy'] 28 | installonly_limit node['yum']['main']['installonly_limit'] 29 | installonlypkgs node['yum']['main']['installonlypkgs'] 30 | installroot node['yum']['main']['installroot'] 31 | distroverpkg node['yum']['main']['distroverpkg'] 32 | releasever node['yum']['main']['releasever'] 33 | action :create 34 | end 35 | -------------------------------------------------------------------------------- /PART03/CH08/wercker.yml: -------------------------------------------------------------------------------- 1 | box: wercker/ruby 2 | build: 3 | steps: 4 | - script: 5 | name: Make $HOME/.ssh directory 6 | code: mkdir -p $HOME/.ssh 7 | - create-file: 8 | name: Put SSH public key 9 | filename: $HOME/.ssh/id_rsa.pub 10 | overwrite: true 11 | hide-from-log: true 12 | content: $DIGITALOCEAN_SSH_KEY_PUBLIC 13 | - create-file: 14 | name: Put SSH private key 15 | filename: $HOME/.ssh/id_rsa 16 | overwrite: true 17 | hide-from-log: true 18 | content: $DIGITALOCEAN_SSH_KEY_PRIVATE 19 | - script: 20 | name: Run chmod 0400 $HOME/.ssh/id_rsa 21 | code: chmod 0400 $HOME/.ssh/id_rsa 22 | - script: 23 | name: gem install 24 | code: sudo gem install serverspec --no-ri --no-rdoc 25 | - script: 26 | name: Get Vagrant 27 | code: wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.1_x86_64.deb 28 | - script: 29 | name: Install Vagrant 30 | code: sudo dpkg -i vagrant_1.5.1_x86_64.deb 31 | - script: 32 | name: Run vagrant plugin install 33 | code: vagrant plugin install vagrant-digitalocean 34 | - script: 35 | name: Run vagrant up 36 | code: vagrant up --provider=digital_ocean 37 | - script: 38 | name: Run rake spec 39 | code: rake spec 40 | 41 | after-steps: 42 | - script: 43 | name: Run vagrant destroy 44 | code: vagrant destroy --force -------------------------------------------------------------------------------- /PART03/CH08/Vagrantfile: -------------------------------------------------------------------------------- 1 | VAGRANTFILE_API_VERSION = "2" 2 | 3 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 4 | config.vm.box = "CentOS6.4" 5 | config.vm.box_url = 6 | "https://dl.dropboxusercontent.com/u/515908/CentOS-6.4-x86.box" 7 | 8 | config.vm.provider :digital_ocean do |provider, override| 9 | override.ssh.private_key_path = "~/.ssh/id_rsa" 10 | override.vm.box = "digital_ocean" 11 | override.vm.box_url = 12 | "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box" 13 | provider.client_id = ENV["DIGITALOCEAN_CLIENT_ID"] 14 | provider.api_key = ENV["DIGITALOCEAN_API_KEY"] 15 | provider.image = "CentOS 6.4 x64" 16 | provider.region = "San Francisco 1" 17 | provider.size = "512MB" 18 | provider.ca_path = 19 | "/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt" 20 | 21 | if ENV['WERCKER'] == "true" 22 | provider.ssh_key_name = "wercker" 23 | else 24 | provider.ssh_key_name = "My MacBook Air" 25 | end 26 | end 27 | 28 | config.vm.provision :shell, inline: <<-EOF 29 | sudo rpm -i \ 30 | http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm 31 | sudo yum install -y puppet 32 | EOF 33 | 34 | config.vm.define :app do |c| 35 | c.vm.provision :shell do |shell| 36 | shell.path = "provision.sh" 37 | shell.args = "app" 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/epel-testing.rb: -------------------------------------------------------------------------------- 1 | default['yum']['epel-testing']['repositoryid'] = 'epel-testing' 2 | 3 | case node['platform'] 4 | when 'amazon' 5 | default['yum']['epel-testing']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 6 | default['yum']['epel-testing']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 7 | default['yum']['epel-testing']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 8 | else 9 | case node['platform_version'].to_i 10 | when 5 11 | default['yum']['epel-testing']['description'] = 'Extra Packages for Enterprise Linux 5 - Testing - $basearch' 12 | default['yum']['epel-testing']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel5&arch=$basearch' 13 | default['yum']['epel-testing']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 14 | when 6 15 | default['yum']['epel-testing']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch' 16 | default['yum']['epel-testing']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-epel6&arch=$basearch' 17 | default['yum']['epel-testing']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 18 | end 19 | end 20 | 21 | default['yum']['epel-testing']['failovermethod'] = 'priority' 22 | default['yum']['epel-testing']['gpgcheck'] = true 23 | default['yum']['epel-testing']['enabled'] = false 24 | default['yum']['epel-testing']['managed'] = false 25 | -------------------------------------------------------------------------------- /PART03/CH07/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | require 'pathname' 3 | require 'net/ssh' 4 | 5 | include SpecInfra::Helper::Ssh 6 | include SpecInfra::Helper::DetectOS 7 | 8 | RSpec.configure do |c| 9 | if ENV['ASK_SUDO_PASSWORD'] 10 | require 'highline/import' 11 | c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false } 12 | else 13 | c.sudo_password = ENV['SUDO_PASSWORD'] 14 | end 15 | c.before :all do 16 | block = self.class.metadata[:example_group_block] 17 | if RUBY_VERSION.start_with?('1.8') 18 | file = block.to_s.match(/.*@(.*):[0-9]+>/)[1] 19 | else 20 | file = block.source_location.first 21 | end 22 | host = File.basename(Pathname.new(file).dirname) 23 | if c.host != host 24 | c.ssh.close if c.ssh 25 | c.host = host 26 | options = Net::SSH::Config.for(c.host) 27 | user = options[:user] || Etc.getlogin 28 | vagrant_up = `vagrant up app` 29 | config = `vagrant ssh-config app` 30 | if config != '' 31 | config.each_line do |line| 32 | if match = /HostName (.*)/.match(line) 33 | host = match[1] 34 | elsif match = /User (.*)/.match(line) 35 | user = match[1] 36 | elsif match = /IdentityFile (.*)/.match(line) 37 | options[:keys] = [match[1].gsub(/"/,'')] 38 | elsif match = /Port (.*)/.match(line) 39 | options[:port] = match[1] 40 | end 41 | end 42 | end 43 | c.ssh = Net::SSH.start(host, user, options) 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /PART03/CH08/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | require 'pathname' 3 | require 'net/ssh' 4 | 5 | include SpecInfra::Helper::Ssh 6 | include SpecInfra::Helper::DetectOS 7 | 8 | RSpec.configure do |c| 9 | if ENV['ASK_SUDO_PASSWORD'] 10 | require 'highline/import' 11 | c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false } 12 | else 13 | c.sudo_password = ENV['SUDO_PASSWORD'] 14 | end 15 | c.before :all do 16 | block = self.class.metadata[:example_group_block] 17 | if RUBY_VERSION.start_with?('1.8') 18 | file = block.to_s.match(/.*@(.*):[0-9]+>/)[1] 19 | else 20 | file = block.source_location.first 21 | end 22 | host = File.basename(Pathname.new(file).dirname) 23 | if c.host != host 24 | c.ssh.close if c.ssh 25 | c.host = host 26 | options = Net::SSH::Config.for(c.host) 27 | user = options[:user] || Etc.getlogin 28 | vagrant_up = `vagrant up app` 29 | config = `vagrant ssh-config app` 30 | if config != '' 31 | config.each_line do |line| 32 | if match = /HostName (.*)/.match(line) 33 | host = match[1] 34 | elsif match = /User (.*)/.match(line) 35 | user = match[1] 36 | elsif match = /IdentityFile (.*)/.match(line) 37 | options[:keys] = [match[1].gsub(/"/,'')] 38 | elsif match = /Port (.*)/.match(line) 39 | options[:port] = match[1] 40 | end 41 | end 42 | end 43 | c.ssh = Net::SSH.start(host, user, options) 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /PART01/CH02/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | require 'pathname' 3 | require 'net/ssh' 4 | 5 | include SpecInfra::Helper::Ssh 6 | include SpecInfra::Helper::DetectOS 7 | 8 | RSpec.configure do |c| 9 | if ENV['ASK_SUDO_PASSWORD'] 10 | require 'highline/import' 11 | c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false } 12 | else 13 | c.sudo_password = ENV['SUDO_PASSWORD'] 14 | end 15 | c.before :all do 16 | block = self.class.metadata[:example_group_block] 17 | if RUBY_VERSION.start_with?('1.8') 18 | file = block.to_s.match(/.*@(.*):[0-9]+>/)[1] 19 | else 20 | file = block.source_location.first 21 | end 22 | host = File.basename(Pathname.new(file).dirname) 23 | if c.host != host 24 | c.ssh.close if c.ssh 25 | c.host = host 26 | options = Net::SSH::Config.for(c.host) 27 | user = options[:user] || Etc.getlogin 28 | vagrant_up = `vagrant up default` 29 | config = `vagrant ssh-config default` 30 | if config != '' 31 | config.each_line do |line| 32 | if match = /HostName (.*)/.match(line) 33 | host = match[1] 34 | elsif match = /User (.*)/.match(line) 35 | user = match[1] 36 | elsif match = /IdentityFile (.*)/.match(line) 37 | options[:keys] = [match[1].gsub(/"/,'')] 38 | elsif match = /Port (.*)/.match(line) 39 | options[:port] = match[1] 40 | end 41 | end 42 | end 43 | c.ssh = Net::SSH.start(host, user, options) 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /PART03/CH09/wercker.yml: -------------------------------------------------------------------------------- 1 | box: wercker/ruby 2 | build: 3 | steps: 4 | - script: 5 | name: Make $HOME/.ssh directory 6 | code: mkdir -p $HOME/.ssh 7 | - create-file: 8 | name: Put SSH public key 9 | filename: $HOME/.ssh/id_rsa.pub 10 | overwrite: true 11 | hide-from-log: true 12 | content: $DIGITALOCEAN_SSH_KEY_PUBLIC 13 | - create-file: 14 | name: Put SSH private key 15 | filename: $HOME/.ssh/id_rsa 16 | overwrite: true 17 | hide-from-log: true 18 | content: $DIGITALOCEAN_SSH_KEY_PRIVATE 19 | - script: 20 | name: Run chmod 0400 $HOME/.ssh/id_rsa 21 | code: chmod 0400 $HOME/.ssh/id_rsa 22 | - script: 23 | name: gem install 24 | code: sudo gem install serverspec --no-ri --no-rdoc 25 | - script: 26 | name: Get Vagrant 27 | code: wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.1_x86_64.deb 28 | - script: 29 | name: Install Vagrant 30 | code: sudo dpkg -i vagrant_1.5.1_x86_64.deb 31 | - script: 32 | name: Run vagrant plugin install 33 | code: vagrant plugin install vagrant-digitalocean 34 | - script: 35 | name: Run vagrant up 36 | code: vagrant up --provider=digital_ocean 37 | - script: 38 | name: Run rake spec:app 39 | code: rake spec:app 40 | - script: 41 | name: Run rake spec:proxy 42 | code: rake spec:proxy 43 | 44 | after-steps: 45 | - script: 46 | name: Run vagrant destroy 47 | code: vagrant destroy --force -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/epel-testing-source.rb: -------------------------------------------------------------------------------- 1 | default['yum']['epel-testing-source']['repositoryid'] = 'epel-testing-source' 2 | 3 | case node['platform'] 4 | when 'amazon' 5 | default['yum']['epel-testing-source']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 6 | default['yum']['epel-testing-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 7 | default['yum']['epel-testing-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 8 | else 9 | case node['platform_version'].to_i 10 | when 5 11 | default['yum']['epel-testing-source']['description'] = 'Extra Packages for Enterprise Linux 5 - Testing - $basearch Source' 12 | default['yum']['epel-testing-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=testing-source-epel5&arch=$basearch' 13 | default['yum']['epel-testing-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 14 | when 6 15 | default['yum']['epel-testing-source']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch Source' 16 | default['yum']['epel-testing-source']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel6&arch=$basearch' 17 | default['yum']['epel-testing-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 18 | end 19 | end 20 | 21 | default['yum']['epel-testing-source']['failovermethod'] = 'priority' 22 | default['yum']['epel-testing-source']['gpgcheck'] = true 23 | default['yum']['epel-testing-source']['enabled'] = false 24 | default['yum']['epel-testing-source']['managed'] = false 25 | -------------------------------------------------------------------------------- /PART03/CH09/Vagrantfile: -------------------------------------------------------------------------------- 1 | VAGRANTFILE_API_VERSION = "2" 2 | 3 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 4 | config.vm.box = "CentOS6.4" 5 | config.vm.box_url = 6 | "https://dl.dropboxusercontent.com/u/515908/CentOS-6.4-x86.box" 7 | 8 | config.vm.provider :digital_ocean do |provider, override| 9 | override.ssh.private_key_path = "~/.ssh/id_rsa" 10 | override.vm.box = "digital_ocean" 11 | override.vm.box_url = 12 | "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box" 13 | provider.client_id = ENV["DIGITALOCEAN_CLIENT_ID"] 14 | provider.api_key = ENV["DIGITALOCEAN_API_KEY"] 15 | provider.image = "CentOS 6.4 x64" 16 | provider.region = "San Francisco 1" 17 | provider.size = "512MB" 18 | provider.ca_path = 19 | "/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt" 20 | 21 | if ENV['WERCKER'] == "true" 22 | provider.ssh_key_name = "wercker" 23 | else 24 | provider.ssh_key_name = "My MacBook Air" 25 | end 26 | end 27 | 28 | config.vm.provision :shell, inline: <<-EOF 29 | sudo rpm -i \ 30 | http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm 31 | sudo yum install -y puppet 32 | EOF 33 | 34 | config.vm.define :app do |c| 35 | c.vm.provision :shell do |shell| 36 | shell.path = "provision.sh" 37 | shell.args = "app" 38 | end 39 | end 40 | 41 | config.vm.define :proxy do |c| 42 | c.vm.provision :shell do |shell| 43 | shell.path = "provision.sh" 44 | shell.args = "proxy" 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/epel.rb: -------------------------------------------------------------------------------- 1 | default['yum']['epel']['repositoryid'] = 'epel' 2 | 3 | case node['platform'] 4 | when 'amazon' 5 | default['yum']['epel']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 6 | default['yum']['epel']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 7 | default['yum']['epel']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 8 | else 9 | case node['platform_version'].to_i 10 | when 5 11 | default['yum']['epel']['description'] = 'Extra Packages for Enterprise Linux 5 - $basearch' 12 | default['yum']['epel']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch' 13 | default['yum']['epel']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 14 | when 6 15 | default['yum']['epel']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 16 | default['yum']['epel']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 17 | default['yum']['epel']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 18 | when 7 19 | default['yum']['epel']['description'] = 'Extra Packages for Enterprise Linux 7 - $basearch' 20 | default['yum']['epel']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=$basearch' 21 | default['yum']['epel']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7' 22 | end 23 | end 24 | 25 | default['yum']['epel']['failovermethod'] = 'priority' 26 | default['yum']['epel']['gpgcheck'] = true 27 | default['yum']['epel']['enabled'] = true 28 | default['yum']['epel']['managed'] = true 29 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb: -------------------------------------------------------------------------------- 1 | default['yum']['epel-testing-debuginfo']['repositoryid'] = 'epel-testing-debuginfo' 2 | 3 | case node['platform'] 4 | when 'amazon' 5 | default['yum']['epel-testing-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 6 | default['yum']['epel-testing-debuginfo']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 7 | default['yum']['epel-testing-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 8 | else 9 | case node['platform_version'].to_i 10 | when 5 11 | default['yum']['epel-testing-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 5 - Testing - $basearch Debug' 12 | default['yum']['epel-testing-debuginfo']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=testing-debug-epel5&arch=$basearch' 13 | default['yum']['epel-testing-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 14 | when 6 15 | default['yum']['epel-testing-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch Debug' 16 | default['yum']['epel-testing-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel6&arch=$basearch' 17 | default['yum']['epel-testing-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 18 | end 19 | end 20 | 21 | default['yum']['epel-testing-debuginfo']['failovermethod'] = 'priority' 22 | default['yum']['epel-testing-debuginfo']['gpgcheck'] = true 23 | default['yum']['epel-testing-debuginfo']['enabled'] = false 24 | default['yum']['epel-testing-debuginfo']['managed'] = false 25 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/git/README.md: -------------------------------------------------------------------------------- 1 | git Cookbook 2 | ============ 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - git needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### git::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['git']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### git::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `git` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[git]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/ntp/README.md: -------------------------------------------------------------------------------- 1 | ntp Cookbook 2 | ============ 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - ntp needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### ntp::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['ntp']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### ntp::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `ntp` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[ntp]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/user/README.md: -------------------------------------------------------------------------------- 1 | user Cookbook 2 | ============= 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - user needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### user::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['user']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### user::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `user` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[user]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/httpd/README.md: -------------------------------------------------------------------------------- 1 | httpd Cookbook 2 | ============== 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - httpd needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### httpd::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['httpd']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### httpd::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `httpd` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[httpd]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/nginx/README.md: -------------------------------------------------------------------------------- 1 | nginx Cookbook 2 | ============== 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - nginx needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### nginx::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['nginx']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### nginx::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `nginx` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[nginx]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /PART01/CH02/Guardfile: -------------------------------------------------------------------------------- 1 | # A sample Guardfile 2 | # More info at https://github.com/guard/guard#readme 3 | 4 | # Note: The cmd option is now required due to the increasing number of ways 5 | # rspec may be run, below are examples of the most common uses. 6 | # * bundler: 'bundle exec rspec' 7 | # * bundler binstubs: 'bin/rspec' 8 | # * spring: 'bin/rsspec' (This will use spring if running and you have 9 | # installed the spring binstubs per the docs) 10 | # * zeus: 'zeus rspec' (requires the server to be started separetly) 11 | # * 'just' rspec: 'rspec' 12 | guard :rspec, cmd: 'bundle exec rspec' do 13 | watch(%r{^spec/.+_spec\.rb$}) 14 | watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 15 | watch('spec/spec_helper.rb') { "spec" } 16 | 17 | # Rails example 18 | watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } 19 | watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } 20 | watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } 21 | watch(%r{^spec/support/(.+)\.rb$}) { "spec" } 22 | watch('config/routes.rb') { "spec/routing" } 23 | watch('app/controllers/application_controller.rb') { "spec/controllers" } 24 | watch('spec/rails_helper.rb') { "spec" } 25 | 26 | # Capybara features specs 27 | watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } 28 | 29 | # Turnip features and steps 30 | watch(%r{^spec/acceptance/(.+)\.feature$}) 31 | watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } 32 | end 33 | 34 | -------------------------------------------------------------------------------- /PART05/CH18/rails/config/deploy.rb: -------------------------------------------------------------------------------- 1 | set :application, "set your application name here" 2 | set :repository, "set your repository location here" 3 | 4 | set :unicorn_conf, "#{current_path}/config/unicorn/production.rb" 5 | set :unicorn_pid, "#{current_path}/tmp/pids/production.pid" 6 | 7 | # set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names 8 | # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` 9 | 10 | role :web, "your web-server here" # Your HTTP server, Apache/etc 11 | role :app, "your app-server here" # This may be the same as your `Web` server 12 | role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run 13 | role :db, "your slave db-server here" 14 | 15 | # 유니콘의 기동, 종료, 다시 불러오기의 작업을 기술 16 | namespace :unicorn do 17 | task :start, :roles => :app do 18 | run <<-CMD 19 | cd #{current_path}; 20 | BUNDLE_GEMFILE="#{current_path}/Gemfile" bundle exec unicorn_rails -c #{unicorn_conf} -E #{rail_env} -D; 21 | CMD 22 | end 23 | task :stop, :roles => :app do 24 | run "kill `cat #{unicorn_pid}`" 25 | end 26 | task :graceful_stop, :roles => :app do 27 | run "kill -QUIT `cat #{unicorn_pid}`" 28 | end 29 | task :reload, :roles => :app do 30 | run "kill -USR2 `cat #{unicorn_pid}`" 31 | end 32 | task :restart, :roles => :app do 33 | run "kill `cat #{unicorn_pid}`" 34 | run <<-CMD 35 | cd #{current_path}; 36 | BUNDLE_GEMFILE="#{current_path}/Gemfile" bundle exec unicorn_rails -c #{unicorn_conf} -E #{rail_env} -D 37 | CMD 38 | end 39 | end 40 | 41 | # 배포시에 자동으로 유니콘을 기동한다 42 | after "deploy:start", "unicorn:start" 43 | after "deploy:stop", "unicorn:stop" 44 | after "deploy:restart", "unicorn:reload" 45 | 46 | 47 | -------------------------------------------------------------------------------- /PART01/CH01/site-cookbooks/base_packages/README.md: -------------------------------------------------------------------------------- 1 | base_packages Cookbook 2 | ====================== 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - base_packages needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### base_packages::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['base_packages']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### base_packages::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `base_packages` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[base_packages]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/epel-source.rb: -------------------------------------------------------------------------------- 1 | default['yum']['epel-source']['repositoryid'] = 'epel-source' 2 | 3 | case node['platform'] 4 | when 'amazon' 5 | default['yum']['epel-source']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 6 | default['yum']['epel-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 7 | default['yum']['epel-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 8 | else 9 | case node['platform_version'].to_i 10 | when 5 11 | default['yum']['epel-source']['description'] = 'Extra Packages for Enterprise Linux 5 - $basearch - Source' 12 | default['yum']['epel-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch' 13 | default['yum']['epel-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 14 | when 6 15 | default['yum']['epel-source']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch - Source' 16 | default['yum']['epel-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-6&arch=$basearch' 17 | default['yum']['epel-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 18 | when 7 19 | default['yum']['epel-source']['description'] = 'Extra Packages for Enterprise Linux 7 - $basearch - Source' 20 | default['yum']['epel-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-7&arch=$basearch' 21 | default['yum']['epel-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7' 22 | end 23 | end 24 | 25 | default['yum']['epel-source']['failovermethod'] = 'priority' 26 | default['yum']['epel-source']['gpgcheck'] = true 27 | default['yum']['epel-source']['enabled'] = false 28 | default['yum']['epel-source']['managed'] = false 29 | -------------------------------------------------------------------------------- /PART01/CH02/site-cookbooks/ntp/templates/default/ntp.conf.erb: -------------------------------------------------------------------------------- 1 | # For more information about this file, see the man pages 2 | # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). 3 | 4 | driftfile /var/lib/ntp/drift 5 | 6 | # Permit time synchronization with our time source, but do not 7 | # permit the source to query or modify the service on this system. 8 | restrict default kod nomodify notrap nopeer noquery 9 | restrict -6 default kod nomodify notrap nopeer noquery 10 | 11 | # Permit all access over the loopback interface. This could 12 | # be tightened as well, but to do so would effect some of 13 | # the administrative functions. 14 | restrict 127.0.0.1 15 | restrict -6 ::1 16 | 17 | # Hosts on local network are less restricted. 18 | #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 19 | 20 | # Use public servers from the pool.ntp.org project. 21 | # Please consider joining the pool (http://www.pool.ntp.org/join.html). 22 | server ntp.nict.jp 23 | 24 | #broadcast 192.168.1.255 autokey # broadcast server 25 | #broadcastclient # broadcast client 26 | #broadcast 224.0.1.1 autokey # multicast server 27 | #multicastclient 224.0.1.1 # multicast client 28 | #manycastserver 239.255.254.254 # manycast server 29 | #manycastclient 239.255.254.254 autokey # manycast client 30 | 31 | # Enable public key cryptography. 32 | #crypto 33 | 34 | includefile /etc/ntp/crypto/pw 35 | 36 | # Key file containing the keys and key identifiers used when operating 37 | # with symmetric key cryptography. 38 | keys /etc/ntp/keys 39 | 40 | # Specify the key identifiers which are trusted. 41 | #trustedkey 4 8 42 42 | 43 | # Specify the key identifier to use with the ntpdc utility. 44 | #requestkey 8 45 | 46 | # Specify the key identifier to use with the ntpq utility. 47 | #controlkey 8 48 | 49 | # Enable writing of statistics records. 50 | #statistics clockstats cryptostats loopstats peerstats 51 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/attributes/epel-debuginfo.rb: -------------------------------------------------------------------------------- 1 | default['yum']['epel-debuginfo']['repositoryid'] = 'epel-debuginfo' 2 | 3 | case node['platform'] 4 | when 'amazon' 5 | default['yum']['epel-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 6 | default['yum']['epel-debuginfo']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' 7 | default['yum']['epel-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 8 | else 9 | case node['platform_version'].to_i 10 | when 5 11 | default['yum']['epel-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 5 - $basearch - Debug' 12 | default['yum']['epel-debuginfo']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch' 13 | default['yum']['epel-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 14 | when 6 15 | default['yum']['epel-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch - Debug' 16 | default['yum']['epel-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch' 17 | default['yum']['epel-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 18 | when 7 19 | default['yum']['epel-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 7 - $basearch - Debug' 20 | default['yum']['epel-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch' 21 | default['yum']['epel-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7' 22 | end 23 | end 24 | 25 | default['yum']['epel-debuginfo']['failovermethod'] = 'priority' 26 | default['yum']['epel-debuginfo']['gpgcheck'] = true 27 | default['yum']['epel-debuginfo']['enabled'] = false 28 | default['yum']['epel-debuginfo']['managed'] = false 29 | -------------------------------------------------------------------------------- /PART04/CH14/callback.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'webrick' 3 | require 'json' 4 | require 'net/http' 5 | 6 | MARATHON_SERVER = 'mesos1' 7 | MARATHON_PORT = 8080 8 | NGX_CONF_DIR = "/etc/nginx/conf.d" 9 | 10 | def update_nginx_conf(event) 11 | generate_nginx_conf event["appID"] 12 | reload_nginx 13 | end 14 | 15 | def generate_nginx_conf(app) 16 | @erb ||= ERB.new(DATA.read) 17 | servers = fetch_app_servers app 18 | File.open("#{NGX_CONF_DIR}/#{app}.conf", 'w') do |f| 19 | f.puts @erb.result(binding) 20 | end 21 | end 22 | 23 | def fetch_app_servers(app) 24 | apps = JSON.parse( 25 | Net::HTTP.get( 26 | MARATHON_SERVER, "/v2/apps", 27 | MARATHON_PORT)) 28 | unless apps["apps"].any? { |a| a["id"] == app } 29 | return [] 30 | end 31 | app_info = JSON.parse( 32 | Net::HTTP.get( 33 | MARATHON_SERVER, "/v2/apps/#{app}/tasks", 34 | MARATHON_PORT)) 35 | servers = app_info["tasks"].map do |t| 36 | t["host"] + ":" + t["ports"].first.to_s 37 | end 38 | return servers 39 | end 40 | 41 | def reload_nginx 42 | system '/etc/init.d/nginx reload' 43 | end 44 | 45 | def activate(app) 46 | File.open("#{NGX_CONF_DIR}/ii.conf", 'w') do |f| 47 | f.puts < '0.0.0.0', 62 | :Port => 18000, 63 | ) 64 | 65 | server.mount_proc('/callback') do |req, res| 66 | event = JSON.parse req.body 67 | puts event 68 | if event["eventType"] == 'status_update_event' 69 | update_nginx_conf event 70 | end 71 | end 72 | 73 | server.mount_proc('/activate') do |req, res| 74 | app = req.query['app'] || '' 75 | if File.exists? "#{NGX_CONF_DIR}/#{app}.conf" 76 | activate app 77 | end 78 | end 79 | 80 | trap(:INT){server.shutdown} 81 | server.start 82 | 83 | __END__ 84 | <% unless servers.empty? %> 85 | upstream <%= app %> { 86 | <% servers.each do |server| %> 87 | server <%= server %>; 88 | <% end %> 89 | } 90 | <% end %> 91 | -------------------------------------------------------------------------------- /PART01/CH01/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | chef (11.14.6) 5 | chef-zero (~> 2.1, >= 2.1.4) 6 | diff-lcs (~> 1.2, >= 1.2.4) 7 | erubis (~> 2.7) 8 | ffi-yajl (~> 1.0) 9 | highline (~> 1.6, >= 1.6.9) 10 | mime-types (~> 1.16) 11 | mixlib-authentication (~> 1.3) 12 | mixlib-cli (~> 1.4) 13 | mixlib-config (~> 2.0) 14 | mixlib-log (~> 1.3) 15 | mixlib-shellout (~> 1.4) 16 | net-ssh (~> 2.6) 17 | net-ssh-multi (~> 1.1) 18 | ohai (~> 7.2) 19 | plist (~> 3.1.0) 20 | pry (~> 0.9) 21 | rest-client (>= 1.0.4, <= 1.6.7) 22 | chef-zero (2.2) 23 | hashie (~> 2.0) 24 | json 25 | mixlib-log (~> 1.3) 26 | rack 27 | coderay (1.1.0) 28 | diff-lcs (1.2.5) 29 | erubis (2.7.0) 30 | ffi (1.9.3) 31 | ffi-yajl (1.0.2) 32 | ffi (~> 1.5) 33 | libyajl2 (~> 1.0) 34 | hashie (2.1.2) 35 | highline (1.6.21) 36 | ipaddress (0.8.0) 37 | json (1.8.1) 38 | knife-solo (0.4.2) 39 | chef (>= 10.12) 40 | erubis (~> 2.7.0) 41 | net-ssh (>= 2.2.2, < 3.0) 42 | libyajl2 (1.0.1) 43 | method_source (0.8.2) 44 | mime-types (1.25.1) 45 | mixlib-authentication (1.3.0) 46 | mixlib-log 47 | mixlib-cli (1.5.0) 48 | mixlib-config (2.1.0) 49 | mixlib-log (1.6.0) 50 | mixlib-shellout (1.4.0) 51 | net-ssh (2.9.1) 52 | net-ssh-gateway (1.2.0) 53 | net-ssh (>= 2.6.5) 54 | net-ssh-multi (1.2.0) 55 | net-ssh (>= 2.6.5) 56 | net-ssh-gateway (>= 1.2.0) 57 | ohai (7.2.4) 58 | ffi (~> 1.9) 59 | ffi-yajl (~> 1.0) 60 | ipaddress 61 | mime-types (~> 1.16) 62 | mixlib-cli 63 | mixlib-config (~> 2.0) 64 | mixlib-log 65 | mixlib-shellout (~> 1.2) 66 | systemu (~> 2.6.4) 67 | wmi-lite (~> 1.0) 68 | plist (3.1.0) 69 | pry (0.10.1) 70 | coderay (~> 1.1.0) 71 | method_source (~> 0.8.1) 72 | slop (~> 3.4) 73 | rack (1.5.2) 74 | rest-client (1.6.7) 75 | mime-types (>= 1.16) 76 | slop (3.6.0) 77 | systemu (2.6.4) 78 | wmi-lite (1.0.0) 79 | 80 | PLATFORMS 81 | ruby 82 | 83 | DEPENDENCIES 84 | knife-solo 85 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Sean OMeara () 3 | # Recipe:: yum-epel::default 4 | # 5 | # Copyright 2013, Chef 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | node['yum-epel']['repositories'].each do |repo| 20 | 21 | if node['yum'][repo]['managed'] 22 | yum_repository repo do 23 | description node['yum'][repo]['description'] 24 | baseurl node['yum'][repo]['baseurl'] 25 | mirrorlist node['yum'][repo]['mirrorlist'] 26 | gpgcheck node['yum'][repo]['gpgcheck'] 27 | gpgkey node['yum'][repo]['gpgkey'] 28 | enabled node['yum'][repo]['enabled'] 29 | cost node['yum'][repo]['cost'] 30 | exclude node['yum'][repo]['exclude'] 31 | enablegroups node['yum'][repo]['enablegroups'] 32 | failovermethod node['yum'][repo]['failovermethod'] 33 | http_caching node['yum'][repo]['http_caching'] 34 | include_config node['yum'][repo]['include_config'] 35 | includepkgs node['yum'][repo]['includepkgs'] 36 | keepalive node['yum'][repo]['keepalive'] 37 | max_retries node['yum'][repo]['max_retries'] 38 | metadata_expire node['yum'][repo]['metadata_expire'] 39 | mirror_expire node['yum'][repo]['mirror_expire'] 40 | priority node['yum'][repo]['priority'] 41 | proxy node['yum'][repo]['proxy'] 42 | proxy_username node['yum'][repo]['proxy_username'] 43 | proxy_password node['yum'][repo]['proxy_password'] 44 | repositoryid node['yum'][repo]['repositoryid'] 45 | sslcacert node['yum'][repo]['sslcacert'] 46 | sslclientcert node['yum'][repo]['sslclientcert'] 47 | sslclientkey node['yum'][repo]['sslclientkey'] 48 | sslverify node['yum'][repo]['sslverify'] 49 | timeout node['yum'][repo]['timeout'] 50 | action :create 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/templates/default/repo.erb: -------------------------------------------------------------------------------- 1 | # This file was generated by Chef 2 | # Do NOT modify this file by hand. 3 | 4 | [<%= @config.repositoryid %>] 5 | name=<%= @config.description %> 6 | <% if @config.baseurl %> 7 | baseurl=<%= @config.baseurl %> 8 | <% end %> 9 | <% if @config.cost %> 10 | cost=<%= @config.cost %> 11 | <% end %> 12 | <% if @config.enabled %> 13 | enabled=1 14 | <% else %> 15 | enabled=0 16 | <% end %> 17 | <% if @config.enablegroups %> 18 | enablegroups=1 19 | <% end %> 20 | <% if @config.exclude %> 21 | exclude=<%= @config.exclude %> 22 | <% end %> 23 | <% if @config.failovermethod %> 24 | failovermethod=<%= @config.failovermethod %> 25 | <% end %> 26 | <% if @config.fastestmirror_enabled %> 27 | fastestmirror_enabled=<%= @config.fastestmirror_enabled %> 28 | <% end %> 29 | <% if @config.gpgcheck %> 30 | gpgcheck=1 31 | <% else %> 32 | gpgcheck=0 33 | <% end %> 34 | <% if @config.gpgkey %> 35 | gpgkey=<%= case @config.gpgkey 36 | when Array 37 | @config.gpgkey.join("\n ") 38 | else 39 | @config.gpgkey 40 | end %> 41 | <% end -%> 42 | <% if @config.http_caching %> 43 | http_caching=<%= @config.http_caching %> 44 | <% end %> 45 | <% if @config.include_config %> 46 | include=<%= @config.include_config %> 47 | <% end %> 48 | <% if @config.includepkgs %> 49 | includepkgs=<%= @config.includepkgs %> 50 | <% end %> 51 | <% if @config.keepalive %> 52 | keepalive=1 53 | <% end %> 54 | <% if @config.metadata_expire %> 55 | metadata_expire=<%= @config.metadata_expire %> 56 | <% end %> 57 | <% if @config.mirrorlist %> 58 | mirrorlist=<%= @config.mirrorlist %> 59 | <% end %> 60 | <% if @config.mirror_expire %> 61 | mirror_expire=<%= @config.mirror_expire %> 62 | <% end %> 63 | <% if @config.mirrorlist_expire %> 64 | mirrorlist_expire=<%= @config.mirrorlist_expire %> 65 | <% end %> 66 | <% if @config.priority %> 67 | priority=<%= @config.priority %> 68 | <% end %> 69 | <% if @config.proxy %> 70 | proxy=<%= @config.proxy %> 71 | <% end %> 72 | <% if @config.proxy_username %> 73 | proxy_username=<%= @config.proxy_username %> 74 | <% end %> 75 | <% if @config.proxy_password %> 76 | proxy_password=<%= @config.proxy_password %> 77 | <% end %> 78 | <% if @config.username %> 79 | username=<%= @config.username %> 80 | <% end %> 81 | <% if @config.password %> 82 | password=<%= @config.password %> 83 | <% end %> 84 | <% if @config.max_retries %> 85 | retries=<%= @config.max_retries %> 86 | <% end %> 87 | <% if @config.report_instanceid %> 88 | report_instanceid=<%= @config.report_instanceid %> 89 | <% end %> 90 | <% if @config.skip_if_unavailable %> 91 | skip_if_unavailable=1 92 | <% end %> 93 | <% if @config.sslcacert %> 94 | sslcacert=<%= @config.sslcacert %> 95 | <% end %> 96 | <% if @config.sslclientcert %> 97 | sslclientcert=<%= @config.sslclientcert %> 98 | <% end %> 99 | <% if @config.sslclientkey %> 100 | sslclientkey=<%= @config.sslclientkey %> 101 | <% end %> 102 | <% if @config.sslverify %> 103 | sslverify=1 104 | <% else %> 105 | sslverify=0 106 | <% end %> 107 | <% if @config.timeout %> 108 | timeout=<%= @config.timeout %> 109 | <% end %> 110 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/providers/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: yum 3 | # Provider:: repository 4 | # 5 | # Author:: Sean OMeara 6 | # Copyright 2013, Chef 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # In Chef 11 and above, calling the use_inline_resources method will 22 | # make Chef create a new "run_context". When an action is called, any 23 | # nested resources are compiled and converged in isolation from the 24 | # recipe that calls it. 25 | 26 | # Allow for Chef 10 support 27 | use_inline_resources if defined?(use_inline_resources) 28 | 29 | def whyrun_supported? 30 | true 31 | end 32 | 33 | action :create do 34 | # Hack around the lack of "use_inline_resources" before Chef 11 by 35 | # uniquely naming the execute[yum-makecache] resources. Set the 36 | # notifies timing to :immediately for the same reasons. Remove both 37 | # of these when dropping Chef 10 support. 38 | 39 | template "/etc/yum.repos.d/#{new_resource.repositoryid}.repo" do 40 | if new_resource.source.nil? 41 | source 'repo.erb' 42 | cookbook 'yum' 43 | else 44 | source new_resource.source 45 | end 46 | mode '0644' 47 | variables(:config => new_resource) 48 | if new_resource.make_cache 49 | notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately 50 | notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately 51 | end 52 | end 53 | 54 | # get the metadata for this repo only 55 | execute "yum-makecache-#{new_resource.repositoryid}" do 56 | command "yum -q makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}" 57 | action :nothing 58 | end 59 | 60 | # reload internal Chef yum cache 61 | ruby_block "yum-cache-reload-#{new_resource.repositoryid}" do 62 | block { Chef::Provider::Package::Yum::YumCache.instance.reload } 63 | action :nothing 64 | end 65 | end 66 | 67 | action :delete do 68 | file "/etc/yum.repos.d/#{new_resource.repositoryid}.repo" do 69 | action :delete 70 | notifies :run, "execute[yum clean #{new_resource.repositoryid}]", :immediately 71 | notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately 72 | end 73 | 74 | execute "yum clean #{new_resource.repositoryid}" do 75 | command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}" 76 | only_if "yum repolist | grep -P '^#{new_resource.repositoryid}([ \t]|$)'" 77 | action :nothing 78 | end 79 | 80 | ruby_block "yum-cache-reload-#{new_resource.repositoryid}" do 81 | block { Chef::Provider::Package::Yum::YumCache.instance.reload } 82 | action :nothing 83 | end 84 | end 85 | 86 | alias_method :action_add, :action_create 87 | alias_method :action_remove, :action_delete 88 | -------------------------------------------------------------------------------- /PART01/CH02/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | celluloid (0.15.2) 5 | timers (~> 1.1.0) 6 | chef (11.14.6) 7 | chef-zero (~> 2.1, >= 2.1.4) 8 | diff-lcs (~> 1.2, >= 1.2.4) 9 | erubis (~> 2.7) 10 | ffi-yajl (~> 1.0) 11 | highline (~> 1.6, >= 1.6.9) 12 | mime-types (~> 1.16) 13 | mixlib-authentication (~> 1.3) 14 | mixlib-cli (~> 1.4) 15 | mixlib-config (~> 2.0) 16 | mixlib-log (~> 1.3) 17 | mixlib-shellout (~> 1.4) 18 | net-ssh (~> 2.6) 19 | net-ssh-multi (~> 1.1) 20 | ohai (~> 7.2) 21 | plist (~> 3.1.0) 22 | pry (~> 0.9) 23 | rest-client (>= 1.0.4, <= 1.6.7) 24 | chef-zero (2.2) 25 | hashie (~> 2.0) 26 | json 27 | mixlib-log (~> 1.3) 28 | rack 29 | coderay (1.1.0) 30 | diff-lcs (1.2.5) 31 | erubis (2.7.0) 32 | ffi (1.9.3) 33 | ffi-yajl (1.0.2) 34 | ffi (~> 1.5) 35 | libyajl2 (~> 1.0) 36 | formatador (0.2.5) 37 | guard (2.6.1) 38 | formatador (>= 0.2.4) 39 | listen (~> 2.7) 40 | lumberjack (~> 1.0) 41 | pry (>= 0.9.12) 42 | thor (>= 0.18.1) 43 | guard-rspec (4.3.1) 44 | guard (~> 2.1) 45 | rspec (>= 2.14, < 4.0) 46 | hashie (2.1.2) 47 | highline (1.6.21) 48 | ipaddress (0.8.0) 49 | json (1.8.1) 50 | knife-solo (0.4.2) 51 | chef (>= 10.12) 52 | erubis (~> 2.7.0) 53 | net-ssh (>= 2.2.2, < 3.0) 54 | libyajl2 (1.0.1) 55 | listen (2.7.9) 56 | celluloid (>= 0.15.2) 57 | rb-fsevent (>= 0.9.3) 58 | rb-inotify (>= 0.9) 59 | lumberjack (1.0.9) 60 | method_source (0.8.2) 61 | mime-types (1.25.1) 62 | mixlib-authentication (1.3.0) 63 | mixlib-log 64 | mixlib-cli (1.5.0) 65 | mixlib-config (2.1.0) 66 | mixlib-log (1.6.0) 67 | mixlib-shellout (1.4.0) 68 | net-ssh (2.9.1) 69 | net-ssh-gateway (1.2.0) 70 | net-ssh (>= 2.6.5) 71 | net-ssh-multi (1.2.0) 72 | net-ssh (>= 2.6.5) 73 | net-ssh-gateway (>= 1.2.0) 74 | ohai (7.2.4) 75 | ffi (~> 1.9) 76 | ffi-yajl (~> 1.0) 77 | ipaddress 78 | mime-types (~> 1.16) 79 | mixlib-cli 80 | mixlib-config (~> 2.0) 81 | mixlib-log 82 | mixlib-shellout (~> 1.2) 83 | systemu (~> 2.6.4) 84 | wmi-lite (~> 1.0) 85 | plist (3.1.0) 86 | pry (0.10.1) 87 | coderay (~> 1.1.0) 88 | method_source (~> 0.8.1) 89 | slop (~> 3.4) 90 | rack (1.5.2) 91 | rake (10.3.2) 92 | rb-fsevent (0.9.4) 93 | rb-inotify (0.9.5) 94 | ffi (>= 0.5.0) 95 | rest-client (1.6.7) 96 | mime-types (>= 1.16) 97 | rspec (2.99.0) 98 | rspec-core (~> 2.99.0) 99 | rspec-expectations (~> 2.99.0) 100 | rspec-mocks (~> 2.99.0) 101 | rspec-core (2.99.2) 102 | rspec-expectations (2.99.2) 103 | diff-lcs (>= 1.1.3, < 2.0) 104 | rspec-its (1.0.1) 105 | rspec-core (>= 2.99.0.beta1) 106 | rspec-expectations (>= 2.99.0.beta1) 107 | rspec-mocks (2.99.2) 108 | serverspec (1.14.0) 109 | highline 110 | net-ssh 111 | rspec (~> 2.99) 112 | rspec-its 113 | specinfra (~> 1.25) 114 | slop (3.6.0) 115 | specinfra (1.25.6) 116 | systemu (2.6.4) 117 | thor (0.19.1) 118 | timers (1.1.0) 119 | wmi-lite (1.0.0) 120 | 121 | PLATFORMS 122 | ruby 123 | 124 | DEPENDENCIES 125 | guard 126 | guard-rspec 127 | knife-solo 128 | rake 129 | serverspec 130 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/resources/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: yum 3 | # Resource:: repository 4 | # 5 | # Author:: Sean OMeara 6 | # Copyright 2013, Chef 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | actions :create, :delete, :add, :remove 22 | 23 | default_action :create 24 | 25 | # http://linux.die.net/man/5/yum.conf 26 | attribute :baseurl, :kind_of => String, :regex => /.*/, :default => nil 27 | attribute :cost, :kind_of => String, :regex => /^\d+$/, :default => nil 28 | attribute :description, :kind_of => String, :regex => /.*/, :default => 'Ye Ole Rpm Repo' 29 | attribute :enabled, :kind_of => [TrueClass, FalseClass], :default => true 30 | attribute :enablegroups, :kind_of => [TrueClass, FalseClass], :default => nil 31 | attribute :exclude, :kind_of => String, :regex => /.*/, :default => nil 32 | attribute :failovermethod, :kind_of => String, :equal_to => %w(priority roundrobin), :default => nil 33 | attribute :fastestmirror_enabled, :kind_of => [TrueClass, FalseClass], :default => nil 34 | attribute :gpgcheck, :kind_of => [TrueClass, FalseClass], :default => true 35 | attribute :gpgkey, :kind_of => [String, Array], :regex => /.*/, :default => nil 36 | attribute :http_caching, :kind_of => String, :equal_to => %w(packages all none), :default => nil 37 | attribute :include_config, :kind_of => String, :regex => /.*/, :default => nil 38 | attribute :includepkgs, :kind_of => String, :regex => /.*/, :default => nil 39 | attribute :keepalive, :kind_of => [TrueClass, FalseClass], :default => nil 40 | attribute :make_cache, :kind_of => [TrueClass, FalseClass], :default => true 41 | attribute :max_retries, :kind_of => String, :regex => /.*/, :default => nil 42 | attribute :metadata_expire, :kind_of => String, :regex => [/^\d+$/, /^\d+[mhd]$/, /never/], :default => nil 43 | attribute :mirrorexpire, :kind_of => String, :regex => /.*/, :default => nil 44 | attribute :mirrorlist, :kind_of => String, :regex => /.*/, :default => nil 45 | attribute :mirror_expire, :kind_of => String, :regex => /^\d+$/, :default => nil 46 | attribute :mirrorlist_expire, :kind_of => String, :regex => /^\d+$/, :default => nil 47 | attribute :priority, :kind_of => String, :regex => /^(\d?[0-9]|[0-9][0-9])$/, :default => nil 48 | attribute :proxy, :kind_of => String, :regex => /.*/, :default => nil 49 | attribute :proxy_username, :kind_of => String, :regex => /.*/, :default => nil 50 | attribute :proxy_password, :kind_of => String, :regex => /.*/, :default => nil 51 | attribute :username, :kind_of => String, :regex => /.*/, :default => nil 52 | attribute :password, :kind_of => String, :regex => /.*/, :default => nil 53 | attribute :report_instanceid, :kind_of => [TrueClass, FalseClass], :default => nil 54 | attribute :repositoryid, :kind_of => String, :regex => /.*/, :name_attribute => true 55 | attribute :skip_if_unavailable, :kind_of => [TrueClass, FalseClass], :default => nil 56 | attribute :source, :kind_of => String, :regex => /.*/, :default => nil 57 | attribute :sslcacert, :kind_of => String, :regex => /.*/, :default => nil 58 | attribute :sslclientcert, :kind_of => String, :regex => /.*/, :default => nil 59 | attribute :sslclientkey, :kind_of => String, :regex => /.*/, :default => nil 60 | attribute :sslverify, :kind_of => [TrueClass, FalseClass], :default => true 61 | attribute :timeout, :kind_of => String, :regex => /^\d+$/, :default => nil 62 | 63 | alias_method :url, :baseurl 64 | alias_method :keyurl, :gpgkey 65 | -------------------------------------------------------------------------------- /PART01/CH01/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | # All Vagrant configuration is done here. The most common configuration 9 | # options are documented and commented below. For a complete reference, 10 | # please see the online documentation at vagrantup.com. 11 | 12 | # Every Vagrant virtual environment requires a box to build off of. 13 | config.vm.box = "opscode-centos-6.5" 14 | 15 | # Disable automatic box update checking. If you disable this, then 16 | # boxes will only be checked for updates when the user runs 17 | # `vagrant box outdated`. This is not recommended. 18 | # config.vm.box_check_update = false 19 | 20 | # Create a forwarded port mapping which allows access to a specific port 21 | # within the machine from a port on the host machine. In the example below, 22 | # accessing "localhost:8080" will access port 80 on the guest machine. 23 | # config.vm.network "forwarded_port", guest: 80, host: 8080 24 | 25 | # Create a private network, which allows host-only access to the machine 26 | # using a specific IP. 27 | config.vm.network "private_network", ip: "192.168.33.10" 28 | 29 | # Create a public network, which generally matched to bridged network. 30 | # Bridged networks make the machine appear as another physical device on 31 | # your network. 32 | # config.vm.network "public_network" 33 | 34 | # If true, then any SSH connections made will enable agent forwarding. 35 | # Default value: false 36 | # config.ssh.forward_agent = true 37 | 38 | # Share an additional folder to the guest VM. The first argument is 39 | # the path on the host to the actual folder. The second argument is 40 | # the path on the guest to mount the folder. And the optional third 41 | # argument is a set of non-required options. 42 | # config.vm.synced_folder "../data", "/vagrant_data" 43 | 44 | # Provider-specific configuration so you can fine-tune various 45 | # backing providers for Vagrant. These expose provider-specific options. 46 | # Example for VirtualBox: 47 | # 48 | # config.vm.provider "virtualbox" do |vb| 49 | # # Don't boot with headless mode 50 | # vb.gui = true 51 | # 52 | # # Use VBoxManage to customize the VM. For example to change memory: 53 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 54 | # end 55 | # 56 | # View the documentation for the provider you're using for more 57 | # information on available options. 58 | 59 | # Enable provisioning with CFEngine. CFEngine Community packages are 60 | # automatically installed. For example, configure the host as a 61 | # policy server and optionally a policy file to run: 62 | # 63 | # config.vm.provision "cfengine" do |cf| 64 | # cf.am_policy_hub = true 65 | # # cf.run_file = "motd.cf" 66 | # end 67 | # 68 | # You can also configure and bootstrap a client to an existing 69 | # policy server: 70 | # 71 | # config.vm.provision "cfengine" do |cf| 72 | # cf.policy_server_address = "10.0.2.15" 73 | # end 74 | 75 | # Enable provisioning with Puppet stand alone. Puppet manifests 76 | # are contained in a directory path relative to this Vagrantfile. 77 | # You will need to create the manifests directory and a manifest in 78 | # the file default.pp in the manifests_path directory. 79 | # 80 | # config.vm.provision "puppet" do |puppet| 81 | # puppet.manifests_path = "manifests" 82 | # puppet.manifest_file = "site.pp" 83 | # end 84 | 85 | # Enable provisioning with chef solo, specifying a cookbooks path, roles 86 | # path, and data_bags path (all relative to this Vagrantfile), and adding 87 | # some recipes and/or roles. 88 | # 89 | # config.vm.provision "chef_solo" do |chef| 90 | # chef.cookbooks_path = "../my-recipes/cookbooks" 91 | # chef.roles_path = "../my-recipes/roles" 92 | # chef.data_bags_path = "../my-recipes/data_bags" 93 | # chef.add_recipe "mysql" 94 | # chef.add_role "web" 95 | # 96 | # # You may also specify custom JSON attributes: 97 | # chef.json = { mysql_password: "foo" } 98 | # end 99 | 100 | # Enable provisioning with chef server, specifying the chef server URL, 101 | # and the path to the validation key (relative to this Vagrantfile). 102 | # 103 | # The Opscode Platform uses HTTPS. Substitute your organization for 104 | # ORGNAME in the URL and validation key. 105 | # 106 | # If you have your own Chef Server, use the appropriate URL, which may be 107 | # HTTP instead of HTTPS depending on your configuration. Also change the 108 | # validation key to validation.pem. 109 | # 110 | # config.vm.provision "chef_client" do |chef| 111 | # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" 112 | # chef.validation_key_path = "ORGNAME-validator.pem" 113 | # end 114 | # 115 | # If you're using the Opscode platform, your validator client is 116 | # ORGNAME-validator, replacing ORGNAME with your organization name. 117 | # 118 | # If you have your own Chef Server, the default validation client name is 119 | # chef-validator, unless you changed the configuration. 120 | # 121 | # chef.validation_client_name = "ORGNAME-validator" 122 | end 123 | -------------------------------------------------------------------------------- /PART01/CH02/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | # All Vagrant configuration is done here. The most common configuration 9 | # options are documented and commented below. For a complete reference, 10 | # please see the online documentation at vagrantup.com. 11 | 12 | # Every Vagrant virtual environment requires a box to build off of. 13 | config.vm.box = "opscode-centos-6.5" 14 | 15 | # Disable automatic box update checking. If you disable this, then 16 | # boxes will only be checked for updates when the user runs 17 | # `vagrant box outdated`. This is not recommended. 18 | # config.vm.box_check_update = false 19 | 20 | # Create a forwarded port mapping which allows access to a specific port 21 | # within the machine from a port on the host machine. In the example below, 22 | # accessing "localhost:8080" will access port 80 on the guest machine. 23 | # config.vm.network "forwarded_port", guest: 80, host: 8080 24 | 25 | # Create a private network, which allows host-only access to the machine 26 | # using a specific IP. 27 | # config.vm.network "private_network", ip: "192.168.33.10" 28 | 29 | # Create a public network, which generally matched to bridged network. 30 | # Bridged networks make the machine appear as another physical device on 31 | # your network. 32 | # config.vm.network "public_network" 33 | 34 | # If true, then any SSH connections made will enable agent forwarding. 35 | # Default value: false 36 | # config.ssh.forward_agent = true 37 | 38 | # Share an additional folder to the guest VM. The first argument is 39 | # the path on the host to the actual folder. The second argument is 40 | # the path on the guest to mount the folder. And the optional third 41 | # argument is a set of non-required options. 42 | # config.vm.synced_folder "../data", "/vagrant_data" 43 | 44 | # Provider-specific configuration so you can fine-tune various 45 | # backing providers for Vagrant. These expose provider-specific options. 46 | # Example for VirtualBox: 47 | # 48 | # config.vm.provider "virtualbox" do |vb| 49 | # # Don't boot with headless mode 50 | # vb.gui = true 51 | # 52 | # # Use VBoxManage to customize the VM. For example to change memory: 53 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 54 | # end 55 | # 56 | # View the documentation for the provider you're using for more 57 | # information on available options. 58 | 59 | # Enable provisioning with CFEngine. CFEngine Community packages are 60 | # automatically installed. For example, configure the host as a 61 | # policy server and optionally a policy file to run: 62 | # 63 | # config.vm.provision "cfengine" do |cf| 64 | # cf.am_policy_hub = true 65 | # # cf.run_file = "motd.cf" 66 | # end 67 | # 68 | # You can also configure and bootstrap a client to an existing 69 | # policy server: 70 | # 71 | # config.vm.provision "cfengine" do |cf| 72 | # cf.policy_server_address = "10.0.2.15" 73 | # end 74 | 75 | # Enable provisioning with Puppet stand alone. Puppet manifests 76 | # are contained in a directory path relative to this Vagrantfile. 77 | # You will need to create the manifests directory and a manifest in 78 | # the file default.pp in the manifests_path directory. 79 | # 80 | # config.vm.provision "puppet" do |puppet| 81 | # puppet.manifests_path = "manifests" 82 | # puppet.manifest_file = "site.pp" 83 | # end 84 | 85 | # Enable provisioning with chef solo, specifying a cookbooks path, roles 86 | # path, and data_bags path (all relative to this Vagrantfile), and adding 87 | # some recipes and/or roles. 88 | # 89 | # config.vm.provision "chef_solo" do |chef| 90 | # chef.cookbooks_path = "../my-recipes/cookbooks" 91 | # chef.roles_path = "../my-recipes/roles" 92 | # chef.data_bags_path = "../my-recipes/data_bags" 93 | # chef.add_recipe "mysql" 94 | # chef.add_role "web" 95 | # 96 | # # You may also specify custom JSON attributes: 97 | # chef.json = { mysql_password: "foo" } 98 | # end 99 | 100 | # Enable provisioning with chef server, specifying the chef server URL, 101 | # and the path to the validation key (relative to this Vagrantfile). 102 | # 103 | # The Opscode Platform uses HTTPS. Substitute your organization for 104 | # ORGNAME in the URL and validation key. 105 | # 106 | # If you have your own Chef Server, use the appropriate URL, which may be 107 | # HTTP instead of HTTPS depending on your configuration. Also change the 108 | # validation key to validation.pem. 109 | # 110 | # config.vm.provision "chef_client" do |chef| 111 | # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" 112 | # chef.validation_key_path = "ORGNAME-validator.pem" 113 | # end 114 | # 115 | # If you're using the Opscode platform, your validator client is 116 | # ORGNAME-validator, replacing ORGNAME with your organization name. 117 | # 118 | # If you have your own Chef Server, the default validation client name is 119 | # chef-validator, unless you changed the configuration. 120 | # 121 | # chef.validation_client_name = "ORGNAME-validator" 122 | end 123 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/attributes/main.rb: -------------------------------------------------------------------------------- 1 | # http://linux.die.net/man/5/yum.conf 2 | case node['platform_version'].to_i 3 | when 5 4 | default['yum']['main']['cachedir'] = '/var/cache/yum' 5 | else 6 | default['yum']['main']['cachedir'] = '/var/cache/yum/$basearch/$releasever' 7 | end 8 | 9 | case node['platform'] 10 | when 'amazon' 11 | default['yum']['main']['distroverpkg'] = 'system-release' 12 | when 'scientific' 13 | default['yum']['main']['distroverpkg'] = 'sl-release' 14 | else 15 | default['yum']['main']['distroverpkg'] = "#{node['platform']}-release" 16 | end 17 | 18 | default['yum']['main']['alwaysprompt'] = nil # [TrueClass, FalseClass] 19 | default['yum']['main']['assumeyes'] = nil # [TrueClass, FalseClass] 20 | default['yum']['main']['bandwidth'] = nil # /^\d+$/ 21 | default['yum']['main']['bugtracker_url'] = nil # /.*/ 22 | default['yum']['main']['clean_requirements_on_remove'] = nil # [TrueClass, FalseClass] 23 | default['yum']['main']['color'] = nil # %w{ always never } 24 | default['yum']['main']['color_list_available_downgrade'] = nil # /.*/ 25 | default['yum']['main']['color_list_available_install'] = nil # /.*/ 26 | default['yum']['main']['color_list_available_reinstall'] = nil # /.*/ 27 | default['yum']['main']['color_list_available_upgrade'] = nil # /.*/ 28 | default['yum']['main']['color_list_installed_extra'] = nil # /.*/ 29 | default['yum']['main']['color_list_installed_newer'] = nil # /.*/ 30 | default['yum']['main']['color_list_installed_older'] = nil # /.*/ 31 | default['yum']['main']['color_list_installed_reinstall'] = nil # /.*/ 32 | default['yum']['main']['color_search_match'] = nil # /.*/ 33 | default['yum']['main']['color_update_installed'] = nil # /.*/ 34 | default['yum']['main']['color_update_local'] = nil # /.*/ 35 | default['yum']['main']['color_update_remote'] = nil # /.*/ 36 | default['yum']['main']['commands'] = nil # /.*/ 37 | default['yum']['main']['debuglevel'] = nil # /^\d+$/ 38 | default['yum']['main']['diskspacecheck'] = nil # [TrueClass, FalseClass] 39 | default['yum']['main']['enable_group_conditionals'] = nil # [TrueClass, FalseClass] 40 | default['yum']['main']['errorlevel'] = nil # /^\d+$/ 41 | default['yum']['main']['exactarch'] = nil # [TrueClass, FalseClass] 42 | default['yum']['main']['exclude'] = nil # /.*/ 43 | default['yum']['main']['gpgcheck'] = true # [TrueClass, FalseClass] 44 | default['yum']['main']['group_package_types'] = nil # /.*/ 45 | default['yum']['main']['groupremove_leaf_only'] = nil # [TrueClass, FalseClass] 46 | default['yum']['main']['history_list_view'] = nil # /.*/ 47 | default['yum']['main']['history_record'] = nil # [TrueClass, FalseClass] 48 | default['yum']['main']['history_record_packages'] = nil # /.*/ 49 | default['yum']['main']['http_caching'] = nil # %w{ packages all none } 50 | default['yum']['main']['installonly_limit'] = nil # /\d+/, /keep/ 51 | default['yum']['main']['installonlypkgs'] = nil # /.*/ 52 | default['yum']['main']['installroot'] = nil # /.*/ 53 | default['yum']['main']['keepalive'] = nil # [TrueClass, FalseClass] 54 | default['yum']['main']['keepcache'] = false # [TrueClass, FalseClass] 55 | default['yum']['main']['kernelpkgnames'] = nil # /.*/ 56 | default['yum']['main']['localpkg_gpgcheck'] = nil # [TrueClass,# FalseClass] 57 | default['yum']['main']['logfile'] = '/var/log/yum.log' # /.*/ 58 | default['yum']['main']['max_retries'] = nil # /^\d+$/ 59 | default['yum']['main']['mdpolicy'] = nil # %w{ packages all none } 60 | default['yum']['main']['metadata_expire'] = nil # /^\d+$/ 61 | default['yum']['main']['mirrorlist_expire'] = nil # /^\d+$/ 62 | default['yum']['main']['multilib_policy'] = nil # %w{ all best } 63 | default['yum']['main']['obsoletes'] = nil # [TrueClass, FalseClass] 64 | default['yum']['main']['overwrite_groups'] = nil # [TrueClass, FalseClass] 65 | default['yum']['main']['password'] = nil # /.*/ 66 | default['yum']['main']['path'] = '/etc/yum.conf' # /.*/ 67 | default['yum']['main']['persistdir'] = nil # /.*/ 68 | default['yum']['main']['pluginconfpath'] = nil # /.*/ 69 | default['yum']['main']['pluginpath'] = nil # /.*/ 70 | default['yum']['main']['plugins'] = nil # [TrueClass, FalseClass] 71 | default['yum']['main']['protected_multilib'] = nil # /.*/ 72 | default['yum']['main']['protected_packages'] = nil # /.*/ 73 | default['yum']['main']['proxy'] = nil # /.*/ 74 | default['yum']['main']['proxy_password'] = nil # /.*/ 75 | default['yum']['main']['proxy_username'] = nil # /.*/ 76 | default['yum']['main']['username'] = nil # /.*/ 77 | default['yum']['main']['password'] = nil # /.*/ 78 | default['yum']['main']['recent'] = nil # /^\d+$/ 79 | default['yum']['main']['releasever'] = nil # /.*/ 80 | default['yum']['main']['repo_gpgcheck'] = nil # [TrueClass, FalseClass] 81 | default['yum']['main']['reset_nice'] = nil # [TrueClass, FalseClass] 82 | default['yum']['main']['rpmverbosity'] = nil # %w{ info critical# emergency error warn debug } 83 | default['yum']['main']['showdupesfromrepos'] = nil # [TrueClass, FalseClass] 84 | default['yum']['main']['skip_broken'] = nil # [TrueClass, FalseClass] 85 | default['yum']['main']['ssl_check_cert_permissions'] = nil # [TrueClass, FalseClass] 86 | default['yum']['main']['sslcacert'] = nil # /.*/ 87 | default['yum']['main']['sslclientcert'] = nil # /.*/ 88 | default['yum']['main']['sslclientkey'] = nil # /.*/ 89 | default['yum']['main']['sslverify'] = nil # [TrueClass, FalseClass] 90 | default['yum']['main']['syslog_device'] = nil # /.*/ 91 | default['yum']['main']['syslog_facility'] = nil # /.*/ 92 | default['yum']['main']['syslog_ident'] = nil # /.*/ 93 | default['yum']['main']['throttle'] = nil # [/\d+k/, /\d+M/, /\d+G/] 94 | default['yum']['main']['timeout'] = nil # /\d+/ 95 | default['yum']['main']['tolerant'] = false 96 | default['yum']['main']['tsflags'] = nil # /.*/ 97 | default['yum']['main']['username'] = nil # /.*/ 98 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yum-epel", 3 | "version": "0.4.0", 4 | "description": "Installs/Configures yum-epel", 5 | "long_description": "yum-epel Cookbook\n============\n\nThe yum-epel cookbook takes over management of the default\nrepositoryids shipped with epel-release. It allows attribute\nmanipulation of `epel`, `epel-debuginfo`, `epel-source`, `epel-testing`,\n`epel-testing-debuginfo`, and `epel-testing-source`.\n\nRequirements\n------------\n* Chef 11 or higher\n* yum cookbook version 3.0.0 or higher\n\nAttributes\n----------\nThe following attributes are set by default\n\n``` ruby\ndefault['yum-epel']['repositories'] = %w{epel epel-debuginfo epel-source epel-testing epel-testing-debuginfo epel-testing-source}\n```\n\n``` ruby\ndefault['yum']['epel']['repositoryid'] = 'epel'\ndefault['yum']['epel']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch'\ndefault['yum']['epel']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch'\ndefault['yum']['epel']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6'\ndefault['yum']['epel']['failovermethod'] = 'priority'\ndefault['yum']['epel']['gpgcheck'] = true\ndefault['yum']['epel']['enabled'] = true\ndefault['yum']['epel']['managed'] = true\n```\n\n``` ruby\ndefault['yum']['epel-debuginfo']['repositoryid'] = 'epel-debuginfo'\ndefault['yum']['epel-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch - Debug'\ndefault['yum']['epel-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch'\ndefault['yum']['epel-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6'\ndefault['yum']['epel-debuginfo']['failovermethod'] = 'priority'\ndefault['yum']['epel-debuginfo']['gpgcheck'] = true\ndefault['yum']['epel-debuginfo']['enabled'] = false\ndefault['yum']['epel-debuginfo']['managed'] = false\n```\n\n``` ruby\ndefault['yum']['epel-source']['repositoryid'] = 'epel-source'\ndefault['yum']['epel-source']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch - Source'\ndefault['yum']['epel-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-6&arch=$basearch'\ndefault['yum']['epel-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6'\ndefault['yum']['epel-source']['failovermethod'] = 'priority'\ndefault['yum']['epel-source']['gpgcheck'] = true\ndefault['yum']['epel-source']['enabled'] = false\ndefault['yum']['epel-source']['managed'] = false\n```\n\n``` ruby\ndefault['yum']['epel-testing']['repositoryid'] = 'epel-testing'\ndefault['yum']['epel-testing']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch'\ndefault['yum']['epel-testing']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-epel6&arch=$basearch'\ndefault['yum']['epel-testing']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6r'\ndefault['yum']['epel-testing']['failovermethod'] = 'priority'\ndefault['yum']['epel-testing']['gpgcheck'] = true\ndefault['yum']['epel-testing']['enabled'] = false\ndefault['yum']['epel-testing']['managed'] = false\n```\n\n``` ruby\ndefault['yum']['epel-testing-debuginfo']['repositoryid'] = 'epel-testing-debuginfo'\ndefault['yum']['epel-testing-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch Debug'\ndefault['yum']['epel-testing-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel6&arch=$basearch'\ndefault['yum']['epel-testing-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6'\ndefault['yum']['epel-testing-debuginfo']['failovermethod'] = 'priority'\ndefault['yum']['epel-testing-debuginfo']['gpgcheck'] = true\ndefault['yum']['epel-testing-debuginfo']['enabled'] = false\ndefault['yum']['epel-testing-debuginfo']['managed'] = false\n```\n\n``` ruby\ndefault['yum']['epel-testing-source']['repositoryid'] = 'epel-testing-source'\ndefault['yum']['epel-testing-source']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch Source'\ndefault['yum']['epel-testing-source']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel6&arch=$basearch'\ndefault['yum']['epel-testing-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6'\ndefault['yum']['epel-testing-source']['failovermethod'] = 'priority'\ndefault['yum']['epel-testing-source']['gpgcheck'] = true\ndefault['yum']['epel-testing-source']['enabled'] = false\ndefault['yum']['epel-testing-source']['managed'] = false\n```\n\nRecipes\n-------\n* default - Walks through node attributes and feeds a yum_resource\n parameters. The following is an example a resource generated by the\n recipe during compilation.\n\n```ruby\n yum_repository 'epel' do\n mirrorlist 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch'\n description 'Extra Packages for Enterprise Linux 5 - $basearch'\n enabled true\n gpgcheck true\n gpgkey 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL'\n end\n```\n\nUsage Example\n-------------\nTo disable the epel repository through a Role or Environment definition\n\n```\ndefault_attributes(\n :yum => {\n :epel => {\n :enabled => {\n false\n }\n }\n }\n )\n```\n\nUncommonly used repositoryids are not managed by default. This is\nspeeds up integration testing pipelines by avoiding yum-cache builds\nthat nobody cares about. To enable the epel-testing repository with a\nwrapper cookbook, place the following in a recipe:\n\n```\nnode.default['yum']['epel-testing']['enabled'] = true\nnode.default['yum']['epel-testing']['managed'] = true\ninclude_recipe 'yum-epel'\n```\n\nMore Examples\n-------------\nPoint the epel repositories at an internally hosted server.\n\n```\nnode.default['yum']['epel']['enabled'] = true\nnode.default['yum']['epel']['mirrorlist'] = nil\nnode.default['yum']['epel']['baseurl'] = 'https://internal.example.com/centos/6/os/x86_64'\nnode.default['yum']['epel']['sslverify'] = false\n\ninclude_recipe 'yum-epel'\n```\n\nLicense & Authors\n-----------------\n- Author:: Sean OMeara ()\n\n```text\nCopyright:: 2011-2013 Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n", 6 | "maintainer": "Chef", 7 | "maintainer_email": "Sean OMeara ", 8 | "license": "Apache 2.0", 9 | "platforms": { 10 | }, 11 | "dependencies": { 12 | "yum": "~> 3.0" 13 | }, 14 | "recommendations": { 15 | }, 16 | "suggestions": { 17 | }, 18 | "conflicting": { 19 | }, 20 | "providing": { 21 | }, 22 | "replacing": { 23 | }, 24 | "attributes": { 25 | }, 26 | "groupings": { 27 | }, 28 | "recipes": { 29 | } 30 | } -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | yum Cookbook CHANGELOG 2 | ====================== 3 | This file is used to list changes made in each version of the yum cookbook. 4 | 5 | v3.2.4 (2014-08-20) 6 | ------------------- 7 | #82 - Adding a makecache parameter 8 | 9 | v3.2.2 (2014-06-11) 10 | ------------------- 11 | #77 - Parameter default to be Trueclass instead of "1" 12 | #78 - add releasever parameter 13 | 14 | 15 | v3.2.0 (2014-04-09) 16 | ------------------- 17 | - [COOK-4510] - Adding username and password parameters to node attributes 18 | - [COOK-4518] - Fix Scientific Linux distroverpkg 19 | 20 | 21 | v3.1.6 (2014-03-27) 22 | ------------------- 23 | - [COOK-4463] - support multiple GPG keys 24 | - [COOK-4364] - yum_repository delete action fails 25 | 26 | 27 | v3.1.4 (2014-03-12) 28 | ------------------- 29 | - [COOK-4417] Expand test harness to encompass 32-bit boxes 30 | 31 | 32 | v3.1.2 (2014-02-23) 33 | ------------------- 34 | Fixing bugs around :delete action and cache clean 35 | Fixing specs to cover :remove and :delete aliasing properly 36 | Adding Travis-ci build matrix bits 37 | 38 | 39 | v3.1.0 (2014-02-13) 40 | ------------------- 41 | - Updating testing harness for integration testing on Travis-ci 42 | - Adding TESTING.md and Guardfile 43 | - PR #67 - Add skip_if_unvailable repository option 44 | - PR #64 - Fix validation of 'metadata_expire' option to match documentation 45 | - [COOK-3591] - removing node.name from repo template rendering 46 | - [COOK-4275] - Enhancements to yum cookbook 47 | - Adding full spec coverage 48 | - Adding support for custom source template to yum_repository 49 | 50 | 51 | v3.0.8 (2014-01-27) 52 | ------------------- 53 | Fixing typo in default.rb. yum_globalconfig now passes proxy attribute correctly. 54 | 55 | 56 | v3.0.6 (2014-01-27) 57 | ------------------- 58 | Updating default.rb to consume node['yum']['main']['proxy'] 59 | 60 | 61 | v3.0.4 (2013-12-29) 62 | ------------------- 63 | ### Bug 64 | - **[COOK-4156](https://tickets.opscode.com/browse/COOK-4156)** - yum cookbook creates a yum.conf with "cachefir" directive 65 | 66 | 67 | v3.0.2 68 | ------ 69 | Updating globalconfig provider for Chef 10 compatability 70 | 71 | 72 | v3.0.0 73 | ------ 74 | 3.0.0 75 | Major rewrite with breaking changes. 76 | Recipes broken out into individual cookbooks 77 | yum_key resource has been removed 78 | yum_repository resource now takes gpgkey as a URL directly 79 | yum_repository actions have been reduced to :create and :delete 80 | 'name' has been changed to repositoryid to avoid ambiguity 81 | chefspec test coverage 82 | gpgcheck is set to 'true' by default and must be explicitly disabled 83 | 84 | 85 | v2.4.4 86 | ------ 87 | Reverting to Ruby 1.8 hash syntax. 88 | 89 | 90 | v2.4.2 91 | ------ 92 | [COOK-3275] LWRP repository.rb :add method fails to create yum repo in 93 | some cases which causes :update to fail Amazon rhel 94 | 95 | 96 | v2.4.0 97 | ------ 98 | ### Improvement 99 | - [COOK-3025] - Allow per-repo proxy definitions 100 | 101 | 102 | v2.3.4 103 | ------ 104 | ### Improvement 105 | - **[COOK-3689](https://tickets.opscode.com/browse/COOK-3689)** - Fix warnings about resource cloning 106 | - **[COOK-3574](https://tickets.opscode.com/browse/COOK-3574)** - Add missing "description" field in metadata 107 | 108 | 109 | v2.3.2 110 | ------ 111 | ### Bug 112 | - **[COOK-3145](https://tickets.opscode.com/browse/COOK-3145)** - Use correct download URL for epel `key_url` 113 | 114 | v2.3.0 115 | ------ 116 | ### New Feature 117 | - [COOK-2924]: Yum should allow type setting in repo file 118 | 119 | v2.2.4 120 | ------ 121 | ### Bug 122 | - [COOK-2360]: last commit to `yum_repository` changes previous behaviour 123 | - [COOK-3015]: Yum cookbook test minitest to fail 124 | 125 | v2.2.2 126 | ------ 127 | ### Improvement 128 | - [COOK-2741]: yum::elrepo 129 | - [COOK-2946]: update tests, test kitchen support in yum cookbook 130 | 131 | ### Bug 132 | - [COOK-2639]: Yum cookbook - epel - always assumes url is a mirror list 133 | - [COOK-2663]: Yum should allow metadata_expire setting in repo file 134 | - [COOK-2751]: Update yum.ius_release version to 1.0-11 135 | 136 | v2.2.0 137 | ------ 138 | - [COOK-2189] - yum::ius failed on install (caused from rpm dependency) 139 | - [COOK-2196] - Make includepkgs and exclude configurable for each repos 140 | - [COOK-2244] - Allow configuring caching using attributes 141 | - [COOK-2399] - yum cookbook LWRPs fail FoodCritic 142 | - [COOK-2519] - Add priority option to Yum repo files 143 | - [COOK-2593] - allow integer or string for yum priority 144 | - [COOK-2643] - don't use conditional attribute for `yum_key` `remote_file` 145 | 146 | v2.1.0 147 | ------ 148 | - [COOK-2045] - add remi repository recipe 149 | - [COOK-2121] - add `:create` action to `yum_repository` 150 | 151 | v2.0.6 152 | ------ 153 | - [COOK-2037] - minor style fixes 154 | - [COOK-2038] - updated README 155 | 156 | v2.0.4 157 | ------ 158 | - [COOK-1908] - unable to install repoforge on CentOS 6 32 bit 159 | 160 | v2.0.2 161 | ------ 162 | - [COOK-1758] - Add default action for repository resource 163 | 164 | v2.0.0 165 | ------ 166 | This version changes the behavior of the EPEL recipe (most commonly used in other Chef cookbooks) on Amazon, and removes an attribute, `node['yum']['epel_release']`. See the README for details. 167 | 168 | - [COOK-1772] - Simplify management of EPEL with LWRP 169 | 170 | v1.0.0 171 | ------ 172 | `mirrorlist` in the `yum_repository` LWRP must be set to the mirror list URI to use rather than setting it to true. See README.md. 173 | 174 | - [COOK-1088] - use dl.fedoraproject.org for EPEL to prevent redirects 175 | - [COOK-1653] - fix mirrorlist 176 | - [COOK-1710] - support http proxy 177 | - [COOK-1722] - update IUS version 178 | 179 | v0.8.2 180 | ------ 181 | - [COOK-1521] - add :update action to `yum_repository` 182 | 183 | v0.8.0 184 | ------ 185 | - [COOK-1204] - Make 'add' default action for yum_repository 186 | - [COOK-1351] - option to not make the yum cache (via attribute) 187 | - [COOK-1353] - x86_64 centos path fixes 188 | - [COOK-1414] - recipe for repoforge 189 | 190 | v0.6.2 191 | ------ 192 | - Updated README to remove git diff artifacts. 193 | 194 | v0.6.0 195 | ------ 196 | - Default action for the yum_repository LWRP is now add. 197 | - [COOK-1227] - clear Chefs internal cache after adding new yum repo 198 | - [COOK-1262] - yum::epel should enable existing repo on Amazon Linux 199 | - [COOK-1272], [COOK-1302] - update RPM file for CentOS / RHEL 6 200 | - [COOK-1330] - update cookbook documentation on excludes for yum 201 | - [COOK-1346] - retry remote_file for EPEL in case we get an FTP mirror 202 | 203 | 204 | v0.5.2 205 | ------ 206 | - [COOK-825] - epel and ius `remote_file` should notify the `rpm_package` to install 207 | 208 | v0.5.0 209 | ------ 210 | - [COOK-675] - add recipe for handling EPEL repository 211 | - [COOK-722] - add recipe for handling IUS repository 212 | 213 | v.0.1.2 214 | ------ 215 | - Remove yum update in default recipe, that doesn't update caches, it updates packages installed. 216 | -------------------------------------------------------------------------------- /PART01/CH01/cookbooks/yum-epel/README.md: -------------------------------------------------------------------------------- 1 | yum-epel Cookbook 2 | ============ 3 | 4 | The yum-epel cookbook takes over management of the default 5 | repositoryids shipped with epel-release. It allows attribute 6 | manipulation of `epel`, `epel-debuginfo`, `epel-source`, `epel-testing`, 7 | `epel-testing-debuginfo`, and `epel-testing-source`. 8 | 9 | Requirements 10 | ------------ 11 | * Chef 11 or higher 12 | * yum cookbook version 3.0.0 or higher 13 | 14 | Attributes 15 | ---------- 16 | The following attributes are set by default 17 | 18 | ``` ruby 19 | default['yum-epel']['repositories'] = %w{epel epel-debuginfo epel-source epel-testing epel-testing-debuginfo epel-testing-source} 20 | ``` 21 | 22 | ``` ruby 23 | default['yum']['epel']['repositoryid'] = 'epel' 24 | default['yum']['epel']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch' 25 | default['yum']['epel']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch' 26 | default['yum']['epel']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 27 | default['yum']['epel']['failovermethod'] = 'priority' 28 | default['yum']['epel']['gpgcheck'] = true 29 | default['yum']['epel']['enabled'] = true 30 | default['yum']['epel']['managed'] = true 31 | ``` 32 | 33 | ``` ruby 34 | default['yum']['epel-debuginfo']['repositoryid'] = 'epel-debuginfo' 35 | default['yum']['epel-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch - Debug' 36 | default['yum']['epel-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch' 37 | default['yum']['epel-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 38 | default['yum']['epel-debuginfo']['failovermethod'] = 'priority' 39 | default['yum']['epel-debuginfo']['gpgcheck'] = true 40 | default['yum']['epel-debuginfo']['enabled'] = false 41 | default['yum']['epel-debuginfo']['managed'] = false 42 | ``` 43 | 44 | ``` ruby 45 | default['yum']['epel-source']['repositoryid'] = 'epel-source' 46 | default['yum']['epel-source']['description'] = 'Extra Packages for Enterprise Linux 6 - $basearch - Source' 47 | default['yum']['epel-source']['mirrorlist'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-6&arch=$basearch' 48 | default['yum']['epel-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 49 | default['yum']['epel-source']['failovermethod'] = 'priority' 50 | default['yum']['epel-source']['gpgcheck'] = true 51 | default['yum']['epel-source']['enabled'] = false 52 | default['yum']['epel-source']['managed'] = false 53 | ``` 54 | 55 | ``` ruby 56 | default['yum']['epel-testing']['repositoryid'] = 'epel-testing' 57 | default['yum']['epel-testing']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch' 58 | default['yum']['epel-testing']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-epel6&arch=$basearch' 59 | default['yum']['epel-testing']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6r' 60 | default['yum']['epel-testing']['failovermethod'] = 'priority' 61 | default['yum']['epel-testing']['gpgcheck'] = true 62 | default['yum']['epel-testing']['enabled'] = false 63 | default['yum']['epel-testing']['managed'] = false 64 | ``` 65 | 66 | ``` ruby 67 | default['yum']['epel-testing-debuginfo']['repositoryid'] = 'epel-testing-debuginfo' 68 | default['yum']['epel-testing-debuginfo']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch Debug' 69 | default['yum']['epel-testing-debuginfo']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel6&arch=$basearch' 70 | default['yum']['epel-testing-debuginfo']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 71 | default['yum']['epel-testing-debuginfo']['failovermethod'] = 'priority' 72 | default['yum']['epel-testing-debuginfo']['gpgcheck'] = true 73 | default['yum']['epel-testing-debuginfo']['enabled'] = false 74 | default['yum']['epel-testing-debuginfo']['managed'] = false 75 | ``` 76 | 77 | ``` ruby 78 | default['yum']['epel-testing-source']['repositoryid'] = 'epel-testing-source' 79 | default['yum']['epel-testing-source']['description'] = 'Extra Packages for Enterprise Linux 6 - Testing - $basearch Source' 80 | default['yum']['epel-testing-source']['mirrorlist'] = 'https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel6&arch=$basearch' 81 | default['yum']['epel-testing-source']['gpgkey'] = 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6' 82 | default['yum']['epel-testing-source']['failovermethod'] = 'priority' 83 | default['yum']['epel-testing-source']['gpgcheck'] = true 84 | default['yum']['epel-testing-source']['enabled'] = false 85 | default['yum']['epel-testing-source']['managed'] = false 86 | ``` 87 | 88 | Recipes 89 | ------- 90 | * default - Walks through node attributes and feeds a yum_resource 91 | parameters. The following is an example a resource generated by the 92 | recipe during compilation. 93 | 94 | ```ruby 95 | yum_repository 'epel' do 96 | mirrorlist 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch' 97 | description 'Extra Packages for Enterprise Linux 5 - $basearch' 98 | enabled true 99 | gpgcheck true 100 | gpgkey 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL' 101 | end 102 | ``` 103 | 104 | Usage Example 105 | ------------- 106 | To disable the epel repository through a Role or Environment definition 107 | 108 | ``` 109 | default_attributes( 110 | :yum => { 111 | :epel => { 112 | :enabled => { 113 | false 114 | } 115 | } 116 | } 117 | ) 118 | ``` 119 | 120 | Uncommonly used repositoryids are not managed by default. This is 121 | speeds up integration testing pipelines by avoiding yum-cache builds 122 | that nobody cares about. To enable the epel-testing repository with a 123 | wrapper cookbook, place the following in a recipe: 124 | 125 | ``` 126 | node.default['yum']['epel-testing']['enabled'] = true 127 | node.default['yum']['epel-testing']['managed'] = true 128 | include_recipe 'yum-epel' 129 | ``` 130 | 131 | More Examples 132 | ------------- 133 | Point the epel repositories at an internally hosted server. 134 | 135 | ``` 136 | node.default['yum']['epel']['enabled'] = true 137 | node.default['yum']['epel']['mirrorlist'] = nil 138 | node.default['yum']['epel']['baseurl'] = 'https://internal.example.com/centos/6/os/x86_64' 139 | node.default['yum']['epel']['sslverify'] = false 140 | 141 | include_recipe 'yum-epel' 142 | ``` 143 | 144 | License & Authors 145 | ----------------- 146 | - Author:: Sean OMeara () 147 | 148 | ```text 149 | Copyright:: 2011-2013 Opscode, Inc. 150 | 151 | Licensed under the Apache License, Version 2.0 (the "License"); 152 | you may not use this file except in compliance with the License. 153 | You may obtain a copy of the License at 154 | 155 | http://www.apache.org/licenses/LICENSE-2.0 156 | 157 | Unless required by applicable law or agreed to in writing, software 158 | distributed under the License is distributed on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 160 | See the License for the specific language governing permissions and 161 | limitations under the License. 162 | ``` 163 | -------------------------------------------------------------------------------- /PART07/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | BOX_NAME = ENV['BOX_NAME'] || "ubuntu" 5 | BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box" 6 | VF_BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64_vmware_fusion.box" 7 | AWS_BOX_URI = ENV['BOX_URI'] || "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" 8 | AWS_REGION = ENV['AWS_REGION'] || "us-east-1" 9 | AWS_AMI = ENV['AWS_AMI'] || "ami-69f5a900" 10 | AWS_INSTANCE_TYPE = ENV['AWS_INSTANCE_TYPE'] || 't1.micro' 11 | 12 | FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS'] 13 | 14 | SSH_PRIVKEY_PATH = ENV["SSH_PRIVKEY_PATH"] 15 | 16 | # A script to upgrade from the 12.04 kernel to the raring backport kernel (3.8) 17 | # and install docker. 18 | $script = <