SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
Introducing Ansible
Francesco Pantano
francesco.pantano@opmbx.org
March 7, 2016
#Outline
1 A day in the life of a sysadmin
2 Automation
3 Introducing Ansible
4 Ansible Playbooks: beyond the Basics
5 Roles and Includes
6 Automating Your Automation
A day in the life of a sysadmin 2/32
The timeline
”We have the misfortune to be living in the present. In the future,
of course, computers will be smart enough to just figure out what
we want, and do it. Until then, we have to spend a lot of time
telling the computer things it should already know.”
A day in the life of a sysadmin 3/32
Keeping the configuration synchronized
A day in the life of a sysadmin 4/32
Repeating changes across many servers
The command to create a new user account is slightly different for
Red Hat Linux from the equivalent command for Ubuntu, for
example. Solaris is a little different again.
Each command is doing basically the same job, but has differences
in syntax, arguments, and default values.
A day in the life of a sysadmin 5/32
Self-updating documentation
A new sysadmin joins your organization, and he needs to know
where all the servers are, and what they do. Even if you keep
scrupulous documentation, it can’t always be relied on.
The only accurate documentation, in fact, is the servers
themselves. You can look at a server to see how it’s configured,
but that only applies while you still have the machine. If something
goes wrong and you can’t access the machine, or the data on it,
your only option is to reconstruct the lost configuration from
scratch.
Wouldn’t it be nice if you had a configuration document which was
guaranteed to be up to date?
A day in the life of a sysadmin 6/32
Version control, history, continuous integration
A day in the life of a sysadmin 7/32
#Outline
1 A day in the life of a sysadmin
2 Automation
3 Introducing Ansible
4 Ansible Playbooks: beyond the Basics
5 Roles and Includes
6 Automating Your Automation
Automation 8/32
Why Automation?
Fast deployment time
It’s cheap and flexible
Scalability and support
Standard environments
Automation as a standardized approach
IT automation is a standard approach that
combines multi-node software deployment,
ad-hoc task execution and configuration
management.
Automation 9/32
The Automation environment
Automation 10/32
IT Automation: Terminology
Idempotence: the ability to run an operation which produces the
same result whether run once or multiple times
Inventory: hosts file that defines:
the description of the nodes that can be
accessed
the IP address or hostname of each node
nodes group to run a different set of
tasks
nodes parameters such as username,
password or ssh keys
Playbooks: they express configurations, deployment and
orchestration in Ansible. Each Playbook maps a group of hosts to
a set of roles. Each role is represented by calls to Ansible call tasks.
Automation 11/32
#Outline
1 A day in the life of a sysadmin
2 Automation
3 Introducing Ansible
4 Ansible Playbooks: beyond the Basics
5 Roles and Includes
6 Automating Your Automation
Introducing Ansible 12/32
Quick Start
Linux - run natively e.g. on a Fedora/RHEL/CentOS:
yum -y install ansible
Debian or Ubuntu
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
Verify your installation
$ ansible –version
ansible 2.0.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
Introducing Ansible 13/32
Quick Start
Linux - run natively e.g. on a Fedora/RHEL/CentOS:
yum -y install ansible
Debian or Ubuntu
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
Verify your installation
$ ansible –version
ansible 2.0.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
Introducing Ansible 13/32
Quick Start
Linux - run natively e.g. on a Fedora/RHEL/CentOS:
yum -y install ansible
Debian or Ubuntu
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
Verify your installation
$ ansible –version
ansible 2.0.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
Introducing Ansible 13/32
Quick Start
Linux - run natively e.g. on a Fedora/RHEL/CentOS:
yum -y install ansible
Debian or Ubuntu
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
Verify your installation
$ ansible –version
ansible 2.0.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
Introducing Ansible 13/32
The inventory file
Where it is located
/etc/ansible/hosts
What is the format
[mailservers]
mail.example.com
[webservers]
foo.example.com ansible ssh user = user001
bar.example.com ansible ssh private key file =
/.ssh/ansible key001
[dbservers]
one.example.com
two.example.com
db-[a:f].example.com
Introducing Ansible 14/32
The inventory file
I can define a group of machines
# Group ’multi’ with all servers
[multi:children]
vm01
vm02
# Variables that will be applied to all servers
[multi:vars]
ansible ssh user=user001
ansible ssh private key file = /.ssh/pkey
..available parameters
https://docs.ansible.com/ansible/intro inventory.html
Introducing Ansible 15/32
The Ansible command line
ansible-playbook
Execute a playbook
ansible-galaxy
Roles management
ansible example -a ”free -m” -u [username]
Run the free command on the example domain
ansible example -m ping -u [username]
Run the ping command on the example domain
ansible atlanta -m copy -a ”src=/etc/hosts
dest=/tmp/hosts”
File copy using the copy module
ansible all -m user -a ”name=foo password=’crypted
password here’”
User and group management
Introducing Ansible 16/32
Your first Ansible playbook
Host section
It is related to a section of the inventory file described above
---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: name=httpd state=latest
- name: write the apache config file
template: src=/ srv/httpd.j2 dest =/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
Vars Section
Variables used to the tasks in order to parametrize something
Introducing Ansible 17/32
Your first Ansible playbook
Task section
Groups of tasks that are performed on a certain set of hosts to
allow them to fulfill the function you want to assign to them.
Notify section
This is not an internal Ansible command, it is a reference to a
handler, which can perform certain functions when it is called from
within a task.
Handlers section
Handlers are just like tasks, but they only run when they have been
told by a task that changes have occurred on the client system.
Run the playbook
ansible-playbook playbook.yml
Introducing Ansible 18/32
#Outline
1 A day in the life of a sysadmin
2 Automation
3 Introducing Ansible
4 Ansible Playbooks: beyond the Basics
5 Roles and Includes
6 Automating Your Automation
Ansible Playbooks: beyond the Basics 19/32
Playing with variables
---
- hosts: example
vars:
foo: bar
tasks:
# Prints "Variable ’foo’ is set to bar".
- debug: msg="’foo’ is set to {{ foo }}"
Variables always begin with a letter ([A-Za-z]), and can include
any number of underscores ( ) or numbers ([0-9]).
Variables can be passed in via the command line, when calling
ansible-playbook, with the –extra-vars option:
ansible-playbook example.yml –extra-vars ”foo=bar”
Ansible Playbooks: beyond the Basics 20/32
Registering/Accessing variables
Send a command and register the result...
name: Get the value of the environment variable we just added.
shell: ”source /.bash profile && echo $ENV VAR”
register: foo
..and then use it as before
- name: Print the value of the environment variable.
debug: msg = ”The variable is {{ foo.stdout }}”
Ansible Playbooks: beyond the Basics 21/32
Per-play environment variables
# Set to ’absent ’ to disable proxy:
proxy_state: present
# In the ’tasks ’ section of the playbook:
- name: Configure the proxy.
lineinfile:
dest: /etc/ environment
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: "{{ proxy_state }}"
with_items:
- {regexp:"^http_proxy=",line:"http_proxy=http :// example -proxy :80/"}
- {regexp:"^https_proxy=",line:" https_proxy =https :// example -proxy :443/"}
- {regexp:"^ftp_proxy=",line:"ftp_proxy=http :// example -proxy :80/"}
Doing it this way allows me to configure whether the proxy is
enabled per-server, and with one play, set the http, https, and ftp
proxies. You can use a similar kind of play for any other types of
environment variables you need to set system-wide.
Ansible Playbooks: beyond the Basics 22/32
#Outline
1 A day in the life of a sysadmin
2 Automation
3 Introducing Ansible
4 Ansible Playbooks: beyond the Basics
5 Roles and Includes
6 Automating Your Automation
Roles and Includes 23/32
Roles and Includes
Ansible is very flexible when it comes to organizing your tasks in
more efficient ways so you can make your playbooks more
maintainable, reusable, and powerful. We are talking about:
Includes
Roles
Includes examples
handlers:
- include: included-handlers.yml
tasks:
- include: tasks/common.yml
- include: tasks/apache.yml
- include: tasks/mysql.yml
Roles and Includes 24/32
More about roles
Including playbooks inside other playbooks makes your playbook
organization a little more sane, but once you start wrapping up
your entire infrastructures configuration in playbooks, you might
end up with something resembling Russian nesting dolls. The
solution comes with the keyword: roles.
Roles provides a way to take bits of configuration and packages
and make them flexible so we can use them throughout our
infrastructure and we can include them in this way:
roles:
- yum-repo-setup
- firewall
- nodejs
- app-deploy
Roles and Includes 25/32
Role essentials
Instead of requiring you to explicitly include certain files and
playbooks in a role, Ansible automatically includes any main.yml
files inside specific directories that make up the role.
Roles structure
There are only two
directories required to
make a working role:
role name/
meta/main.yml
tasks/main.yml
Ansible will run all the tasks
defined in tasks/main.yml, you
just need to include the created
role using following syntax:
- - -
- hosts: all
roles:
- role name
Your roles can live in a couple different placesin the default global
Ansible role path configurable in /etc/ansible/ansible.cfg.
Roles and Includes 26/32
Enter Ansible Galaxy: Be social
Wouldnt it be better if people could share roles for
commonly-installed applications and services?
Helpful Galaxy commands
Some other helpful ansible-galaxy commands you might use from
time to time:
ansible-galaxy list displays a list of installed roles, with
version numbers
ansible-galaxy remove [role] removes an installed role
ansible-galaxy init can be used to create a role template
suitable for submission to Ansible Galaxy
Roles and Includes 27/32
#Outline
1 A day in the life of a sysadmin
2 Automation
3 Introducing Ansible
4 Ansible Playbooks: beyond the Basics
5 Roles and Includes
6 Automating Your Automation
Automating Your Automation 28/32
Ansible tower
Continuous integration
It’s always a good practise use a continuous integration model
inside your infrastructure
Go Over the CLI
The business needs detailed reporting of infrastructure
deployments and failures, especially for audit purposes.
Team-based infrastructure management requires varying levels
of involvement in playbook management, inventory
management, and key and password access.
A through visual overview of the current and historical
playbook runs and server health helps identify potential issues
before they affect the bottom line.
Playbook scheduling can help ensure infrastructure remains in
a known state.
Automating Your Automation 29/32
Ansible tower
Automating Your Automation 30/32
Thank you! Questions?
More examples at
https://github.com/ansible/
Automating Your Automation 31/32
References
Ansible for DevOps
https://leanpub.com/ansible-for-devops
Ansible in Real Life
https://www.reinteractive.net/posts/167-ansible-real-life-
good-practices
Ansible Tower
https://docs.ansible.com/ansible-tower/
Official doc
https://docs.ansible.com/
Automating Your Automation 32/32

