SlideShare a Scribd company logo
1 of 31
Provisioning part
You can download me here:
https://github.com/akranga/devops-hackathon-2
Infrastructure Complexity
Virtual Nodes
Physical Hardware
Infrastructure as Code
- Declarative approach: You describe what
you want to get, not how
- You describe state of the VM you want to
achieve in cookbook or manifest.
- Chef (or other tool like Puppet or Ansible)
will bring your VM into described state
- This operation called provisioning or
convergence
include_recipe "java"
package "tomcat6"
service "tomcat6" do
action [:enable, :start]
end
Cookbooks vs Scripts
- Cookbooks are repeatable
- Cookbooks are unit testable
- Cookbooks has dependencies and versions
- Cookbooks are written on Ruby DSL
- Over 1300+ cookbooks available from the
community
- For Ops: no programming experience
required
- For Devs: no sys-admin experience
required
include_recipe "java"
package "tomcat6"
service "tomcat6" do
action [:enable, :start]
end
Chef
- Very popular provisioning tool
- Huge community
Vagrant and Chef
- Vagrant manages VM
(operates outside)
- Vagrant triggers Chef
(provisioning)
- Chef runs inside existingVM
- Chef installs Services
(Tomcat, MySQL, RabbitMQ)
Use Cases
- DevOps are using Vagrant + Chef for Cookbook development
- Dev & QA are using t host environment locally
- Ops using test deployments before roll-out to prod
- Jenkins using to run Infrastructure Automation Tests
- Jenkins using to do true Integration Tests of the App
+
recipe example
Cookbooks vs Scripts
- Cookbooks are repeatable
- Cookbooks are unit testable
- Cookbooks are written on Ruby DSL
- Over 1300+ cookbooks available from the
community
- For Ops: no programming experience
required
- For Devs: no sys-admin experience
required
include_recipe "java"
package "tomcat6"
service "tomcat6" do
action [:enable, :start]
end
How does it works
- Chef is an app that installed on VM (node)
- Chef reads a “run list” of cookbooks and
recipes
- Chef detects attributes of the VM
(OS, RAM, IP address, hostname)
- Chef adds custom attributes defined in
cookbook
(version of java, database port)
- Chef transforms recipes and attributes to
OS specific instructions and runs
convergence
Recipe
Attributes
OS Specific Instructions
Anatomy of Cookbook
Cookbook Content
- Attributes: contains configurable
parameters
(database port, mirror URL)
- Recipes: describes resources for chef
(package to install, users to create etc)
- Templates: contains custom configuration
that you want to apply
- Metadata: file that describes cookbook
name, version, supported OS etc
- Readme: meaningful file for User
Most common cookbook have structure as following
cookbook structure
mycookbook
/attributes
/recipes
/templates
metadata.rb
README.md
cookbook structure
Attributes
- Attributes defined in file
<cookbook>/attributes/default.rb
- Recipe specific attributes can be defined
in file
<cookbook>/attributes/<recipe_name>.rb
- Attributes are hierarchical
(structured as multi dimensional map)
- Attributes can be defined as
default[:tomcat][:home] = "/var/tomat“
(valid ruby code)
- Attributes can be accessed in recipe or
template as the following
node.tomcat.home or node[:tomcat][:home]
mycookbook
/attributes
default.rb
<recipe>.rb
/recipes
/templates
metadata.rb
README.md
All cookbook configurables can be exposed as attributes. Cookbook contains
default attributes that user can override with their own
All about attributes:
http://docs.opscode.com/chef_overview_attributes.html
cookbook structure
Recipes
mycookbook
/attributes
/recipes
default.rb
<other_recipe>.rb
/templates
metadata.rb
README.md
Recipe describes resources for chef convergence. Cookbook should have at
least “default” recipe. Recipes ordered in the chef run list.
Single web page for Chef resoruces:
http://docs.opscode.com/resources.html
- package: a software package that will be
installed from package manager (apt, yum)
- service: a service in: /etc/init.d
:enable – enable service to autorun
:start, :stop, :restart, :reload
- user: user that will be created or updated
- directory: directory to be created
- remote_file: file to be downloaded from
remote host
- tempalte: a file in VM rendered from ERB
template (templates directory
cookbook structure
References inside recipes
mycookbook
/attributes
/recipes
default.rb
<other_recipe>.rb
/templates
metadata.rb
README.md
Single web page for Chef resoruces:
http://docs.opscode.com/resources.html
- You can refer to another recipe by calling
include_recipe "mysql::server"
- Reference just by cookbook name assumes
“default” recipe of that cookbook
include_recipe "java" same as
include_recipe "java::default"
- “Other” cookbook must be declared in
metadata.rb as
depends “java"
cookbook structure
Recipe references
mycookbook
/attributes
/recipes
/templates
/default
apache.conf.erb
/redhat
apache.conf.erb
metadata.rb
README.md
Single web page for Chef resoruces:
http://docs.opscode.com/resources.html
- Template files stored in directory
/template/default
- OS specific templates can be stored in
/template/<os-type>
- Node attributes can be referenced inside
template as
<%= node.tomcat.port %>
Templates are typically be populated with VM (node) attributes and rendered
as a configuration file. Templates follow ERB semantics
cookbook structure
Metadata
mycookbook
/attributes
/recipes
/templates
metadata.rb
README.md
Single web page for Chef resoruces:
http://docs.opscode.com/resources.html
- Template files stored in directory
/template/default
- OS specific templates can be stored in
/template/<os-type>
- Node attributes can be referenced inside
template as
<%= node.tomcat.port %>
Chef has dependency management between cookbooks. Each cookbook should
have following data
Activity 1
Create a custom cookbook that
- Installs and configures nginx
Berksfile: TODO2
Vagrantfile: TODO1
Activity 1
Go to /activity1 directory
1. Enable Chef at Vagrantfile: by adding following lines:
config.omnibus.chef_version = :latest
config.berkshelf.enabled = true
2. Add cookbooks to Berkshelf file:
This will instruct Vagrant to use latest Chef from Omnibus package
Second line will instruct vagrant to activate Cookbook dependency manager
cookbook "apt"
cookbook "my_webserver", path: "cookbooks/mynginx"
Apt cookbook will be installed from Chef website
my_webserver cookbook we will just create
my_webserver::default TODO4
Activity 1
3. Add cookbooks to the Vagrantfile runlist
4. Add some logic to my_webserver cookbook. Modify default recipe and
add instructuion to download nginx from package manager
package "nginx"
Vagrantfile: TODO3
chef.add_recipe "apt"
chef.add_recipe "my_webserver"
These cookbooks will be delivered to Vagrant by instructions specified in
Berksfile
my_webserver::default TODO5
Activity 1
5. Add resource that will declare service “nginx”. Enable it as auto-run and
start it
service "nginx" do
action [ :enable, :start ]
end
6. Start vagrant machine
$ vagrant up
If you have existing vagrant VM (not empty) you might want to destroy it
$ vagrant destroy --force
$ vagrant up
7. Go to http://localhost:2080 with your browser
Activity 2
Add Tomcat and Java to web server
Reconfigure nginx to work as reverse proxy
Vagrantfile: TODO2
Berksfile: TODO1
Activity 2
Go to /activity2 directory
1. Add new cookbooks to the Berksfile
cookbook "java"
cookbook "tomcat"
2. Add tomcat and Java to your VM provisioning run list:
This will instruct Vagrant to use latest Chef from Omnibus package
Second line will instruct vagrant to activate Cookbook dependency manager
chef.add_recipe "java"
chef.add_recipe "tomcat"
Activity 2
6. Add cookbooks to the Vagrantfile runlist
4. Run the VM
# vagrant up --provision
Vagrantfile: TODO3
config.vm.network :forwarded_port, guest: 8080, host: 8080
config.vm.network :forwarded_port, guest: 8443, host: 8443
8080 is a HTTP port for Tomcat
8443 is a HTTPS port for Tomcat
5. With your browser go to: http://localhost:2080 and http://localhost:8080
Activity 2
7. Add attributes to the attributes/default.rb file
8. Add synced directory to Vagrantfile
attributes/default.rb: TODO4
default.nginx.port = 80
default.nginx.www_docs = "/var/www/html"
We will make nginx port 80 and htdocs directory configurable
Vagrantfile: TODO5
config.vm.synced_folder "webapp/", "/var/www/html"
This will deliver our custom html page to the vagrant VM
Activity 2
9. Change default-site.erb template
9. Modify code in recipe tomcat_proxy.rb
default-site.erb: TODO6
<%= node.nginx.www_docs %>;
my_webserver::tomcat_proxy TODO8
template "/etc/nginx/sites-available/default" do
source "default-site.erb"
end
This will instruct chef to replace nginx default site configuration with file
rendered from templates
default-site.erb: TODO7
<%= node.tomcat.port %>
This attribute will be taken from attributes/default.rb file
This attribute will be taken from Tomcat cookbook (it is in VM run list)
Activity 2
10. Add logic that will notify service declared in “default.rb” recipe to
reload after template have been rendered. Please change yellow line
my_webserver::tomcat_proxy TODO9
template "/etc/nginx/sites-available/default" do
source "default-site.erb”
notifies :reload, "service[nginx]"
end
We must instruct service that it should support “service reload” action
(which is disabled by default)
my_webserver::default TODO10
service "nginx" do
action [ :enable, :start ]
supports :reload => true
end
Activity 2
10. Reload vagrant with one of the following commands
11. With your browser go to: http://localhost:2080
http://localhost:2080/static
$ vagrant reload –provision
$ vagrant provision
$ vagrant up --provision
Fixing Vagrant-Berkshelf
- Use Vagrant Version 1.4.3
- Run: vagrant plugin install vagrant-berkshelf --plugin-version "< 2.0.0"
Activity 3 (install mysql server)
Add Tomcat and Java to web server
Reconfigure nginx to work as reverse proxy
Vagrantfile: TODO2
Change: TODO1
Activity 3
Go to /activity3 directory
1. Change Berkshelf file to include mysql cookbook
cookbook "mysql"
2. Add mapping of port 3306
config.vm.network :forwarded_port, guest: 3306, host: 3306
Vagrantfile: TODO3
"mysql" => {
"server_root_password" => "secret"
}
3. By default mysql password can be found below (we will override it):
https://github.com/opscode-cookbooks/mysql/blob/master/attributes/default.rb
Retrospective

More Related Content

What's hot

Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = CodeGeorg Sorst
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chefMukta Aphale
 
London Community Summit - Habitat 2016
London Community Summit - Habitat 2016London Community Summit - Habitat 2016
London Community Summit - Habitat 2016Sarah Richards
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleOrestes Carracedo
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry Cai
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash courseMarcus Deglos
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetMichael Lessard
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and DockerDaniel Ku
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Añadiendo Jenkins al entorno para Integración continua
Añadiendo Jenkins al entorno para Integración continuaAñadiendo Jenkins al entorno para Integración continua
Añadiendo Jenkins al entorno para Integración continuaCésar Martín Ortiz Pintado
 
Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesabadger1999
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Julian Dunn
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef
 

What's hot (20)

Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = Code
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
 
London Community Summit - Habitat 2016
London Community Summit - Habitat 2016London Community Summit - Habitat 2016
London Community Summit - Habitat 2016
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash course
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Vagrant
VagrantVagrant
Vagrant
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Añadiendo Jenkins al entorno para Integración continua
Añadiendo Jenkins al entorno para Integración continuaAñadiendo Jenkins al entorno para Integración continua
Añadiendo Jenkins al entorno para Integración continua
 
Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker images
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Ansible project-deploy
Ansible project-deployAnsible project-deploy
Ansible project-deploy
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
 

Viewers also liked

Getting started with Chef
Getting started with ChefGetting started with Chef
Getting started with ChefEdureka!
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Software, Inc.
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Pravin Mishra
 
A charity organisation i would like to start
A charity organisation i would like to startA charity organisation i would like to start
A charity organisation i would like to startProsv
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Software, Inc.
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation WorkshopChef
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Software, Inc.
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeJosh Padnick
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an IntroductionSanjeev Sharma
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with ChefAdam Jacob
 

Viewers also liked (10)

Getting started with Chef
Getting started with ChefGetting started with Chef
Getting started with Chef
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation Setup
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )
 
