Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

DevOps and Chef

185 views

Published on

A DevOps introduction and Chef

Published in: Software
  • Be the first to comment

  • Be the first to like this

DevOps and Chef

  1. 1. DevOps & Stuff Chris Jimenez
  2. 2. DevOps? DevOps (a clipped compound of "development" and "operations") Its a culture, movement or practice that emphasizes the collaboration and communication of both software developers and other information-technology (IT) professionals while automating the process of software delivery and infrastructure changes.
  3. 3. DevOps “It aims at establishing a culture and environment where building, testing, and releasing software, can happen rapidly, frequently, and more reliably.”
  4. 4. DevOps Code – Code Development and Review, continuous integration tools Build – Version control tools, code merging, Build status Test – Test and results determine performance Package – Artifact repository, Application pre-deployment staging Release – Change management, Release approvals, release automation Configure – Infrastructure configuration and management, Infrastructure as Code tools Monitor – Applications performance monitoring, End user experience
  5. 5. DevOps
  6. 6. Chef INFRASTRUCTURE : Save time and reduce errors by automating provisioning and configuration at scale APPLICATIONS: Continuously deliver applications faster and safer with a proven pipeline COMPLIANCE : Automate testing for security and compliance, and add remediation to your pipeline ONE PLATFORM: CHEF : Manage changes to apps, infrastructure, and compliance in multiple environments Es un chuzo!
  7. 7. Infrastructure
  8. 8. Let's create a Recipe mkdir ~/chef-repo cd ~/chef-repo Create a MOTD file vim hello.rb file '/tmp/motd' do content 'hello world' end
  9. 9. Let's configure a resource chef-client --local-mode hello.rb Converging 1 resourcesRecipe: @recipe_files::/root/chef-repo/hello.rb * file[/tmp/motd] action create - create new file /tmp/motd - update content in file /tmp/motd from none to b94d27 --- /tmp/motd 2016-01-07 18:10:44.638360163 +0000 +++ /tmp/.motd20160107-5972-h0sawb 2016-01-07 18:10:44.638360163 +0000 @@ -1 +1,2 @@ +hello world Running handlers: Running handlers complete Chef Client finished, 1/1 resources updated in 01 seconds more /tmp/motd hello world
  10. 10. Run the command again chef-client --local-mode hello.rb Running handlers: Running handlers complete Chef Client finished, 0/1 resources updated in 01 seconds
  11. 11. Delete the file file '/tmp/motd' do action :delete end chef-client --local-mode goodbye.rb Recipe: @recipe_files::/root/chef-repo/goodbye.rb * file[/tmp/motd] action delete - delete file /tmp/motd Running handlers: Running handlers complete Chef Client finished, 1/1 resources updated in 01 seconds
  12. 12. Lets install Apache vim webserver.rb package 'apache2' sudo chef-client --local-mode webserver.rb Recipe: @recipe_files::/root/chef-repo/webserver.rb apt_package[apache2] action install - install version 2.4.7-1ubuntu4.8 of package apache2 Chef Client finished, 1/1 resources updated in 08 seconds
  13. 13. Run a second time sudo chef-client --local-mode webserver.rb * apt_package[apache2] action install (up to date) Chef Client finished, 0/1 resources updated in 01 seconds
  14. 14. Start & Enable Apache package 'apache2' service 'apache2' do supports :status => true action [:enable, :start] end
  15. 15. Add a home page package 'apache2' service 'apache2' do supports :status => true action [:enable, :start] end file '/var/www/html/index.html' do content '<html> <body> <h1>hello world</h1> </body> </html>' end
  16. 16. Hello World
  17. 17. Cookbooks Make our recipes manageable mkdir cookbook cd cookbooks chef generate cookbook learn_chef_apache2 This generates all the folder structure with test folders, specs, templates, and the recipes folders
  18. 18. Update the recipe with a template package 'apache2' service 'apache2' do supports :status => true action [:enable, :start] end template '/var/www/html/index.html' do source 'index.html.erb' end sudo chef-client --local-mode --runlist 'recipe[learn_chef_apache2]'
  19. 19. Manage your nodes
  20. 20. Chef Server Acts as a central repository for your cookbooks as well as for information about every node it manages. For example, the Chef server knows a node's fully qualified domain name (FQDN) and its platform. Self Hosted Hosted Chef Server
  21. 21. Upload a Cookbook cd ~/learn-chef mkdir cookbooks knife cookbook site download learn_chef_apache2 knife cookbook upload learn_chef_apache2 Uploading learn_chef_apache2 [0.2.1] Uploaded 1 cookbook.
  22. 22. Cookbooks knife cookbook list learn_chef_apache2 0.2.1
  23. 23. Bootstrap a Node knife bootstrap ADDRESS --ssh-user USER --sudo --identity-file IDENTITY_FILE --node-name node1 --run-list 'recipe[learn_chef_apache2]' Creating new client for node1 Creating new node for node1 Connecting to 52.33.228.36 52.33.228.36 Chef Client finished, 2/4 resources updated in 15 seconds
  24. 24. Chef Server
  25. 25. Chef Server
  26. 26. Update Cookbook knife cookbook upload learn_chef_apache2 knife ssh ADDRESS 'sudo chef-client' --manual-list --ssh-user USER --identity-file IDENTITY_FILE
  27. 27. Clean Up knife node delete node1 --yes Deleted node[node1]
  28. 28. Develop Locally
  29. 29. Test Kitchen
  30. 30. Kitchen Life
  31. 31. References

×