SlideShare a Scribd company logo
Top 10 Ansible Tips – Jan 2018
Viresh Doshi’s top tips based on 1
year working as an DevOps Engineer
for a container shipping company.
About me
• Over 20 years IT experience
• Started my career working on Air Traffic Systems
with Lockheed Martin
• I have three young kids who hopefully have no
interest in computing!
• I remember life when social meant going down
the pub with your mates
• I love the challenge of making a positive change
• Enjoy getting muddy
Recent work history
Maersk Schlumberger ARM
Grass Valley
What is Ansible?
• Ansible is a tool that works over SSH to
configure servers and software in a reliable
and repeatable way.
• It satisfies the principle DevOps practice of
Infrastructure as Code (IaC)
Other IT automation tools?
• Puppet
• Chef
• Salt
• DSC ( on windows)
The top 10 list
Add a README.md
Unit test your Ansible Role using Molecule
Use name and debug modules
Connect your roles to a Jenkins CI server
Use python virtualenv
Use Jina2 templates
Abide by idempotent state
Use variables for everything
Split your tasks up into individual files
Share with the open source community
TOP 10
Lets go through the top 10 in some more detail
10
README
• Scenario: you have a repository in github that
you have knocked up quickly to satisfy your
immediate goal that is wired into your CD tool
• Problem: you come back to that repo or a
team member has to modify it but they don’t
know what it does because there isn’t the
basic README.
README
• README.md files are like the index.html files
of a website.
• It’s the first landing page for a repo
• It uses markup language for annotation
• Add images/diagrams
• Improves the overall quality
• Makes you look like a devops professional
9
UNIT TEST USING MOLECULE
• Scenario: when we write code, we always (
cough, cough) create an associated unit test.
• Problem: Where is your unittest for your
ansible role?
UNIT TEST USING MOLECULE
What is molecule?
• https://molecule.readthedocs.io/en/latest/
• A framework that helps with the development
and test of ansible roles
• Works really well with testinfra which is a python
module that helps test software and services on
servers.
• https://testinfra.readthedocs.io/en/latest/index.h
tml
UNIT TEST USING MOLECULE
Benefits:
• Assert that the service is started
• Assert that the configuration file is created
• Assert that the permissions are correct
• Assert that the version installed is correct
• Assert that the network interfaces are correct
• …
UNIT TEST USING MOLECULE
• How to use molecule with testinfra and docker
• $ pip install molecule
• $ pip install testinfra
• $ pip install docker
• $ molecule –init –role ansible_role –driver
docker –verifier testinfra
UNIT TEST USING MOLECULE
• What is covered?
• Ansible linting
• Flake 8 and pep8
• Idempotence
• Unit test through testinfra
8
Use name and debug modules
Don’t do this:
Do this:
- name: install unzip
package:
name: "{{ item }}"
with_items:
- unzip
- vim
- package:
name: "{{ item }}"
with_items:
- unzip
- vim
Add the name
section for better
readability
Use name and debug modules
• Debug statements are harmless and can
improve the confidence in execution
-name:Display all variables/facts known for a host
debug:
var:hostvars[inventory_hostname]
verbosity:4
7
Connect your roles to a Jenkins CI
server
• Your role will likely sit inside a git repository.
• Consider connecting the role to Jenkins CI and
run molecule test and assert on the successful
execution
6
Use python virtualenv
• You can install Ansible simply by running a couple
of commands in your Bash shell but how can you
be sure that the versions, packages,
dependencies are correct for when you want to
reliably repeat the execution?
• $ pip install virtualenv
• $ virtualenv env1 – will create a new env
• $ source env1/bin/activate
• $ pip install ansible==2.4.3
• $ which ansible
5
Use Jina2 templates
• Dynamic settings files using variables
tasks/main.yml
- name: template test
template:
src=myTemplateFile.j2
dest={{ item }}
with_dict: some_dict
vars/main.yml
some_dict:
/path/to/dest1:
var1: 1
var2: 2
/path/to/dest2:
var1: 3
var2: 4
templates/myTemplateFile.j2
test_variable = {{ item.value.var1 }}
test_var_2= {{ item.value.var2 }}
4
Abide by idempotent state
An operation is idempotent if the result of
performing it once is exactly the same as the
result of performing it repeatedly without any
intervening actions.
• specify a final state
• Command or shell module
• Molecule will test for idempotency
3
Use variables for everything
• Simple advice
• Don’t hardcode variables
• Split out variables that contain say versions
• program_linux_version_1.3.1.rpm
• Extract {{platform}} , {{version_num}}
2
Split your tasks up into individual files
• Very long playbooks are a bad practice
• Consider splitting up common tasks into
separate files and use the include module to
slurp them in
1
Share with the open source
community
• Upload your role to github
• Share on ansible-galaxy
• Create a README
• Hook up to Travis CI
Bonus list
1. Write your own Ansible module
2. Explore the usage of filters
3. Use galaxy Ansible
4. Use inventories
5. love Python
6. Drink coffee

