Your SlideShare is downloading. ×
Chef
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Chef

1,033
views

Published on


0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,033
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. chefрецепты от шеф-повара
  • 2. Основные понятияNode - хост на котором запущен chef-clientchef-client - консольная утилитаобновляющая нодуchef server - хост с которого нодызагружают свою конфигурациюchef-repo - репозиторий с конфигурациямиworkstation (Client) - компьютерразработчика с локальной версией chef-repocookbook - поваренная книга
  • 3. Архитектура
  • 4. Основные компонентыohai - собирает информацию о ноде накоторой запущен (platform, fqdn)knife - консольная утилита для управленияchef-repo, chef server, nodes and more.shef - интерактивная ruby консоль дляотладки и управления.
  • 5. В кратце это работает так
  • 6. С чего начать?1. Поднимаем chef server;2. Настраиваем knife на chef server;3. Настраиваем workstation (clone chef-repo, setup knife);4. Бутстрапим ноду. knife bootstrap 10.40.64.143 -r -x root -P <secret>;5. Обновляем ноду chef-client.
  • 7. NodeОписывается структурой json. knife node edit<node_name> для редактирования.● Аттрибуты;● Run list - рецепты которые будут применены к ноде;● Environment● Role
  • 8. Attributes
  • 9. Cookbooksattributes/definitions/files/libraries/metadata.rb # version, dependencyproviders/README.rdocrecipes/resources/templates/
  • 10. Recipesknife cookbook create apache2cookbooks/apache2/recipes/default.rbcookbooks/apache2/recipes/mod_ssl.rb{ # knife node edit <name> "run_list": [ "recipe[apache2]", "recipe[apache2::mod_ssl]" ]}
  • 11. Resources# Создаем директориюdirectory "/tmp/monkey" do owner "root" group "root" mode 0755 action :createend# Запускаем и добавляем в автозагрузкуservice "nginx" do supports :status => true, :restart => true, :reload => true subscribes :reload, resources(:template => "#{node[:nginx][:dir]}/nginx.conf") action [:enable, :start]end
  • 12. apt-repository exampleapt_repository "hardy-rsyslog-ppa" do uri "http://ppa.launchpad.net/a.bono/rsyslog/ubuntu" distribution "hardy" components ["main"] keyserver "keyserver.ubuntu.com" key "C0061A4A" action :add notifies :run, "execute[apt-get update]", :immediatelyendapt_repository "zenoss" do action :removeend
  • 13. php examplephp_pear "XML_RPC" do action :upgradeendphp_pear "XML_RPC" do version "1.5.4" action :installendphp_pear "apc" do action :install directives(:shm_size => 128, :enable_cli => 1)end
  • 14. Providersaction :create do execute "create database" do not_if "mysql -e show databases; | grep #{new_resource.name}" command "mysqladmin create #{new_resource.name}" endendaction :delete do execute "delete database" do only_if "mysql -e show databases; | grep #{new_resource.name}" command "mysqladmin drop #{new_resource.name}" endend
  • 15. Searchknife search admins id:charlieknife search node name:app?.example.comknife search node "broadcast:192.168.0.*"knife search node "mtu:1500"knife search node "flags:UP"search(:node, run_list:recipe[foo::bar])search(:node, role:load_balancer)
  • 16. Data bagsknife data bag create adminsvi data_bags/admins/charlie.json{ "id": "charlie", "uid": 1005, "gid":"ops", "shell":"/bin/zsh", "comment":"Crazy Charlie"}# in receiptdata_bag_item(admins, charlie)
  • 17. workstation workflow● knife cookbook create <name>● knife cookbook upload <name>● Изменения в нодах, синхронизируются автоматически.
  • 18. deploy exampledeploy "/my/deploy/dir" do repo "git@github.com/whoami/project" revision "abc123" # or "HEAD" or "TAG_for_1.0" or (subversion) "1234" user "deploy_ninja" enable_submodules true migrate true migration_command "rake db:migrate" environment "RAILS_ENV" => "production", "OTHER_ENV" => "foo" shallow_clone true action :deploy # or :rollback restart_command "touch tmp/restart.txt" git_ssh_wrapper "wrap-ssh4git.sh" scm_provider Chef::Provider::Git # is the default, for svn: Chef::Provider::Subversionend
  • 19. Полезняшки● http://wiki.opscode.com/display/chef/Home● https://github.com/opscode/chef-repo● http://habrahabr.ru/company/scalaxy/blog/87302/● http://vagrantup.com/● http://www.opscode.com/ (chef-server)
  • 20. Спасибо за вниманиеemail: mokevnin@gmail.comblog: www.wddx.ruКайдзен www.kaize.rutwitter.com/mokevnin