Weitere ähnliche Inhalte

Was ist angesagt?

Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Keith Resar
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with AnsibleAnas
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshopDavid Karban
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017Jumping Bean
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)Richard Donkin
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
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, 2015Alex S
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Ivan Rossi
 
Ansible module development 101
Ansible module development 101Ansible module development 101
Ansible module development 101yfauser
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleOmid Vahdaty
 

Was ist angesagt? (20)

Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshop
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
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
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Ansible Crash Course
Ansible Crash CourseAnsible Crash Course
Ansible Crash Course
 
Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible module development 101
Ansible module development 101Ansible module development 101
Ansible module development 101
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 

Andere mochten auch

Ansible- Durham Meetup: Using Ansible for Cisco ACI deployment
Ansible- Durham Meetup: Using Ansible for Cisco ACI deploymentAnsible- Durham Meetup: Using Ansible for Cisco ACI deployment
Ansible- Durham Meetup: Using Ansible for Cisco ACI deploymentJoel W. King
 
Ansible role reuse - promising but hard
Ansible role reuse - promising but hardAnsible role reuse - promising but hard
Ansible role reuse - promising but hardMartin Maisey
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Timothy Appnel
 
Machine Learning for Your Enterprise: Operations and Security for Mainframe E...
Machine Learning for Your Enterprise: Operations and Security for Mainframe E...Machine Learning for Your Enterprise: Operations and Security for Mainframe E...
Machine Learning for Your Enterprise: Operations and Security for Mainframe E...Precisely
 