More Related Content

What's hot

Testing for infra code using test-kitchen,docker,chef
Testing for infra code using  test-kitchen,docker,chefTesting for infra code using  test-kitchen,docker,chef
Testing for infra code using test-kitchen,docker,chef
kamalikamj
 
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Gareth Bowles
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
Larry Cai
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case Study
Michael Lihs
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
Drone your Ansible
Drone your AnsibleDrone your Ansible
Drone your Ansible
Dennis Rowe
 
CLUG 2014-10 - Cookbook CI with Jenkins
CLUG 2014-10 - Cookbook CI with JenkinsCLUG 2014-10 - Cookbook CI with Jenkins
CLUG 2014-10 - Cookbook CI with Jenkins
Zachary Stevens
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
devopsjourney
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
Jeffery Smith
 
Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021
Joe Ferguson
 
Grooving with Jenkins
Grooving with JenkinsGrooving with Jenkins
Grooving with Jenkins
Anton Weiss
 
JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...
JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...
JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...
CloudBees
 
Learning chef
Learning chefLearning chef
Learning chef
Jonathan Carrillo
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Marcel Birkner
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
Ranjib Dey
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker Chef
Sean OMeara
 
Superb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with SensuSuperb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with Sensu
Paul O'Connor
 
Chef Cookbook Workflow
Chef Cookbook WorkflowChef Cookbook Workflow
Chef Cookbook Workflow
Amazon Web Services
 
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and MaintenanceJUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
CloudBees
 
Fits docker into devops
Fits docker into devopsFits docker into devops
Fits docker into devops
Evans Ye
 

What's hot (20)

Testing for infra code using test-kitchen,docker,chef
Testing for infra code using  test-kitchen,docker,chefTesting for infra code using  test-kitchen,docker,chef
Testing for infra code using test-kitchen,docker,chef
 
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case Study
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
Drone your Ansible
Drone your AnsibleDrone your Ansible
Drone your Ansible
 
CLUG 2014-10 - Cookbook CI with Jenkins
CLUG 2014-10 - Cookbook CI with JenkinsCLUG 2014-10 - Cookbook CI with Jenkins
CLUG 2014-10 - Cookbook CI with Jenkins
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
 
Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021
 
Grooving with Jenkins
Grooving with JenkinsGrooving with Jenkins
Grooving with Jenkins
 
JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...
JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...
JUC Europe 2015: Jenkins-Based Continuous Integration for Heterogeneous Hardw...
 
Learning chef
Learning chefLearning chef
Learning chef
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker Chef
 
Superb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with SensuSuperb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with Sensu
 
Chef Cookbook Workflow
Chef Cookbook WorkflowChef Cookbook Workflow
Chef Cookbook Workflow
 
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and MaintenanceJUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
JUC Europe 2015: Scaling of Jenkins Pipeline Creation and Maintenance
 
Fits docker into devops
Fits docker into devopsFits docker into devops
Fits docker into devops
 

Similar to Ansible top 10 - 2018

TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
Michael Lihs
 
Devops
DevopsDevops
Devops
JyothirmaiG4
 
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Bootstrapping Puppet and Application Deployment - PuppetConf 2013Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Puppet
 
Vagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVagrant for Effective DevOps Culture
Vagrant for Effective DevOps Culture
Vaidik Kapoor
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
SQALab
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Edureka!
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Richard Bullington-McGuire
 