A charity organisation i would like to start
A charity organisation i would like to startA charity organisation i would like to start
A charity organisation i would like to start
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an Introduction
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with Chef
 

Similar to DevOps hackathon Session 2: Basics of Chef

DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureAntons Kranga
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with ChefJohn Ewart
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Alessandro Pilotti
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Chef infrastructure as code - paris.rb
Chef infrastructure as code - paris.rbChef infrastructure as code - paris.rb
Chef infrastructure as code - paris.rbNicolas Ledez
 
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013Amazon Web Services
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular applicationmirrec
 
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfChef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfJun Sakata
 
Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for ussickill
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.INRajesh Hegde
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile InfrastructuresAntons Kranga
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 

Similar to DevOps hackathon Session 2: Basics of Chef (20)

Chef introduction
Chef introductionChef introduction
Chef introduction
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
Chef
ChefChef
Chef
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Chef infrastructure as code - paris.rb
Chef infrastructure as code - paris.rbChef infrastructure as code - paris.rb
Chef infrastructure as code - paris.rb
 
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfChef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
 
Chef advance
Chef advanceChef advance
Chef advance
 
Chef advance
Chef advanceChef advance
Chef advance
 
Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for us
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 

More from Antons Kranga

DevOps.2D: two dimensions
of engineering
DevOps.2D: two dimensions
of  engineeringDevOps.2D: two dimensions
of  engineering
DevOps.2D: two dimensions
of engineeringAntons Kranga
 