Integrate with ldap
Integrate with ldapIntegrate with ldap
Integrate with ldapSon Nguyen
 
Dynamic access control sbc12 - thuan nguyen
Dynamic access control sbc12 - thuan nguyenDynamic access control sbc12 - thuan nguyen
Dynamic access control sbc12 - thuan nguyenThuan Ng
 
Marketing automation solutions webinar (part 2)
Marketing automation solutions webinar (part 2)Marketing automation solutions webinar (part 2)
Marketing automation solutions webinar (part 2)Acquisio
 
Strategies for Transitioning From SharePoint On-Prem to Office 365
Strategies for Transitioning From SharePoint On-Prem to Office 365Strategies for Transitioning From SharePoint On-Prem to Office 365
Strategies for Transitioning From SharePoint On-Prem to Office 365Kanwal Khipple
 
Gentle introduction to Machine Learning
Gentle introduction to Machine LearningGentle introduction to Machine Learning
Gentle introduction to Machine LearningRoman Orač
 
2016 the year of machine learning 12.16.2015
2016 the year of machine learning 12.16.20152016 the year of machine learning 12.16.2015
2016 the year of machine learning 12.16.2015Acquisio
 
Placement of BPM runtime components in an SOA environment
Placement of BPM runtime components in an SOA environmentPlacement of BPM runtime components in an SOA environment
Placement of BPM runtime components in an SOA environmentKim Clark
 
