SlideShare une entreprise Scribd logo
1  sur  41
AnsibleAutomate everything
DevOps North East
Soroush Atarod – @_atarod
https://infinitypp.com
 Thanks Creative Agile for sponsoring the talk 
Life before using Ansible
• Shell Scripts……
• New Server, New Nightmare…….….
• Things go wrong, SSH in manual process………………..….
Current Automation products
• Chef
• Puppet
• SaltStack
• Ansible
What made me to select Ansible?
• Uses YAML. - very easy to learn but difficult to master
• Agentless.
• Easy to add custom modules.
• Ansible Tower
Introduction to Ansible
• Released in 2012.
• Acquired by Red Hat in October 2015.
• Developed in Python.
• Current version: 2.6
• 1850 Modules (from cloud providers, network, windows many more)
How does Ansible works? – Inventory files
Inventory
[web]
192.168.2.4
192.134.2.5
[db]
123.232.2.45
How does Ansible works?
Inventory
[web]
192.168.2.4
192.134.2.5
[db]
123.232.2.45
Playbook
- A single YAML file
- Define tasks
- Actions to perform
- Ex: install a package, restart
service
How does Ansible works?
Inventory
[web]
192.168.2.4
192.134.2.5
[db]
123.232.2.45
Playbook
- A single YAML file
- Define tasks
- Actions to perform
- Ex: install a package, restart
service
--------
Example: setup.yml
Hosts: web
Name: install Apache
Yum:
name: httpd
state: present
Modules
Yum
Service
Vmware
Aws
Azure
Mysql
Mongodb
1850 Modules!
Inventory files
•Stores details about the server
1. IP address
2. Username
3. Password
4. SSH Key
Inventory files - Example
[loadbalancer]
192.168.2.23
[webservers]
123.23.43.5
123.23.43.6
123.23.43.7
123.23.43.8
[dbservers]
172.12.65.34
Inventory files
Inventory files – better
[loadbalancer]
192.168.2.23
[webservers]
123.23.43.[5:65]
[dbservers]
172.12.65.34
RANGE
OPERATOR
Ansible Tasks
• Functions that perform an action
Tasks:
- name: install Apache
yum:
name: httpd
state: present
- name: start apache
service:
name: httpd
state: started
We are using two modules
1.YUM
2.Service
2.1Ansible Tasks - for loops
- name: install PHP packages
yum:
name: {{ item }}
with_items:
php72
php72-mysql
php72-common
- with_item = for loop in Programming terminology.  :O
For ($items as $item) {
yum install $item
}
2.1Ansible Handlers
- Hosts: web
- Tasks:
- name: install apache
apt-get: name=apache2 state=present
- name: enable mod_ssl
apache2_module: name= mod_ssl state=present
- Handlers:
- name: restart apache2
service: name=apache2 state:reloaded
2.1Ansible Handlers
- Hosts: web
- Tasks:
- name: install apache
apt-get: name=apache2 state=present
- name: enable mod_ssl
apache2_module: name= mod_ssl state=present
notify: restart apache2
- Handlers:
- name: restart apache2
service: name=apache2 state:reloaded
Ansible task best practice
Naming of task:
- mention the intent of the task
current name
- name: install PHP
Better name
- name: install PHP even if it doesn’t exist
Ansible ROLES
- Responsible to do one thing.
- Install Apache only
- Install PHP only.
- Code reuse
Ansible ROLES
Roles
apache
php
mysql
common
3.1 Ansible ROLES
create roles:
ansible-galaxy init apache
apache
- defaults
- handlers
- meta
- tasks
- tests
- vars
3.1 Ansible ROLES
create roles:
ansible-galaxy init apache
apache
- defaults –variables
- handlers – we define handlers here
- meta – description of the role
- tasks - define the main task ex: install python, etc
- tests. - test script
- vars. - variables
3.1 Ansible ROLES - variables
create roles:
ansible-galaxy init apache
two places to place your variables
1. Defaults directory – gets overridden by the “vars” directory
2. Vars directory
3.3 Ansible ROLES - variables
where to save variables?
If (varibles->shouldBeOverridden ) {
place variables in defaults
} else {.
place variables in vars
}
3.3 Ansible Galaxy
• https://galaxy.ansible.com/home
• Public registry of roles.
• Download community roles to speed up the process.
• More than 15,000 roles to download.
• Downloading roles is very easy
• This installs a hosts management role ready to use!
ansible-galaxy install ajsalminen.hosts
Ansible Tower
- Web application to manage and run playbooks.
- Gives anyone the permission to run a playbook.
- Example: users in the group ”Database developer” can
run “database playbook” only.
- Lets playbooks to be reused.
Ansible Tower demo
https://aws.amazon.com/premiumsupport/knowledge-center/blocked-mysql-query/
Use case:
A query to my Amazon RDS for MySQL instance was
blocked, but no other queries were executing at the time
Solution:
Create a playbook that performs the manual job in
Ansible.
Give DB admins the access to this playbook only in
Ansible Tower.
Deployment strategies using Ansible
1. Blue-Green deployment
2. Zero-downtime deployment across multiple server
3. Single deployment
Zero-downtime deployment
- How to deploy applications across multiple servers
with zero-downtime deployment?
- Ansible provides “serial” keyword.
- Deploys on a selection of instances, if test passes
deploys to other instances!
Zero-downtime deployment
- 1 Load Balancer, 4 servers.
Zero-downtime deployment
Serial keyword
Deploy.yml  playbook that deploys
hosts: webservers
Serial: 2
Roles:
- app
Zero-downtime deployment
Serial
Deploy.yml
hosts: webservers
Serial: 2
Roles:
- app
4 servers.
Serial is set to 2
Ansible deploys to two instances. If the test
passes, continues the deployment to the rest.
Zero-downtime deployment
Serial
Deploy.yml
hosts: webservers
Serial: 2
Roles:
- app
Name: pull master branch
Git:
repo: ‘https://github.com/ere/apple.git
version: release-1.2
dest: /var/www/project/
uri:
url: http://localhost.com/health-status
return_content: yes
Register: webpage
name: Fail if we find FAILED in the page
Fail:
When: ” ‘FAILED’ ” not in webpage.content
Ansible Containers
- Ansible-Container can use Ansible roles to
provision Docker containers.
- Long Docker files can be rewritten in Ansible roles.
- Ansible installs the roles in a Docker image and
pushes it to Docker hub.
Ansible Containers
- How to begin?
- Download the GIT repo:
https://github.com/ansible/ansible-container
cd ansible-container
pip install –e .[docker,openshift]
Ansible Containers
- How to start?
1.
2. Ansible creates the directory structure.
mkdir ansible-docker-demo
cd ansible-docker-demo
ansible-container init
Ansible Containers
3. container.yml is where you list out the Docker
image and the roles you need Ansible to run on the
Docker image
Ansible Containers
Container.yml example
Version: “2”
Services:
web:
from: “centos-7”
roles:
- apache
ports:
- “80:80”
command: [“/usr/sbin/httpd”, “-D”, “FOREGROUND”]
Ansible runs the role Apache on the
Docker container with the image
“Centos 7”
It then runs the command
Key things: No Docker files . Just
Ansible Roles
Questions 
- Thank you 
- See you next month 