Jest: Frontend Testing richtig gemacht @WebworkerNRW
Jest: Frontend Testing richtig gemacht @WebworkerNRWJest: Frontend Testing richtig gemacht @WebworkerNRW
Jest: Frontend Testing richtig gemacht @WebworkerNRW
Holger Grosse-Plankermann
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Борис Зора
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
Einar Ingebrigtsen
 
Kubernetes @ meetic
Kubernetes @ meeticKubernetes @ meetic
Kubernetes @ meetic
Sébastien Le Gall
 
DevOps demystified
DevOps demystifiedDevOps demystified
DevOps demystified
Xebia IT Architects
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
Claudio Beatrice
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Gaetano Giunta
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
Geoff Harcourt
 
Introduction to Puppet Scripting
Introduction to Puppet ScriptingIntroduction to Puppet Scripting
Introduction to Puppet Scripting
Achieve Internet
 
Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016
Thomas Shaw
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
Vlad Fedosov
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
Samuel Brown
 

Similar to Ansible top 10 - 2018 (20)

TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
 
Devops
DevopsDevops
Devops
 
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Bootstrapping Puppet and Application Deployment - PuppetConf 2013Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
 
Vagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVagrant for Effective DevOps Culture
Vagrant for Effective DevOps Culture
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
 
Jest: Frontend Testing richtig gemacht @WebworkerNRW
Jest: Frontend Testing richtig gemacht @WebworkerNRWJest: Frontend Testing richtig gemacht @WebworkerNRW
Jest: Frontend Testing richtig gemacht @WebworkerNRW
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Kubernetes @ meetic
Kubernetes @ meeticKubernetes @ meetic
Kubernetes @ meetic
 
DevOps demystified
DevOps demystifiedDevOps demystified
DevOps demystified
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Introduction to Puppet Scripting
Introduction to Puppet ScriptingIntroduction to Puppet Scripting
Introduction to Puppet Scripting
 
Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
 

More from Viresh Doshi

DevOps terms for 2018
DevOps terms for 2018DevOps terms for 2018
DevOps terms for 2018
Viresh Doshi
 
Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges
Viresh Doshi
 
Scrum master motivation role
Scrum master motivation roleScrum master motivation role
Scrum master motivation role
Viresh Doshi
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agile
Viresh Doshi
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startup
Viresh Doshi
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
Viresh Doshi
 
Coding using jscript test complete
Coding using jscript test completeCoding using jscript test complete
Coding using jscript test complete
Viresh Doshi
 
Capital markets testing - Calypso
Capital markets testing - CalypsoCapital markets testing - Calypso
Capital markets testing - Calypso
Viresh Doshi
 
Collaboration in testing
Collaboration in testingCollaboration in testing
Collaboration in testing
Viresh Doshi
 

More from Viresh Doshi (9)

DevOps terms for 2018
DevOps terms for 2018DevOps terms for 2018
DevOps terms for 2018
 
Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges
 
Scrum master motivation role
Scrum master motivation roleScrum master motivation role
Scrum master motivation role
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agile
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startup
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
 
Coding using jscript test complete
Coding using jscript test completeCoding using jscript test complete
Coding using jscript test complete
 
Capital markets testing - Calypso
Capital markets testing - CalypsoCapital markets testing - Calypso
Capital markets testing - Calypso
 
Collaboration in testing
Collaboration in testingCollaboration in testing
Collaboration in testing
 

Recently uploaded

Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
gaafergoudaay7aga
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
Data Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptxData Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptx
ramrag33
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
Mahmoud Morsy
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 

Recently uploaded (20)

Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
Data Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptxData Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptx
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 