Riga DevDays 2017 - Efficient AWS Lambda
Riga DevDays 2017 - Efficient AWS LambdaRiga DevDays 2017 - Efficient AWS Lambda
Riga DevDays 2017 - Efficient AWS LambdaAntons Kranga
 
DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureAntons Kranga
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesAntons Kranga
 
Dev ops with smell v1.2
Dev ops with smell v1.2Dev ops with smell v1.2
Dev ops with smell v1.2Antons Kranga
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSAntons Kranga
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smellAntons Kranga
 
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesJava Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesAntons Kranga
 
OpenSlava 2015 When DevOps Hurts
OpenSlava 2015 When DevOps HurtsOpenSlava 2015 When DevOps Hurts
OpenSlava 2015 When DevOps HurtsAntons Kranga
 
OpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outOpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outAntons Kranga
 
OpenSlava Infrastructure Automation Patterns
OpenSlava   Infrastructure Automation PatternsOpenSlava   Infrastructure Automation Patterns
OpenSlava Infrastructure Automation PatternsAntons Kranga
 

More from Antons Kranga (12)

DevOps.2D: two dimensions
of engineering
DevOps.2D: two dimensions
of  engineeringDevOps.2D: two dimensions
of  engineering
DevOps.2D: two dimensions
of engineering
 