Contenu connexe

Tendances

What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Simplilearn
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Simplilearn
 

Tendances (20)

DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)
 
Immutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and TerraformImmutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and Terraform
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User Group
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
 
Continuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsContinuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub Actions
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Ansible
AnsibleAnsible
Ansible
 
Chef - Infrastructure Automation for the Masses
Chef - Infrastructure Automation for the Masses�Chef - Infrastructure Automation for the Masses�
Chef - Infrastructure Automation for the Masses
 
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with Ansible
 
Ansible
AnsibleAnsible
Ansible
 

Similaire à Ansible Devops North East - slides

Similaire à Ansible Devops North East - slides (20)

ansible_rhel.pdf
ansible_rhel.pdfansible_rhel.pdf
ansible_rhel.pdf
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containers
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
 
Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetup
 
UNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptxUNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptx
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
MongoDB Management & Ansible
MongoDB Management & AnsibleMongoDB Management & Ansible
MongoDB Management & Ansible
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
Ansible with oci
Ansible with ociAnsible with oci
Ansible with oci
 
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL MeetupAnsible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
 
Getting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfGetting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdf
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Ansible Devops North East - slides

  • 1. AnsibleAutomate everything DevOps North East Soroush Atarod – @_atarod https://infinitypp.com  Thanks Creative Agile for sponsoring the talk 
  • 2. Life before using Ansible • Shell Scripts…… • New Server, New Nightmare…….…. • Things go wrong, SSH in manual process………………..….
  • 3.
  • 4.
  • 5.
  • 6. Current Automation products • Chef • Puppet • SaltStack • Ansible
  • 7. What made me to select Ansible? • Uses YAML. - very easy to learn but difficult to master • Agentless. • Easy to add custom modules. • Ansible Tower
  • 8. Introduction to Ansible • Released in 2012. • Acquired by Red Hat in October 2015. • Developed in Python. • Current version: 2.6 • 1850 Modules (from cloud providers, network, windows many more)
  • 9. How does Ansible works? – Inventory files Inventory [web] 192.168.2.4 192.134.2.5 [db] 123.232.2.45
  • 10. How does Ansible works? Inventory [web] 192.168.2.4 192.134.2.5 [db] 123.232.2.45 Playbook - A single YAML file - Define tasks - Actions to perform - Ex: install a package, restart service
  • 11. How does Ansible works? Inventory [web] 192.168.2.4 192.134.2.5 [db] 123.232.2.45 Playbook - A single YAML file - Define tasks - Actions to perform - Ex: install a package, restart service -------- Example: setup.yml Hosts: web Name: install Apache Yum: name: httpd state: present Modules Yum Service Vmware Aws Azure Mysql Mongodb 1850 Modules!
  • 12. Inventory files •Stores details about the server 1. IP address 2. Username 3. Password 4. SSH Key
  • 13. Inventory files - Example [loadbalancer] 192.168.2.23 [webservers] 123.23.43.5 123.23.43.6 123.23.43.7 123.23.43.8 [dbservers] 172.12.65.34
  • 15. Inventory files – better [loadbalancer] 192.168.2.23 [webservers] 123.23.43.[5:65] [dbservers] 172.12.65.34 RANGE OPERATOR
  • 16. Ansible Tasks • Functions that perform an action Tasks: - name: install Apache yum: name: httpd state: present - name: start apache service: name: httpd state: started We are using two modules 1.YUM 2.Service
  • 17. 2.1Ansible Tasks - for loops - name: install PHP packages yum: name: {{ item }} with_items: php72 php72-mysql php72-common - with_item = for loop in Programming terminology.  :O For ($items as $item) { yum install $item }
  • 18. 2.1Ansible Handlers - Hosts: web - Tasks: - name: install apache apt-get: name=apache2 state=present - name: enable mod_ssl apache2_module: name= mod_ssl state=present - Handlers: - name: restart apache2 service: name=apache2 state:reloaded
  • 19. 2.1Ansible Handlers - Hosts: web - Tasks: - name: install apache apt-get: name=apache2 state=present - name: enable mod_ssl apache2_module: name= mod_ssl state=present notify: restart apache2 - Handlers: - name: restart apache2 service: name=apache2 state:reloaded
  • 20. Ansible task best practice Naming of task: - mention the intent of the task current name - name: install PHP Better name - name: install PHP even if it doesn’t exist
  • 21. Ansible ROLES - Responsible to do one thing. - Install Apache only - Install PHP only. - Code reuse
  • 23. 3.1 Ansible ROLES create roles: ansible-galaxy init apache apache - defaults - handlers - meta - tasks - tests - vars
  • 24. 3.1 Ansible ROLES create roles: ansible-galaxy init apache apache - defaults –variables - handlers – we define handlers here - meta – description of the role - tasks - define the main task ex: install python, etc - tests. - test script - vars. - variables
  • 25. 3.1 Ansible ROLES - variables create roles: ansible-galaxy init apache two places to place your variables 1. Defaults directory – gets overridden by the “vars” directory 2. Vars directory
  • 26. 3.3 Ansible ROLES - variables where to save variables? If (varibles->shouldBeOverridden ) { place variables in defaults } else {. place variables in vars }
  • 27. 3.3 Ansible Galaxy • https://galaxy.ansible.com/home • Public registry of roles. • Download community roles to speed up the process. • More than 15,000 roles to download. • Downloading roles is very easy • This installs a hosts management role ready to use! ansible-galaxy install ajsalminen.hosts
  • 28. Ansible Tower - Web application to manage and run playbooks. - Gives anyone the permission to run a playbook. - Example: users in the group ”Database developer” can run “database playbook” only. - Lets playbooks to be reused.
  • 29. Ansible Tower demo https://aws.amazon.com/premiumsupport/knowledge-center/blocked-mysql-query/ Use case: A query to my Amazon RDS for MySQL instance was blocked, but no other queries were executing at the time Solution: Create a playbook that performs the manual job in Ansible. Give DB admins the access to this playbook only in Ansible Tower.
  • 30. Deployment strategies using Ansible 1. Blue-Green deployment 2. Zero-downtime deployment across multiple server 3. Single deployment
  • 31. Zero-downtime deployment - How to deploy applications across multiple servers with zero-downtime deployment? - Ansible provides “serial” keyword. - Deploys on a selection of instances, if test passes deploys to other instances!
  • 32. Zero-downtime deployment - 1 Load Balancer, 4 servers.
  • 33. Zero-downtime deployment Serial keyword Deploy.yml  playbook that deploys hosts: webservers Serial: 2 Roles: - app
  • 34. Zero-downtime deployment Serial Deploy.yml hosts: webservers Serial: 2 Roles: - app 4 servers. Serial is set to 2 Ansible deploys to two instances. If the test passes, continues the deployment to the rest.
  • 35. Zero-downtime deployment Serial Deploy.yml hosts: webservers Serial: 2 Roles: - app Name: pull master branch Git: repo: ‘https://github.com/ere/apple.git version: release-1.2 dest: /var/www/project/ uri: url: http://localhost.com/health-status return_content: yes Register: webpage name: Fail if we find FAILED in the page Fail: When: ” ‘FAILED’ ” not in webpage.content
  • 36. Ansible Containers - Ansible-Container can use Ansible roles to provision Docker containers. - Long Docker files can be rewritten in Ansible roles. - Ansible installs the roles in a Docker image and pushes it to Docker hub.
  • 37. Ansible Containers - How to begin? - Download the GIT repo: https://github.com/ansible/ansible-container cd ansible-container pip install –e .[docker,openshift]
  • 38. Ansible Containers - How to start? 1. 2. Ansible creates the directory structure. mkdir ansible-docker-demo cd ansible-docker-demo ansible-container init
  • 39. Ansible Containers 3. container.yml is where you list out the Docker image and the roles you need Ansible to run on the Docker image
  • 40. Ansible Containers Container.yml example Version: “2” Services: web: from: “centos-7” roles: - apache ports: - “80:80” command: [“/usr/sbin/httpd”, “-D”, “FOREGROUND”] Ansible runs the role Apache on the Docker container with the image “Centos 7” It then runs the command Key things: No Docker files . Just Ansible Roles
  • 41. Questions  - Thank you  - See you next month 