How to Triple Your Speed of Development Using Automation
How to Triple Your Speed of Development Using AutomationHow to Triple Your Speed of Development Using Automation
How to Triple Your Speed of Development Using AutomationAllCloud
 
Deloitte BPM case study by WorkflowGen
Deloitte BPM case study by WorkflowGenDeloitte BPM case study by WorkflowGen
Deloitte BPM case study by WorkflowGenAlain Bezançon
 
AI & Machine Learning - Webinar Deck
AI & Machine Learning - Webinar DeckAI & Machine Learning - Webinar Deck
AI & Machine Learning - Webinar DeckThe Digital Insurer
 
IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...
IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...
IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...Frank Altenburg
 
ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...
ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...
ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...Thuan Ng
 
Practical Strategies to Designing Beautiful Portals
Practical Strategies to Designing Beautiful PortalsPractical Strategies to Designing Beautiful Portals
Practical Strategies to Designing Beautiful PortalsKanwal Khipple
 
Machine Learning Application to Manufacturing using Tableau and Google by Pluto7
Machine Learning Application to Manufacturing using Tableau and Google by Pluto7Machine Learning Application to Manufacturing using Tableau and Google by Pluto7
Machine Learning Application to Manufacturing using Tableau and Google by Pluto7Manju Devadas
 
Practical Strategies for Transitioning to Office 365 #sptechcon
Practical Strategies for Transitioning to Office 365 #sptechconPractical Strategies for Transitioning to Office 365 #sptechcon
Practical Strategies for Transitioning to Office 365 #sptechconKanwal Khipple
 

Andere mochten auch (20)

Ansible- Durham Meetup: Using Ansible for Cisco ACI deployment
Ansible- Durham Meetup: Using Ansible for Cisco ACI deploymentAnsible- Durham Meetup: Using Ansible for Cisco ACI deployment
Ansible- Durham Meetup: Using Ansible for Cisco ACI deployment
 
Ansible role reuse - promising but hard
Ansible role reuse - promising but hardAnsible role reuse - promising but hard
Ansible role reuse - promising but hard
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
 
Machine Learning for Your Enterprise: Operations and Security for Mainframe E...
Machine Learning for Your Enterprise: Operations and Security for Mainframe E...Machine Learning for Your Enterprise: Operations and Security for Mainframe E...
Machine Learning for Your Enterprise: Operations and Security for Mainframe E...
 