Ansible top 10 - 2018

  • 1. Top 10 Ansible Tips – Jan 2018 Viresh Doshi’s top tips based on 1 year working as an DevOps Engineer for a container shipping company.
  • 2. About me • Over 20 years IT experience • Started my career working on Air Traffic Systems with Lockheed Martin • I have three young kids who hopefully have no interest in computing! • I remember life when social meant going down the pub with your mates • I love the challenge of making a positive change • Enjoy getting muddy
  • 3. Recent work history Maersk Schlumberger ARM Grass Valley
  • 4. What is Ansible? • Ansible is a tool that works over SSH to configure servers and software in a reliable and repeatable way. • It satisfies the principle DevOps practice of Infrastructure as Code (IaC)
  • 5. Other IT automation tools? • Puppet • Chef • Salt • DSC ( on windows)
  • 6. The top 10 list Add a README.md Unit test your Ansible Role using Molecule Use name and debug modules Connect your roles to a Jenkins CI server Use python virtualenv Use Jina2 templates Abide by idempotent state Use variables for everything Split your tasks up into individual files Share with the open source community
  • 7. TOP 10 Lets go through the top 10 in some more detail
  • 8. 10
  • 9. README • Scenario: you have a repository in github that you have knocked up quickly to satisfy your immediate goal that is wired into your CD tool • Problem: you come back to that repo or a team member has to modify it but they don’t know what it does because there isn’t the basic README.
  • 10. README • README.md files are like the index.html files of a website. • It’s the first landing page for a repo • It uses markup language for annotation • Add images/diagrams • Improves the overall quality • Makes you look like a devops professional
  • 11. 9
  • 12. UNIT TEST USING MOLECULE • Scenario: when we write code, we always ( cough, cough) create an associated unit test. • Problem: Where is your unittest for your ansible role?
  • 13. UNIT TEST USING MOLECULE What is molecule? • https://molecule.readthedocs.io/en/latest/ • A framework that helps with the development and test of ansible roles • Works really well with testinfra which is a python module that helps test software and services on servers. • https://testinfra.readthedocs.io/en/latest/index.h tml
  • 14. UNIT TEST USING MOLECULE Benefits: • Assert that the service is started • Assert that the configuration file is created • Assert that the permissions are correct • Assert that the version installed is correct • Assert that the network interfaces are correct • …
  • 15. UNIT TEST USING MOLECULE • How to use molecule with testinfra and docker • $ pip install molecule • $ pip install testinfra • $ pip install docker • $ molecule –init –role ansible_role –driver docker –verifier testinfra
  • 16. UNIT TEST USING MOLECULE • What is covered? • Ansible linting • Flake 8 and pep8 • Idempotence • Unit test through testinfra
  • 17. 8
  • 18. Use name and debug modules Don’t do this: Do this: - name: install unzip package: name: "{{ item }}" with_items: - unzip - vim - package: name: "{{ item }}" with_items: - unzip - vim Add the name section for better readability
  • 19. Use name and debug modules • Debug statements are harmless and can improve the confidence in execution -name:Display all variables/facts known for a host debug: var:hostvars[inventory_hostname] verbosity:4
  • 20. 7
  • 21. Connect your roles to a Jenkins CI server • Your role will likely sit inside a git repository. • Consider connecting the role to Jenkins CI and run molecule test and assert on the successful execution
  • 22. 6
  • 23. Use python virtualenv • You can install Ansible simply by running a couple of commands in your Bash shell but how can you be sure that the versions, packages, dependencies are correct for when you want to reliably repeat the execution? • $ pip install virtualenv • $ virtualenv env1 – will create a new env • $ source env1/bin/activate • $ pip install ansible==2.4.3 • $ which ansible
  • 24. 5
  • 25. Use Jina2 templates • Dynamic settings files using variables tasks/main.yml - name: template test template: src=myTemplateFile.j2 dest={{ item }} with_dict: some_dict vars/main.yml some_dict: /path/to/dest1: var1: 1 var2: 2 /path/to/dest2: var1: 3 var2: 4 templates/myTemplateFile.j2 test_variable = {{ item.value.var1 }} test_var_2= {{ item.value.var2 }}
  • 26. 4
  • 27. Abide by idempotent state An operation is idempotent if the result of performing it once is exactly the same as the result of performing it repeatedly without any intervening actions. • specify a final state • Command or shell module • Molecule will test for idempotency
  • 28. 3
  • 29. Use variables for everything • Simple advice • Don’t hardcode variables • Split out variables that contain say versions • program_linux_version_1.3.1.rpm • Extract {{platform}} , {{version_num}}
  • 30. 2
  • 31. Split your tasks up into individual files • Very long playbooks are a bad practice • Consider splitting up common tasks into separate files and use the include module to slurp them in
  • 32. 1
  • 33. Share with the open source community • Upload your role to github • Share on ansible-galaxy • Create a README • Hook up to Travis CI
  • 34. Bonus list 1. Write your own Ansible module 2. Explore the usage of filters 3. Use galaxy Ansible 4. Use inventories 5. love Python 6. Drink coffee