Top conf serverlezz
Top conf   serverlezzTop conf   serverlezz
Top conf serverlezz
 
Riga DevDays 2017 - Efficient AWS Lambda
Riga DevDays 2017 - Efficient AWS LambdaRiga DevDays 2017 - Efficient AWS Lambda
Riga DevDays 2017 - Efficient AWS Lambda
 
DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless Architecture
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
 
Dev ops with smell v1.2
Dev ops with smell v1.2Dev ops with smell v1.2
Dev ops with smell v1.2
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWS
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smell
 
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesJava Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
 
OpenSlava 2015 When DevOps Hurts
OpenSlava 2015 When DevOps HurtsOpenSlava 2015 When DevOps Hurts
OpenSlava 2015 When DevOps Hurts
 
OpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outOpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-out
 
OpenSlava Infrastructure Automation Patterns
OpenSlava   Infrastructure Automation PatternsOpenSlava   Infrastructure Automation Patterns
OpenSlava Infrastructure Automation Patterns
 

Recently uploaded

Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 

Recently uploaded (20)

Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 

DevOps hackathon Session 2: Basics of Chef

  • 1. Provisioning part You can download me here: https://github.com/akranga/devops-hackathon-2
  • 3. Infrastructure as Code - Declarative approach: You describe what you want to get, not how - You describe state of the VM you want to achieve in cookbook or manifest. - Chef (or other tool like Puppet or Ansible) will bring your VM into described state - This operation called provisioning or convergence include_recipe "java" package "tomcat6" service "tomcat6" do action [:enable, :start] end
  • 4. Cookbooks vs Scripts - Cookbooks are repeatable - Cookbooks are unit testable - Cookbooks has dependencies and versions - Cookbooks are written on Ruby DSL - Over 1300+ cookbooks available from the community - For Ops: no programming experience required - For Devs: no sys-admin experience required include_recipe "java" package "tomcat6" service "tomcat6" do action [:enable, :start] end
  • 5. Chef - Very popular provisioning tool - Huge community
  • 6. Vagrant and Chef - Vagrant manages VM (operates outside) - Vagrant triggers Chef (provisioning) - Chef runs inside existingVM - Chef installs Services (Tomcat, MySQL, RabbitMQ)
  • 7. Use Cases - DevOps are using Vagrant + Chef for Cookbook development - Dev & QA are using t host environment locally - Ops using test deployments before roll-out to prod - Jenkins using to run Infrastructure Automation Tests - Jenkins using to do true Integration Tests of the App +
  • 8. recipe example Cookbooks vs Scripts - Cookbooks are repeatable - Cookbooks are unit testable - Cookbooks are written on Ruby DSL - Over 1300+ cookbooks available from the community - For Ops: no programming experience required - For Devs: no sys-admin experience required include_recipe "java" package "tomcat6" service "tomcat6" do action [:enable, :start] end
  • 9. How does it works - Chef is an app that installed on VM (node) - Chef reads a “run list” of cookbooks and recipes - Chef detects attributes of the VM (OS, RAM, IP address, hostname) - Chef adds custom attributes defined in cookbook (version of java, database port) - Chef transforms recipes and attributes to OS specific instructions and runs convergence Recipe Attributes OS Specific Instructions
  • 11. Cookbook Content - Attributes: contains configurable parameters (database port, mirror URL) - Recipes: describes resources for chef (package to install, users to create etc) - Templates: contains custom configuration that you want to apply - Metadata: file that describes cookbook name, version, supported OS etc - Readme: meaningful file for User Most common cookbook have structure as following cookbook structure mycookbook /attributes /recipes /templates metadata.rb README.md
  • 12. cookbook structure Attributes - Attributes defined in file <cookbook>/attributes/default.rb - Recipe specific attributes can be defined in file <cookbook>/attributes/<recipe_name>.rb - Attributes are hierarchical (structured as multi dimensional map) - Attributes can be defined as default[:tomcat][:home] = "/var/tomat“ (valid ruby code) - Attributes can be accessed in recipe or template as the following node.tomcat.home or node[:tomcat][:home] mycookbook /attributes default.rb <recipe>.rb /recipes /templates metadata.rb README.md All cookbook configurables can be exposed as attributes. Cookbook contains default attributes that user can override with their own All about attributes: http://docs.opscode.com/chef_overview_attributes.html
  • 13. cookbook structure Recipes mycookbook /attributes /recipes default.rb <other_recipe>.rb /templates metadata.rb README.md Recipe describes resources for chef convergence. Cookbook should have at least “default” recipe. Recipes ordered in the chef run list. Single web page for Chef resoruces: http://docs.opscode.com/resources.html - package: a software package that will be installed from package manager (apt, yum) - service: a service in: /etc/init.d :enable – enable service to autorun :start, :stop, :restart, :reload - user: user that will be created or updated - directory: directory to be created - remote_file: file to be downloaded from remote host - tempalte: a file in VM rendered from ERB template (templates directory
  • 14. cookbook structure References inside recipes mycookbook /attributes /recipes default.rb <other_recipe>.rb /templates metadata.rb README.md Single web page for Chef resoruces: http://docs.opscode.com/resources.html - You can refer to another recipe by calling include_recipe "mysql::server" - Reference just by cookbook name assumes “default” recipe of that cookbook include_recipe "java" same as include_recipe "java::default" - “Other” cookbook must be declared in metadata.rb as depends “java"
  • 15. cookbook structure Recipe references mycookbook /attributes /recipes /templates /default apache.conf.erb /redhat apache.conf.erb metadata.rb README.md Single web page for Chef resoruces: http://docs.opscode.com/resources.html - Template files stored in directory /template/default - OS specific templates can be stored in /template/<os-type> - Node attributes can be referenced inside template as <%= node.tomcat.port %> Templates are typically be populated with VM (node) attributes and rendered as a configuration file. Templates follow ERB semantics
  • 16. cookbook structure Metadata mycookbook /attributes /recipes /templates metadata.rb README.md Single web page for Chef resoruces: http://docs.opscode.com/resources.html - Template files stored in directory /template/default - OS specific templates can be stored in /template/<os-type> - Node attributes can be referenced inside template as <%= node.tomcat.port %> Chef has dependency management between cookbooks. Each cookbook should have following data
  • 17. Activity 1 Create a custom cookbook that - Installs and configures nginx
  • 18. Berksfile: TODO2 Vagrantfile: TODO1 Activity 1 Go to /activity1 directory 1. Enable Chef at Vagrantfile: by adding following lines: config.omnibus.chef_version = :latest config.berkshelf.enabled = true 2. Add cookbooks to Berkshelf file: This will instruct Vagrant to use latest Chef from Omnibus package Second line will instruct vagrant to activate Cookbook dependency manager cookbook "apt" cookbook "my_webserver", path: "cookbooks/mynginx" Apt cookbook will be installed from Chef website my_webserver cookbook we will just create
  • 19. my_webserver::default TODO4 Activity 1 3. Add cookbooks to the Vagrantfile runlist 4. Add some logic to my_webserver cookbook. Modify default recipe and add instructuion to download nginx from package manager package "nginx" Vagrantfile: TODO3 chef.add_recipe "apt" chef.add_recipe "my_webserver" These cookbooks will be delivered to Vagrant by instructions specified in Berksfile
  • 20. my_webserver::default TODO5 Activity 1 5. Add resource that will declare service “nginx”. Enable it as auto-run and start it service "nginx" do action [ :enable, :start ] end 6. Start vagrant machine $ vagrant up If you have existing vagrant VM (not empty) you might want to destroy it $ vagrant destroy --force $ vagrant up 7. Go to http://localhost:2080 with your browser
  • 21. Activity 2 Add Tomcat and Java to web server Reconfigure nginx to work as reverse proxy
  • 22. Vagrantfile: TODO2 Berksfile: TODO1 Activity 2 Go to /activity2 directory 1. Add new cookbooks to the Berksfile cookbook "java" cookbook "tomcat" 2. Add tomcat and Java to your VM provisioning run list: This will instruct Vagrant to use latest Chef from Omnibus package Second line will instruct vagrant to activate Cookbook dependency manager chef.add_recipe "java" chef.add_recipe "tomcat"
  • 23. Activity 2 6. Add cookbooks to the Vagrantfile runlist 4. Run the VM # vagrant up --provision Vagrantfile: TODO3 config.vm.network :forwarded_port, guest: 8080, host: 8080 config.vm.network :forwarded_port, guest: 8443, host: 8443 8080 is a HTTP port for Tomcat 8443 is a HTTPS port for Tomcat 5. With your browser go to: http://localhost:2080 and http://localhost:8080
  • 24. Activity 2 7. Add attributes to the attributes/default.rb file 8. Add synced directory to Vagrantfile attributes/default.rb: TODO4 default.nginx.port = 80 default.nginx.www_docs = "/var/www/html" We will make nginx port 80 and htdocs directory configurable Vagrantfile: TODO5 config.vm.synced_folder "webapp/", "/var/www/html" This will deliver our custom html page to the vagrant VM
  • 25. Activity 2 9. Change default-site.erb template 9. Modify code in recipe tomcat_proxy.rb default-site.erb: TODO6 <%= node.nginx.www_docs %>; my_webserver::tomcat_proxy TODO8 template "/etc/nginx/sites-available/default" do source "default-site.erb" end This will instruct chef to replace nginx default site configuration with file rendered from templates default-site.erb: TODO7 <%= node.tomcat.port %> This attribute will be taken from attributes/default.rb file This attribute will be taken from Tomcat cookbook (it is in VM run list)
  • 26. Activity 2 10. Add logic that will notify service declared in “default.rb” recipe to reload after template have been rendered. Please change yellow line my_webserver::tomcat_proxy TODO9 template "/etc/nginx/sites-available/default" do source "default-site.erb” notifies :reload, "service[nginx]" end We must instruct service that it should support “service reload” action (which is disabled by default) my_webserver::default TODO10 service "nginx" do action [ :enable, :start ] supports :reload => true end
  • 27. Activity 2 10. Reload vagrant with one of the following commands 11. With your browser go to: http://localhost:2080 http://localhost:2080/static $ vagrant reload –provision $ vagrant provision $ vagrant up --provision
  • 28. Fixing Vagrant-Berkshelf - Use Vagrant Version 1.4.3 - Run: vagrant plugin install vagrant-berkshelf --plugin-version "< 2.0.0"
  • 29. Activity 3 (install mysql server) Add Tomcat and Java to web server Reconfigure nginx to work as reverse proxy
  • 30. Vagrantfile: TODO2 Change: TODO1 Activity 3 Go to /activity3 directory 1. Change Berkshelf file to include mysql cookbook cookbook "mysql" 2. Add mapping of port 3306 config.vm.network :forwarded_port, guest: 3306, host: 3306 Vagrantfile: TODO3 "mysql" => { "server_root_password" => "secret" } 3. By default mysql password can be found below (we will override it): https://github.com/opscode-cookbooks/mysql/blob/master/attributes/default.rb