Developer 2.0
Developer 2.0  Developer 2.0
Developer 2.0
 
Integrate with ldap
Integrate with ldapIntegrate with ldap
Integrate with ldap
 
Dynamic access control sbc12 - thuan nguyen
Dynamic access control sbc12 - thuan nguyenDynamic access control sbc12 - thuan nguyen
Dynamic access control sbc12 - thuan nguyen
 
Marketing automation solutions webinar (part 2)
Marketing automation solutions webinar (part 2)Marketing automation solutions webinar (part 2)
Marketing automation solutions webinar (part 2)
 
Strategies for Transitioning From SharePoint On-Prem to Office 365
Strategies for Transitioning From SharePoint On-Prem to Office 365Strategies for Transitioning From SharePoint On-Prem to Office 365
Strategies for Transitioning From SharePoint On-Prem to Office 365
 
Gentle introduction to Machine Learning
Gentle introduction to Machine LearningGentle introduction to Machine Learning
Gentle introduction to Machine Learning
 
2016 the year of machine learning 12.16.2015
2016 the year of machine learning 12.16.20152016 the year of machine learning 12.16.2015
2016 the year of machine learning 12.16.2015
 
Placement of BPM runtime components in an SOA environment
Placement of BPM runtime components in an SOA environmentPlacement of BPM runtime components in an SOA environment
Placement of BPM runtime components in an SOA environment
 
How to Triple Your Speed of Development Using Automation
How to Triple Your Speed of Development Using AutomationHow to Triple Your Speed of Development Using Automation
How to Triple Your Speed of Development Using Automation
 
Deloitte BPM case study by WorkflowGen
Deloitte BPM case study by WorkflowGenDeloitte BPM case study by WorkflowGen
Deloitte BPM case study by WorkflowGen
 
AI & Machine Learning - Webinar Deck
AI & Machine Learning - Webinar DeckAI & Machine Learning - Webinar Deck
AI & Machine Learning - Webinar Deck
 
IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...
IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...
IBM Connections 4.5 Integration - From Zero To Social Hero - 2.0 - with Domin...
 
ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...
ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...
ExpertsLive Asia Pacific 2017 - Planning and Deploying SharePoint Server 2016...
 
Practical Strategies to Designing Beautiful Portals
Practical Strategies to Designing Beautiful PortalsPractical Strategies to Designing Beautiful Portals
Practical Strategies to Designing Beautiful Portals
 
Machine Learning Application to Manufacturing using Tableau and Google by Pluto7
Machine Learning Application to Manufacturing using Tableau and Google by Pluto7Machine Learning Application to Manufacturing using Tableau and Google by Pluto7
Machine Learning Application to Manufacturing using Tableau and Google by Pluto7
 
Practical Strategies for Transitioning to Office 365 #sptechcon
Practical Strategies for Transitioning to Office 365 #sptechconPractical Strategies for Transitioning to Office 365 #sptechcon
Practical Strategies for Transitioning to Office 365 #sptechcon
 

Ähnlich wie Introducing Ansible

Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleBrian Hogan
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modulesmohamedmoharam
 
Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupRamesh Godishela
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonMyNOG
 
Getting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfGetting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfssuserd254491
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaSahil Davawala
 
How to deploy spark instance using ansible 2.0 in fiware lab v2
How to deploy spark instance using ansible 2.0 in fiware lab v2How to deploy spark instance using ansible 2.0 in fiware lab v2
How to deploy spark instance using ansible 2.0 in fiware lab v2Fernando Lopez Aguilar
 
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE LabHow to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE LabFIWARE
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Chu-Siang Lai
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupGreg DeKoenigsberg
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Amin Astaneh
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdfNigussMehari4
 
Ubuntu Practice and Configuration
Ubuntu Practice and ConfigurationUbuntu Practice and Configuration
Ubuntu Practice and ConfigurationManoj Sahu
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganCorkOpenTech
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides InfinityPP
 
Linux advanced privilege escalation
Linux advanced privilege escalationLinux advanced privilege escalation
Linux advanced privilege escalationJameel Nabbo
 

