SlideShare une entreprise Scribd logo
1  sur  34
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

Contenu connexe

Tendances

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,chefkamalikamj
 
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 90minsLarry Cai
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case StudyMichael 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-20Michael Lihs
 
Drone your Ansible
Drone your AnsibleDrone your Ansible
Drone your AnsibleDennis 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 JenkinsZachary Stevens
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbookdevopsjourney
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development WorkflowJeffery 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 2021Joe Ferguson
 
Grooving with Jenkins
Grooving with JenkinsGrooving with Jenkins
Grooving with JenkinsAnton 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
 
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 JenkinsMarcel Birkner
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure TestingRanjib Dey
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker ChefSean 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 SensuPaul O'Connor
 
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 MaintenanceCloudBees
 
Fits docker into devops
Fits docker into devopsFits docker into devops
Fits docker into devopsEvans Ye
 

Tendances (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
 

Similaire à 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 ToolsMichael Lihs
 
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 2013Puppet
 
Vagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVaidik 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 @WebworkerNRWHolger 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 developmentEinar Ingebrigtsen
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAlberto Molina Coballes
 
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 ParityGeoff Harcourt
 
Introduction to Puppet Scripting
Introduction to Puppet ScriptingIntroduction to Puppet Scripting
Introduction to Puppet ScriptingAchieve 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 2016Thomas 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 PipelineSamuel Brown
 

Similaire à 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
 

Plus de Viresh Doshi

DevOps terms for 2018
DevOps terms for 2018DevOps terms for 2018
DevOps terms for 2018Viresh 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 roleViresh Doshi
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agileViresh Doshi
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startupViresh Doshi
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automationViresh Doshi
 
Coding using jscript test complete
Coding using jscript test completeCoding using jscript test complete
Coding using jscript test completeViresh Doshi
 
Capital markets testing - Calypso
Capital markets testing - CalypsoCapital markets testing - Calypso
Capital markets testing - CalypsoViresh Doshi
 
Collaboration in testing
Collaboration in testingCollaboration in testing
Collaboration in testingViresh Doshi
 

Plus de 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
 

Dernier

Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosVictor Morales
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
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
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsapna80328
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
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
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 

Dernier (20)

Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitos
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
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
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveying
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
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
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.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