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. DevOps
“It aims at establishing a culture and environment where
building, testing, and releasing software, can happen rapidly,
frequently, and more reliably.”
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
7. 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!
9. 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
10. 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
11. 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
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
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
14. 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
15. Start & Enable Apache
package 'apache2'
service 'apache2' do
supports :status => true
action [:enable, :start]
end
16. 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
18. 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
19. 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]'
21. 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
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.
24. 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