Upgrade to Pro — share decks privately, control downloads, hide ads and more …

15分で解る Chef

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

15分で解る Chef

社内向けに利用した資料。ぎゅっとまとめたら15分で理解出来る内容に。

Avatar for Tomokazu HIRAI

Tomokazu HIRAI

November 18, 2013
Tweet

More Decks by Tomokazu HIRAI

Other Decks in Technology

Transcript

  1. Chef ͷߏ੒ Chef-Server WorkStation Node ʢ̍ʣ ʢ̎ʣ ʢ̏ʣ (1) :

    cookbooks, roles, data_bag, environments ౳ΛΞοϓϩʔυ (2) : node ʹରͯ͠ ‘bootstrap’ ߦ͍σϓϩΠ։࢝ (3) : cookbooks, roles ౳Λμ΢ϯϩʔυ͠ chef-client ࣮ߦ, ͦͷޙ΋ఆظతʹ࣮ߦ knife Λ࢖͍ૢ࡞ 13೥10݄2೔ਫ༵೔
  2. WorkStation server% knife configure -i 伴ͷੜ੒ client% mkdir .chef client%

    scp <server>:~/thirai.pem .chef/ client% scp <server>:~/chef-validator.pem .chef/ client% vim .chef/knife.rb log_level :info log_location STDOUT node_name 'thirai' client_key '/Users/thirai/chef-repo/.chef/thirai.pem' validation_client_name 'chef-validator' validation_key '/Users/thirai/chef-repo/.chef/chef-validator.pem' chef_server_url 'https://10.200.10.96' syntax_check_cache_path '/Users/thirai/chef-repo/.chef/syntax_check_cache' client% knife node list # knife ίϚϯυ͕ར༻Մೳʹɻ foo01 foo02 ... Chef-Server WorkStation Node 13೥10݄2೔ਫ༵೔
  3. Chef-Repo chef-repo !"" cookbooks # %"" nginx # !"" attributes

    # !"" definitions # !"" files # # %"" default # # %"" tests # # %"" minitest # # %"" support # !"" recipes # %"" templates # !"" debian # !"" default # # !"" modules # # %"" plugins # !"" gentoo # %"" ubuntu !"" data_bags !"" environments %"" roles Chef-Server WorkStation Node 13೥10݄2೔ਫ༵೔
  4. Cookbooks * Attributes * Templates * Recipe default['apache']['package'] = "httpd"

    default['apache']['pid_file'] = "/var/run/httpd.pid" default['apache']['timeout'] = 300 default['apache']['keepalive'] = "On" 13೥10݄2೔ਫ༵೔
  5. Cookbooks * Attributes * Templates * Recipe PidFile <%= node['apache']['pid_file']

    %> Timeout <%= node['apache']['timeout'] %> KeepAlive <%= node['apache']['keepalive'] %> 13೥10݄2೔ਫ༵೔
  6. Cookbooks * Attributes * Templates * Recipe package "apache2" do

    package_name node['apache']['package'] end 13೥10݄2೔ਫ༵೔
  7. Cookbooks * Attributes * Templates * Recipe package "apache2" do

    package_name node['apache']['package'] end http://docs.opscode.com/resource.html Resources 13೥10݄2೔ਫ༵೔
  8. Roles name "webservers" description "role of web servers" run_list "recipe[apache2]",

    "recipe[apache2::mod_fastcgi]" override_attributes "apache2" => { "max_children" => "50" } recipe/default.rb recipe/mod_fastcgi.rb 13೥10݄2೔ਫ༵೔
  9. Environments name  "dev" description  "The  development  environment" cookbook_versions    "couchdb"

     =>  "=  11.0.0" override_attributes  "apache2"  =>  {  "listen_ports"  =>  [  "80",  "443"  ]  } 13೥10݄2೔ਫ༵೔
  10. Data Bags % ${EDITOR} bofh.json { "id": "bofh", "ssh_keys": "ssh-rsa

    AAAAB3Nz...yhCw== bofh", "groups": [ "sysadmin", "dba", "devops" ], "uid": 2001, "shell": "\/bin\/bash", "comment": "BOFH", "nagios": { "pager": "[email protected]", "email": "[email protected]" }, "openid": "bofh.myopenid.com" } % knife data bag create users % knife data bag from file users ./bofh.json 13೥10݄2೔ਫ༵೔