Ähnlich wie Introducing Ansible (20)

Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetup
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
Getting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfGetting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdf
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
How to deploy spark instance using ansible 2.0 in fiware lab v2
How to deploy spark instance using ansible 2.0 in fiware lab v2How to deploy spark instance using ansible 2.0 in fiware lab v2
How to deploy spark instance using ansible 2.0 in fiware lab v2
 
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE LabHow to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Ansible_Basics_ppt.pdf
Ansible_Basics_ppt.pdfAnsible_Basics_ppt.pdf
Ansible_Basics_ppt.pdf
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
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
 
Ubuntu Practice and Configuration
Ubuntu Practice and ConfigurationUbuntu Practice and Configuration
Ubuntu Practice and Configuration
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides
 
Linux advanced privilege escalation
Linux advanced privilege escalationLinux advanced privilege escalation
Linux advanced privilege escalation
 

Kürzlich hochgeladen

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 

Kürzlich hochgeladen (20)

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 

Introducing Ansible

  • 2. #Outline 1 A day in the life of a sysadmin 2 Automation 3 Introducing Ansible 4 Ansible Playbooks: beyond the Basics 5 Roles and Includes 6 Automating Your Automation A day in the life of a sysadmin 2/32
  • 3. The timeline ”We have the misfortune to be living in the present. In the future, of course, computers will be smart enough to just figure out what we want, and do it. Until then, we have to spend a lot of time telling the computer things it should already know.” A day in the life of a sysadmin 3/32
  • 4. Keeping the configuration synchronized A day in the life of a sysadmin 4/32
  • 5. Repeating changes across many servers The command to create a new user account is slightly different for Red Hat Linux from the equivalent command for Ubuntu, for example. Solaris is a little different again. Each command is doing basically the same job, but has differences in syntax, arguments, and default values. A day in the life of a sysadmin 5/32
  • 6. Self-updating documentation A new sysadmin joins your organization, and he needs to know where all the servers are, and what they do. Even if you keep scrupulous documentation, it can’t always be relied on. The only accurate documentation, in fact, is the servers themselves. You can look at a server to see how it’s configured, but that only applies while you still have the machine. If something goes wrong and you can’t access the machine, or the data on it, your only option is to reconstruct the lost configuration from scratch. Wouldn’t it be nice if you had a configuration document which was guaranteed to be up to date? A day in the life of a sysadmin 6/32
  • 7. Version control, history, continuous integration A day in the life of a sysadmin 7/32
  • 8. #Outline 1 A day in the life of a sysadmin 2 Automation 3 Introducing Ansible 4 Ansible Playbooks: beyond the Basics 5 Roles and Includes 6 Automating Your Automation Automation 8/32
  • 9. Why Automation? Fast deployment time It’s cheap and flexible Scalability and support Standard environments Automation as a standardized approach IT automation is a standard approach that combines multi-node software deployment, ad-hoc task execution and configuration management. Automation 9/32
  • 11. IT Automation: Terminology Idempotence: the ability to run an operation which produces the same result whether run once or multiple times Inventory: hosts file that defines: the description of the nodes that can be accessed the IP address or hostname of each node nodes group to run a different set of tasks nodes parameters such as username, password or ssh keys Playbooks: they express configurations, deployment and orchestration in Ansible. Each Playbook maps a group of hosts to a set of roles. Each role is represented by calls to Ansible call tasks. Automation 11/32
  • 12. #Outline 1 A day in the life of a sysadmin 2 Automation 3 Introducing Ansible 4 Ansible Playbooks: beyond the Basics 5 Roles and Includes 6 Automating Your Automation Introducing Ansible 12/32
  • 13. Quick Start Linux - run natively e.g. on a Fedora/RHEL/CentOS: yum -y install ansible Debian or Ubuntu sudo apt-add-repository -y ppa:ansible/ansible sudo apt-get update sudo apt-get install -y ansible Verify your installation $ ansible –version ansible 2.0.1.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides Introducing Ansible 13/32
  • 14. Quick Start Linux - run natively e.g. on a Fedora/RHEL/CentOS: yum -y install ansible Debian or Ubuntu sudo apt-add-repository -y ppa:ansible/ansible sudo apt-get update sudo apt-get install -y ansible Verify your installation $ ansible –version ansible 2.0.1.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides Introducing Ansible 13/32
  • 15. Quick Start Linux - run natively e.g. on a Fedora/RHEL/CentOS: yum -y install ansible Debian or Ubuntu sudo apt-add-repository -y ppa:ansible/ansible sudo apt-get update sudo apt-get install -y ansible Verify your installation $ ansible –version ansible 2.0.1.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides Introducing Ansible 13/32
  • 16. Quick Start Linux - run natively e.g. on a Fedora/RHEL/CentOS: yum -y install ansible Debian or Ubuntu sudo apt-add-repository -y ppa:ansible/ansible sudo apt-get update sudo apt-get install -y ansible Verify your installation $ ansible –version ansible 2.0.1.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides Introducing Ansible 13/32
  • 17. The inventory file Where it is located /etc/ansible/hosts What is the format [mailservers] mail.example.com [webservers] foo.example.com ansible ssh user = user001 bar.example.com ansible ssh private key file = /.ssh/ansible key001 [dbservers] one.example.com two.example.com db-[a:f].example.com Introducing Ansible 14/32
  • 18. The inventory file I can define a group of machines # Group ’multi’ with all servers [multi:children] vm01 vm02 # Variables that will be applied to all servers [multi:vars] ansible ssh user=user001 ansible ssh private key file = /.ssh/pkey ..available parameters https://docs.ansible.com/ansible/intro inventory.html Introducing Ansible 15/32
  • 19. The Ansible command line ansible-playbook Execute a playbook ansible-galaxy Roles management ansible example -a ”free -m” -u [username] Run the free command on the example domain ansible example -m ping -u [username] Run the ping command on the example domain ansible atlanta -m copy -a ”src=/etc/hosts dest=/tmp/hosts” File copy using the copy module ansible all -m user -a ”name=foo password=’crypted password here’” User and group management Introducing Ansible 16/32
  • 20. Your first Ansible playbook Host section It is related to a section of the inventory file described above --- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: name=httpd state=latest - name: write the apache config file template: src=/ srv/httpd.j2 dest =/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted Vars Section Variables used to the tasks in order to parametrize something Introducing Ansible 17/32
  • 21. Your first Ansible playbook Task section Groups of tasks that are performed on a certain set of hosts to allow them to fulfill the function you want to assign to them. Notify section This is not an internal Ansible command, it is a reference to a handler, which can perform certain functions when it is called from within a task. Handlers section Handlers are just like tasks, but they only run when they have been told by a task that changes have occurred on the client system. Run the playbook ansible-playbook playbook.yml Introducing Ansible 18/32
  • 22. #Outline 1 A day in the life of a sysadmin 2 Automation 3 Introducing Ansible 4 Ansible Playbooks: beyond the Basics 5 Roles and Includes 6 Automating Your Automation Ansible Playbooks: beyond the Basics 19/32
  • 23. Playing with variables --- - hosts: example vars: foo: bar tasks: # Prints "Variable ’foo’ is set to bar". - debug: msg="’foo’ is set to {{ foo }}" Variables always begin with a letter ([A-Za-z]), and can include any number of underscores ( ) or numbers ([0-9]). Variables can be passed in via the command line, when calling ansible-playbook, with the –extra-vars option: ansible-playbook example.yml –extra-vars ”foo=bar” Ansible Playbooks: beyond the Basics 20/32
  • 24. Registering/Accessing variables Send a command and register the result... name: Get the value of the environment variable we just added. shell: ”source /.bash profile && echo $ENV VAR” register: foo ..and then use it as before - name: Print the value of the environment variable. debug: msg = ”The variable is {{ foo.stdout }}” Ansible Playbooks: beyond the Basics 21/32
  • 25. Per-play environment variables # Set to ’absent ’ to disable proxy: proxy_state: present # In the ’tasks ’ section of the playbook: - name: Configure the proxy. lineinfile: dest: /etc/ environment regexp: "{{ item.regexp }}" line: "{{ item.line }}" state: "{{ proxy_state }}" with_items: - {regexp:"^http_proxy=",line:"http_proxy=http :// example -proxy :80/"} - {regexp:"^https_proxy=",line:" https_proxy =https :// example -proxy :443/"} - {regexp:"^ftp_proxy=",line:"ftp_proxy=http :// example -proxy :80/"} Doing it this way allows me to configure whether the proxy is enabled per-server, and with one play, set the http, https, and ftp proxies. You can use a similar kind of play for any other types of environment variables you need to set system-wide. Ansible Playbooks: beyond the Basics 22/32
  • 26. #Outline 1 A day in the life of a sysadmin 2 Automation 3 Introducing Ansible 4 Ansible Playbooks: beyond the Basics 5 Roles and Includes 6 Automating Your Automation Roles and Includes 23/32
  • 27. Roles and Includes Ansible is very flexible when it comes to organizing your tasks in more efficient ways so you can make your playbooks more maintainable, reusable, and powerful. We are talking about: Includes Roles Includes examples handlers: - include: included-handlers.yml tasks: - include: tasks/common.yml - include: tasks/apache.yml - include: tasks/mysql.yml Roles and Includes 24/32
  • 28. More about roles Including playbooks inside other playbooks makes your playbook organization a little more sane, but once you start wrapping up your entire infrastructures configuration in playbooks, you might end up with something resembling Russian nesting dolls. The solution comes with the keyword: roles. Roles provides a way to take bits of configuration and packages and make them flexible so we can use them throughout our infrastructure and we can include them in this way: roles: - yum-repo-setup - firewall - nodejs - app-deploy Roles and Includes 25/32
  • 29. Role essentials Instead of requiring you to explicitly include certain files and playbooks in a role, Ansible automatically includes any main.yml files inside specific directories that make up the role. Roles structure There are only two directories required to make a working role: role name/ meta/main.yml tasks/main.yml Ansible will run all the tasks defined in tasks/main.yml, you just need to include the created role using following syntax: - - - - hosts: all roles: - role name Your roles can live in a couple different placesin the default global Ansible role path configurable in /etc/ansible/ansible.cfg. Roles and Includes 26/32
  • 30. Enter Ansible Galaxy: Be social Wouldnt it be better if people could share roles for commonly-installed applications and services? Helpful Galaxy commands Some other helpful ansible-galaxy commands you might use from time to time: ansible-galaxy list displays a list of installed roles, with version numbers ansible-galaxy remove [role] removes an installed role ansible-galaxy init can be used to create a role template suitable for submission to Ansible Galaxy Roles and Includes 27/32
  • 31. #Outline 1 A day in the life of a sysadmin 2 Automation 3 Introducing Ansible 4 Ansible Playbooks: beyond the Basics 5 Roles and Includes 6 Automating Your Automation Automating Your Automation 28/32
  • 32. Ansible tower Continuous integration It’s always a good practise use a continuous integration model inside your infrastructure Go Over the CLI The business needs detailed reporting of infrastructure deployments and failures, especially for audit purposes. Team-based infrastructure management requires varying levels of involvement in playbook management, inventory management, and key and password access. A through visual overview of the current and historical playbook runs and server health helps identify potential issues before they affect the bottom line. Playbook scheduling can help ensure infrastructure remains in a known state. Automating Your Automation 29/32
  • 33. Ansible tower Automating Your Automation 30/32
  • 34. Thank you! Questions? More examples at https://github.com/ansible/ Automating Your Automation 31/32
  • 35. References Ansible for DevOps https://leanpub.com/ansible-for-devops Ansible in Real Life https://www.reinteractive.net/posts/167-ansible-real-life- good-practices Ansible Tower https://docs.ansible.com/ansible-tower/ Official doc https://docs.ansible.com/ Automating Your Automation 32/32