Help improve internal process, use of Chef at Chef • System Administrator, Software Developer • Based in Westminster, CO • Contact: jtimberman pretty much everywhere, and [email protected]
integration • Complete infrastructure automation • Resources, providers, recipes, cookbooks • Chef Server • Test Driven Infrastructure • Chef Provisioning • Walls of text and funny weird interesting images
Chef • Run your own Chef Server • Entirely Open Source as of Chef Server 12 "There is One Chef Server, and it is Open Source" - Adam Jacob https://www.chef.io/blog/2014/09/08/there-is-one-chef-server-and-it-is-open-source/
>> WEBrick (v1.3.1) on Rack (v1.5) is listening at http://127.0.0.1:8889 >> Press CTRL+C to stop % knife client create demo -‐d -‐z Created client[demo] % knife client list -‐z demo
Policy Authoring Test-Driven Infrastructure Chef Server Management Console Analytics Platform High Availability and Replication Chef Client Nodes Data Center The Cloud
system state you define • You declare resource state using the recipe DSL package "httpd" do action :install end windows_feature "IIS-WebServerRole" do action :install end
home '/opt/example' shell '/bin/false' system true end template '/opt/example/example.conf' do notifies :restart, 'service[example]' end service 'example' do supports :restart action [:enable, :start] end
home '/opt/example' shell '/bin/false' system true end template '/opt/example/example.conf' do notifies :restart, 'service[example]' end service 'example' do supports :restart action [:enable, :start] end
home '/opt/example' shell '/bin/false' system true end template '/opt/example/example.conf' do notifies :restart, 'service[example]' end service 'example' do supports :restart action [:enable, :start] end
home '/opt/example' shell '/bin/false' system true end template '/opt/example/example.conf' do notifies :restart, 'service[example]' end service 'example' do supports :restart action [:enable, :start] end
home '/opt/example' shell '/bin/false' system true end template '/opt/example/example.conf' do notifies :restart, 'service[example]' end service 'example' do supports :restart action [:enable, :start] end Chef has a default action for all resources
do home '/opt/example' shell '/bin/false' system true end template '/opt/example/example.conf' do notifies :restart, 'service[example]' end service 'example' do supports :restart action [:enable, :start] end
collection of resources to deliver that service • Resources are converged in the order they are listed Building Blocks: What is a Recipe? On Linux based OSes: package "httpd" do action :install end template ”/var/www/index.html" do source ”index.html.erb” mode "0644" end service "httpd" do action [ :enable, :start ] end windows_feature "IIS-WebServerRole" do action :install end template 'c:\inetpub\wwwroot\Default.htm' do source "Default.htm.erb" rights :read, "Everyone" end service "w3svc" do action [ :enable, :start ] end
of the system in line with what we've declared in the policy (recipe). Chef resources are configured by providers that take action to put resources in the desired state. That is, Chef performs "test and repair" operations. Actions are not taken if the resource is in the desired state. Providers can be platform specific, e.g. "yum" or "apt" for the "package" resource
a set of recipes and supporting assets (templates, etc) • A cookbook is a defined set of items and different outcomes that you expect to address ./attributes ./attributes/default.rb ./CHANGELOG.md ./metadata.rb ./README.md ./recipes ./recipes/application.rb ./recipes/balancer.rb ./recipes/database.rb ./recipes/default.rb ./recipes/webserver.rb ./templates ./templates/default ./templates/default/mysite.conf.erb
attributes and run lists to nodes chef_type: role default_attributes: my-app: application: version: 1.5.6 description: Role for my application json_class: Chef::Role name: my_application_role run_list: role[base] recipe[my-app::application]
built into Chef • Chef Vault* is a library by Nordstrom for shared secret management/distribution deploy_key: cipher: aes-256-cbc encrypted_data: lIpW3sqd69wXt7+MB +uGXr0GfcrEf6rOnHLMA7H00ZCbTxMcEypguGD22w23 qzEZSzCf2ahv67CtcfrDGvUoWS57Gp5/QoR4WBYKQQUplY0LPtXMZFDISCLU a0aNhrzrXhT9eDKNpru7hpuEkOZPRNstx1121bdMZ9lm1/6BPBeIWUYrxAeS . . . . . . . . . . . . . . iv: tpz6zFz9xkscoi36kRw4JQ== version: 1 id: jenkins_ssh_key *Not to be confused with Hashicorp's Vault
user[example] action create DEBUG: user[example] user does not exist DEBUG: user[example] setting shell to /bin/false DEBUG: user[example] setting home to /opt/example INFO: user[example] created -‐ create user example $ getent passwd example example:x:999:999::/opt/example:/bin/false
cookbook)::(chef-‐apply recipe) * user[example] action create DEBUG: user[example] setting uid to 333 INFO: user[example] altered -‐ alter user example $ getent passwd example example:x:333:999::/opt/example:/bin/false
package 'haproxy' template '/etc/haproxy/haproxy.cfg' do source 'haproxy.cfg.erb' owner 'root' group 'root' mode '0644' variables(:pool_members => members) notifies :reload, 'service[haproxy]' end service 'haproxy' do supports :reload action [:enable, :start] end
Chef Search is not a service discovery system. Nor does it do leader election. Service discovery is not infrastructure management. Service discovery tools aren't publishing platforms.
Chef for ubuntu... downloading https://www.chef.io/chef/metadata? v=&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64 to file /tmp/install.sh.12411/metadata.txt trying wget... url https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/10.04/x86_64/ chef_12.3.0-1_amd64.deb md5 d8421c9b3010deb03e713ada00387e8a sha256 e06eb748e44d0a323f4334aececdf3c2c74d2f97323678ad3a43c33ac32b4f81 downloaded metadata file looks valid... downloading https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/10.04/x86_64/ chef_12.3.0-1_amd64.deb to file /tmp/install.sh.12411/chef_12.3.0-1_amd64.deb trying wget... Comparing checksum with sha256sum... Installing Chef installing with dpkg... Selecting previously unselected package chef. ng database ... 32352 files and directories currently installed.) Preparing to unpack .../chef_12.3.0-1_amd64.deb ... Unpacking chef (12.3.0-1) ... Setting up chef (12.3.0-1) ... Thank you for installing Chef! Kitchen installs Chef