DevOps & Stuff
Chris Jimenez
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.
DevOps
“It aims at establishing a culture and environment where
building, testing, and releasing software, can happen rapidly,
frequently, and more reliably.”
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
DevOps
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!
Infrastructure
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
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
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
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
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
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
Start & Enable Apache
package 'apache2'
service 'apache2' do
supports :status => true
action [:enable, :start]
end
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
Hello World
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
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]'
Manage your nodes
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
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.
Cookbooks
knife cookbook list
learn_chef_apache2 0.2.1
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
Chef Server
Chef Server
Update Cookbook
knife cookbook upload learn_chef_apache2
knife ssh ADDRESS 'sudo chef-client' --manual-list --ssh-user USER --identity-file IDENTITY_FILE
Clean Up
knife node delete node1 --yes
Deleted node[node1]
Develop Locally
Test Kitchen
Kitchen Life
References

DevOps and Chef

  • 1.
  • 2.
    DevOps? DevOps (a clippedcompound 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.
    DevOps “It aims atestablishing a culture and environment where building, testing, and releasing software, can happen rapidly, frequently, and more reliably.”
  • 4.
    DevOps Code – CodeDevelopment 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.
  • 7.
    Chef INFRASTRUCTURE : Savetime 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!
  • 8.
  • 9.
    Let's create aRecipe mkdir ~/chef-repo cd ~/chef-repo Create a MOTD file vim hello.rb file '/tmp/motd' do content 'hello world' end
  • 10.
    Let's configure aresource 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
  • 11.
    Run the commandagain chef-client --local-mode hello.rb Running handlers: Running handlers complete Chef Client finished, 0/1 resources updated in 01 seconds
  • 12.
    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
  • 13.
    Lets install Apache vimwebserver.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
  • 14.
    Run a secondtime 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
  • 15.
    Start & EnableApache package 'apache2' service 'apache2' do supports :status => true action [:enable, :start] end
  • 16.
    Add a homepage 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
  • 17.
  • 18.
    Cookbooks Make our recipesmanageable 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
  • 19.
    Update the recipewith 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]'
  • 20.
  • 21.
    Chef Server Acts asa 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
  • 22.
    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.
  • 23.
  • 24.
    Bootstrap a Node knifebootstrap 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
  • 25.
  • 26.
  • 27.
    Update Cookbook knife cookbookupload learn_chef_apache2 knife ssh ADDRESS 'sudo chef-client' --manual-list --ssh-user USER --identity-file IDENTITY_FILE
  • 28.
    Clean Up knife nodedelete node1 --yes Deleted node[node1]
  • 29.
  • 30.
  • 31.
  • 32.