SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Ansible DevOps Training
LPI-OT DevOps Ansible Objectives
● Description: Candidates should be able to use
Ansible to ensure a target server is in a specific
state regarding its configuration and installed
software. This objective covers the feature set of
Ansible version 2.2 or later.
● Key Knowledge Areas:
– Understand the principles of automated system
configuration and software installation
– Create and maintain inventory files
– Understand how Ansible interacts with remote systems
– Manage SSH login credentials for Ansible, including
using unprivileged login accounts
– Create, maintain and run Ansible playbooks, including
tasks, handlers, conditionals, loops and registers
– Set and use variables
– Maintain secrets using Ansible vaults
– Write Jinja2 templates, including using common filters,
loops and conditionals
– Understand and use Ansible roles and install Ansible roles
from Ansible Galaxy
– Understand and use important Ansible tasks, including file,
copy, template, ini_file, lineinfile, patch, replace, user,
group, command, shell, service, systemd, cron, apt,
debconf, yum, git, and debug
– Awareness of dynamic inventory
– Awareness of Ansibles features for non-Linux systems
– Awareness of Ansible containers
● The following is a partial list of the used files,
terms and utilities:
– ansible.cfg
– ansible-playbook
– ansible-vault
– ansible-galaxy
– ansible-doc
Ansible
● Agentless
– Uses ssh,
● Secure
– Uses os level security and
privilege escalation
mechanisms
● Provisioning and deployment
● Easy to start
● Configuration mostly in yaml
● Data driven
● Idempotent
– Rerunning the playbook will not
result in duplication of successful
actions
● Describe the intended system
state
● Written i and extended with
Python,
● Tries to leave nothing behind
(agentless)
Modules
● Ansible functionality provided by
modules
● 250+ modules
– Cloud services (Amazon,
Rackspace, Google Compute
Platform)
– Packaging (apt, yum, pip, gem)
– Source control (git, svn)
– OS plugins (service, command, file,
template)
– Module index
● Generic modules used when a
specific module does not
exist,
– commands,
– shell
– Raw
● Best to use a specific module
when available – ensures
proper handling of
idempotence
How Ansible Works
Provisioning/Set Up
● Ansible target host requirements
– Ssh must be enabled
– User with admin privileges
● root (not recommended),
● User with sudo/su rights – ansible recommends passwordless sudo/su for the ansible user
– Authentication via
● Password
● Ssh key (preferred)
● Prerequisites for labs:
– Install a virtual machine
● Ensure ssh is enabled
● Ensure python is installed
Ansible Concepts
● Hosts are defined in the ansible
“inventory”
● Ansible operates on a set of host
by
– Hostname,
● one.example.com
● one.example.com:two.example.com
– group name
● Web-servers
● Webserver:!dbserver - in
webservers but not dbservers group
–
– a selection pattern.
● 192.0.2.50
● 192.0.2.*
● Ansible can operate in
– ad-hoc mode, used to run once off
commands
– playbook mode where multi-step
commands are run to configure the
target host
● Ansible uses modules for its
functionality
– Modules are written in python
Static Inventory
● Defines how ansible will
interact with remote hosts
via inventory parameters
● Define logical groups of
managed nodes
● Default location :
/etc/ansible/hosts
● INI format
Static Inventory
● Can have parent
groups
– “[southeast:children”
● Can use patterns to
match hosts
Ansible Ad-hoc Commands
● Ansible can run ad-hoc commands,
● Ad-hoc commands can be used to
– learn ansible or
– run once off commands,
● Primarily playbooks are used to run ansible configurations tasks
● Before running anbsile commands the target node’s hostkey
– must be in known_hosts or
– host key checking must be disabled in ansible.cfg
● Initially we will use password based authentication to run ansible
Ansible Ad-hoc Commands
● Ansible can run ad-hoc commands,
● Ad-hoc commands can be used to
– learn ansible or
– run once off commands,
● Primarily playbooks are used to run ansible configurations tasks
● Before running anbsile commands the target node’s hostkey
– must be in known_hosts or
– host key checking must be disabled in ansible.cfg
● Initially we will use password based authentication to run ansible
Ansible Ad hoc Commands
● “ansible {pattern} -m {module} -a “{options}” {flags}”
– pattern : which hosts
– module : which ansible module (command by default)
– options : which module options
● flags : command flags
– “-u {username}”: to run the command as a different user (useraccount by default)
– “--ask-pass”, “-k”: prompt for user password. Used if ssh keys are not sued for authentication
– “-f {n}”: to run the command in n parallel forks (5 by default)
– “--become”, “-b”: to run the command through sudo
– “--ask-become-pass”,”-K”: to interactively prompt you for the sudo password to use
– “-i {file}”: inventory file to use
– “--ask-vault-pass”: to specify the vault-password interactively
Ad-hoc Command & Modules
● As stated previously functionality is provided by
modules,
● Ansible ad-hoc command can take a module option,
– “command” is the default module if none is specified
● The “-a” option takes the module parameters as
arguments. These are the same parameters used in
playbooks,
Ansible Ad hoc Commands
Examples
● Examples: ansible <pattern_goes_here> -m <module_name> -a <arguments>
– Ansible Ping Hosts
● “ansible webhosts -m ping”
– Manage a service
● ‘ansible webservers -m service -a "name=httpd state=restarted"’
– File transfer
● ‘ansible all -m copy -a "src=/etc/hosts dest=/tmp/hosts"’
– Deploying from source control
● ‘ansible webservers -m git -a "repo=git://foo.example.org/repo.git dest=/srv/myapp
version=HEAD"’
– Gathering facts
● ‘ansible all -m setup’
Configure node targets for key
based access
● Copy over key of Ansible admin to authorised key file on target
– “ssh-copy-id ansible@example.co.za”
● Edit /etc/sudoers file on target. Either
– ad an user entry for the remote ansible user or
● “ansible ALL=(ALL:ALL) NOPASSWD: ALL”
– make ansible user member of wheel group and enable passwordless
sudo
● ”usermod -a -G sudo ansible”
● “%sudo ALL=(ALL:ALL) NOPASSWD: ALL”
PlayBooks
● Ansible's configuration and orchestration language
● Describe policy of desired state of node
● Can be used form mange configurations or roll-outs of complex software
solutions
● Expressed in YAML language
● Composed of one or more “plays” in a list
– A play can consist of multiple tasks
● Allowing multi-machine deployments orchestration
● Support templating—both in playbooks and in file templates—by way of Jinja2
● Can be one file, or split up into many roles (more later!)
Ansible Playbooks
Playbook Syntax
● hosts:
– one or more group or host patterns
● vars:
– Playbook variables
● tasks:
– List of tasks to run for the play
● handlers:
– List of handlers – handler are called by notify parameter to a task
● remote_user : (not shown in example)
– the name of the remote user account (per play or task)
● become/sudo: (not shown in example)
– run tasks using sudo (per play or task)
● become_user/sudo_user: (not shown in example)
– sudo to a different user than root
Playbook Syntax - Tasks
● Are executed in order against all
machines matched by the host
pattern
● May be Included from other files
● Hosts with failed tasks are taken
out for the entire playbook
● Each task executes a module with
specific options
● Modules are idempotent in order to
bring the system to the desired
state
tasks:
- include: tasks/foo.yml
Task Syntax
tasks:
- name: {task name}
{module}: {options}
Playbooks Tasks - Handlers
● Notifications may be triggered at the end of each task
whenever a change has been made on the remote system
● Handlers are referenced by name
tasks:
- name: template configuration file
template: src=template.j2 dest=/etc/foo.conf
notify:
- restart apache
...
handlers:
- name: restart apache
service: name=apache state=restarted
Ansible Inventory Parameters
● Used in
– inventory file,
– hosts_vars files,
– group_vars files
● ansible_connection: local, ssh or paramiko
● ansible_ssh_host: the name of the host to connect to
● ansible_ssh_port: the ssh port number if not 22
● ansible_ssh_user: the ssh user name to use
● ansible_ssh_pass: the ssh password to use(insecure)
● ansible_ssh_private_key_file: private key file used by ssh
● ansible_python_interpreter: path to python interpreter tou es
Ansible Variables
● Variables are defined
– in yaml as
● “name: value”
– In ini files as
● “name=value”
● Variables can be defined on a per
– host,
● Inventory file
● host_vars folder
– playbook,
– group,
● Inventory file
● group_vars folder
– Roles
● host_vars,
● group_vars
● defaults
Roles
● A way to organise tasks in a DRY way,
● Based on known folder structure and file name
– Each folder should contain a file named
● “main.yml”
– The playbooks contain set up and configuration
parameters. Roles contains tasks, handler and
variables
Referenced in playbook via
the “roles” key
Referenced in playbook via
the “roles” key
Roles main.yml
● Tasks defined in the
tasks/main.yml are just a list of
tasks as per an ordinary
playbook,
● For var/main.yml,
handlers/main.yml etc the yaml
files simply contain a list of
variables, handlers etc as per
playbooks not using roles,
● Roles are primarily a way to
manage and organise task
Docker Vault
● Allows keeping encrypted data in source control
● Used to encrypt enitre playbook or can be used to encrypt passwords in plain text files
● Created encrypted files
– “ansible-vault create foo.yml”
● Editing encrypted files
– “ansible-vault edit foo.yml”
● Encrypting unencrypted files
– “ansible-vault encrypt foo.yml”
● Decrypting encrypted files
– “ansible-vault decrypt foo.yml”
● Running ad-hoc or playbook with vault
– “ansible-playbook site.yml –vault-password-file ~/.vault_pass.txt”

Más contenido relacionado

La actualidad más candente

Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshopDavid Karban
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible referencelaonap166
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Brian Schott
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricksbcoca
 
Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = CodeGeorg Sorst
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102APNIC
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with AnsibleBas Meijer
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupGreg DeKoenigsberg
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartHenry Stamerjohann
 

La actualidad más candente (20)

Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshop
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = Code
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with Ansible
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / Quickstart
 

Similar a DevOpsDaysCPT Ansible Infrastrucutre as Code 2017

Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganCorkOpenTech
 
ansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and moreansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and moreSabarinath Gnanasekar
 
Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Jude A. Goonawardena
 
PLNOG Automation@Brainly
PLNOG Automation@BrainlyPLNOG Automation@Brainly
PLNOG Automation@Brainlyvespian_256
 
PLNOG14: Automation at Brainly - Paweł Rozlach
PLNOG14: Automation at Brainly - Paweł RozlachPLNOG14: Automation at Brainly - Paweł Rozlach
PLNOG14: Automation at Brainly - Paweł RozlachPROIDEA
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaSahil Davawala
 
Automating with ansible (Part A)
Automating with ansible (Part A)Automating with ansible (Part A)
Automating with ansible (Part A)iman darabi
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of AnsibleDevOps Ltd.
 
Using Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud EnvironmentsUsing Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud Environmentsahamilton55
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Gulcin Yildirim Jelinek
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for DummiesŁukasz Proszek
 
Managing PostgreSQL with Ansible
 Managing PostgreSQL with Ansible Managing PostgreSQL with Ansible
Managing PostgreSQL with AnsibleEDB
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)M Malai
 
Ansible is Our Wishbone
Ansible is Our WishboneAnsible is Our Wishbone
Ansible is Our WishboneMydbops
 
Automating with ansible (part a)
Automating with ansible (part a)Automating with ansible (part a)
Automating with ansible (part a)iman darabi
 
Puppet modules: An Holistic Approach
Puppet modules: An Holistic ApproachPuppet modules: An Holistic Approach
Puppet modules: An Holistic ApproachAlessandro Franceschi
 

Similar a DevOpsDaysCPT Ansible Infrastrucutre as Code 2017 (20)

Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Ansible_Basics_ppt.pdf
Ansible_Basics_ppt.pdfAnsible_Basics_ppt.pdf
Ansible_Basics_ppt.pdf
 
ansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and moreansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and more
 
Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
PLNOG Automation@Brainly
PLNOG Automation@BrainlyPLNOG Automation@Brainly
PLNOG Automation@Brainly
 
PLNOG14: Automation at Brainly - Paweł Rozlach
PLNOG14: Automation at Brainly - Paweł RozlachPLNOG14: Automation at Brainly - Paweł Rozlach
PLNOG14: Automation at Brainly - Paweł Rozlach
 
Installing AtoM with Ansible
Installing AtoM with AnsibleInstalling AtoM with Ansible
Installing AtoM with Ansible
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
Automating with ansible (Part A)
Automating with ansible (Part A)Automating with ansible (Part A)
Automating with ansible (Part A)
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
Using Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud EnvironmentsUsing Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud Environments
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
 
Managing PostgreSQL with Ansible
 Managing PostgreSQL with Ansible Managing PostgreSQL with Ansible
Managing PostgreSQL with Ansible
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
 
Ansible is Our Wishbone
Ansible is Our WishboneAnsible is Our Wishbone
Ansible is Our Wishbone
 
Automating with ansible (part a)
Automating with ansible (part a)Automating with ansible (part a)
Automating with ansible (part a)
 
Ansible 202
Ansible 202Ansible 202
Ansible 202
 
Puppet modules: An Holistic Approach
Puppet modules: An Holistic ApproachPuppet modules: An Holistic Approach
Puppet modules: An Holistic Approach
 

Más de Jumping Bean

Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data typePostgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data typeJumping Bean
 
React - The JavaScript Library for User Interfaces
React - The JavaScript Library for User InterfacesReact - The JavaScript Library for User Interfaces
React - The JavaScript Library for User InterfacesJumping Bean
 
IPv6 How To Set Up a Linux IPv6 Lan
IPv6 How To Set Up  a Linux IPv6 LanIPv6 How To Set Up  a Linux IPv6 Lan
IPv6 How To Set Up a Linux IPv6 LanJumping Bean
 
HTML 5 & The Modern Web
HTML 5 & The Modern WebHTML 5 & The Modern Web
HTML 5 & The Modern WebJumping Bean
 
Building games-with-libgdx
Building games-with-libgdxBuilding games-with-libgdx
Building games-with-libgdxJumping Bean
 
Linux Containers & Docker
Linux Containers & DockerLinux Containers & Docker
Linux Containers & DockerJumping Bean
 
Introduction to Web Sockets
Introduction to Web SocketsIntroduction to Web Sockets
Introduction to Web SocketsJumping Bean
 
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South AfricaSecrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South AfricaJumping Bean
 
M-Learning application development with open source
M-Learning application development with open sourceM-Learning application development with open source
M-Learning application development with open sourceJumping Bean
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSJumping Bean
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentJumping Bean
 
Glassfish An Introduction
Glassfish An IntroductionGlassfish An Introduction
Glassfish An IntroductionJumping Bean
 
IPv6 - Jozi Linux User Group Presentation
IPv6  - Jozi Linux User Group PresentationIPv6  - Jozi Linux User Group Presentation
IPv6 - Jozi Linux User Group PresentationJumping Bean
 
SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)Jumping Bean
 

Más de Jumping Bean (15)

Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data typePostgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
 
React - The JavaScript Library for User Interfaces
React - The JavaScript Library for User InterfacesReact - The JavaScript Library for User Interfaces
React - The JavaScript Library for User Interfaces
 
IPv6 How To Set Up a Linux IPv6 Lan
IPv6 How To Set Up  a Linux IPv6 LanIPv6 How To Set Up  a Linux IPv6 Lan
IPv6 How To Set Up a Linux IPv6 Lan
 
HTML 5 & The Modern Web
HTML 5 & The Modern WebHTML 5 & The Modern Web
HTML 5 & The Modern Web
 
Building games-with-libgdx
Building games-with-libgdxBuilding games-with-libgdx
Building games-with-libgdx
 
Linux Containers & Docker
Linux Containers & DockerLinux Containers & Docker
Linux Containers & Docker
 
Introduction to Web Sockets
Introduction to Web SocketsIntroduction to Web Sockets
Introduction to Web Sockets
 
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South AfricaSecrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
 
M-Learning application development with open source
M-Learning application development with open sourceM-Learning application development with open source
M-Learning application development with open source
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Glassfish An Introduction
Glassfish An IntroductionGlassfish An Introduction
Glassfish An Introduction
 
Java logging
Java loggingJava logging
Java logging
 
IPv6 - Jozi Linux User Group Presentation
IPv6  - Jozi Linux User Group PresentationIPv6  - Jozi Linux User Group Presentation
IPv6 - Jozi Linux User Group Presentation
 
SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)
 

Último

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.
 
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
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
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
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
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
 
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
 
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
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
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
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Último (20)

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...
 
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
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
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...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
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
 
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
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
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
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
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
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

DevOpsDaysCPT Ansible Infrastrucutre as Code 2017

  • 2. LPI-OT DevOps Ansible Objectives ● Description: Candidates should be able to use Ansible to ensure a target server is in a specific state regarding its configuration and installed software. This objective covers the feature set of Ansible version 2.2 or later. ● Key Knowledge Areas: – Understand the principles of automated system configuration and software installation – Create and maintain inventory files – Understand how Ansible interacts with remote systems – Manage SSH login credentials for Ansible, including using unprivileged login accounts – Create, maintain and run Ansible playbooks, including tasks, handlers, conditionals, loops and registers – Set and use variables – Maintain secrets using Ansible vaults – Write Jinja2 templates, including using common filters, loops and conditionals – Understand and use Ansible roles and install Ansible roles from Ansible Galaxy – Understand and use important Ansible tasks, including file, copy, template, ini_file, lineinfile, patch, replace, user, group, command, shell, service, systemd, cron, apt, debconf, yum, git, and debug – Awareness of dynamic inventory – Awareness of Ansibles features for non-Linux systems – Awareness of Ansible containers ● The following is a partial list of the used files, terms and utilities: – ansible.cfg – ansible-playbook – ansible-vault – ansible-galaxy – ansible-doc
  • 3. Ansible ● Agentless – Uses ssh, ● Secure – Uses os level security and privilege escalation mechanisms ● Provisioning and deployment ● Easy to start ● Configuration mostly in yaml ● Data driven ● Idempotent – Rerunning the playbook will not result in duplication of successful actions ● Describe the intended system state ● Written i and extended with Python, ● Tries to leave nothing behind (agentless)
  • 4. Modules ● Ansible functionality provided by modules ● 250+ modules – Cloud services (Amazon, Rackspace, Google Compute Platform) – Packaging (apt, yum, pip, gem) – Source control (git, svn) – OS plugins (service, command, file, template) – Module index ● Generic modules used when a specific module does not exist, – commands, – shell – Raw ● Best to use a specific module when available – ensures proper handling of idempotence
  • 6. Provisioning/Set Up ● Ansible target host requirements – Ssh must be enabled – User with admin privileges ● root (not recommended), ● User with sudo/su rights – ansible recommends passwordless sudo/su for the ansible user – Authentication via ● Password ● Ssh key (preferred) ● Prerequisites for labs: – Install a virtual machine ● Ensure ssh is enabled ● Ensure python is installed
  • 7. Ansible Concepts ● Hosts are defined in the ansible “inventory” ● Ansible operates on a set of host by – Hostname, ● one.example.com ● one.example.com:two.example.com – group name ● Web-servers ● Webserver:!dbserver - in webservers but not dbservers group – – a selection pattern. ● 192.0.2.50 ● 192.0.2.* ● Ansible can operate in – ad-hoc mode, used to run once off commands – playbook mode where multi-step commands are run to configure the target host ● Ansible uses modules for its functionality – Modules are written in python
  • 8. Static Inventory ● Defines how ansible will interact with remote hosts via inventory parameters ● Define logical groups of managed nodes ● Default location : /etc/ansible/hosts ● INI format
  • 9. Static Inventory ● Can have parent groups – “[southeast:children” ● Can use patterns to match hosts
  • 10. Ansible Ad-hoc Commands ● Ansible can run ad-hoc commands, ● Ad-hoc commands can be used to – learn ansible or – run once off commands, ● Primarily playbooks are used to run ansible configurations tasks ● Before running anbsile commands the target node’s hostkey – must be in known_hosts or – host key checking must be disabled in ansible.cfg ● Initially we will use password based authentication to run ansible
  • 11. Ansible Ad-hoc Commands ● Ansible can run ad-hoc commands, ● Ad-hoc commands can be used to – learn ansible or – run once off commands, ● Primarily playbooks are used to run ansible configurations tasks ● Before running anbsile commands the target node’s hostkey – must be in known_hosts or – host key checking must be disabled in ansible.cfg ● Initially we will use password based authentication to run ansible
  • 12. Ansible Ad hoc Commands ● “ansible {pattern} -m {module} -a “{options}” {flags}” – pattern : which hosts – module : which ansible module (command by default) – options : which module options ● flags : command flags – “-u {username}”: to run the command as a different user (useraccount by default) – “--ask-pass”, “-k”: prompt for user password. Used if ssh keys are not sued for authentication – “-f {n}”: to run the command in n parallel forks (5 by default) – “--become”, “-b”: to run the command through sudo – “--ask-become-pass”,”-K”: to interactively prompt you for the sudo password to use – “-i {file}”: inventory file to use – “--ask-vault-pass”: to specify the vault-password interactively
  • 13. Ad-hoc Command & Modules ● As stated previously functionality is provided by modules, ● Ansible ad-hoc command can take a module option, – “command” is the default module if none is specified ● The “-a” option takes the module parameters as arguments. These are the same parameters used in playbooks,
  • 14. Ansible Ad hoc Commands Examples ● Examples: ansible <pattern_goes_here> -m <module_name> -a <arguments> – Ansible Ping Hosts ● “ansible webhosts -m ping” – Manage a service ● ‘ansible webservers -m service -a "name=httpd state=restarted"’ – File transfer ● ‘ansible all -m copy -a "src=/etc/hosts dest=/tmp/hosts"’ – Deploying from source control ● ‘ansible webservers -m git -a "repo=git://foo.example.org/repo.git dest=/srv/myapp version=HEAD"’ – Gathering facts ● ‘ansible all -m setup’
  • 15. Configure node targets for key based access ● Copy over key of Ansible admin to authorised key file on target – “ssh-copy-id ansible@example.co.za” ● Edit /etc/sudoers file on target. Either – ad an user entry for the remote ansible user or ● “ansible ALL=(ALL:ALL) NOPASSWD: ALL” – make ansible user member of wheel group and enable passwordless sudo ● ”usermod -a -G sudo ansible” ● “%sudo ALL=(ALL:ALL) NOPASSWD: ALL”
  • 16. PlayBooks ● Ansible's configuration and orchestration language ● Describe policy of desired state of node ● Can be used form mange configurations or roll-outs of complex software solutions ● Expressed in YAML language ● Composed of one or more “plays” in a list – A play can consist of multiple tasks ● Allowing multi-machine deployments orchestration ● Support templating—both in playbooks and in file templates—by way of Jinja2 ● Can be one file, or split up into many roles (more later!)
  • 18. Playbook Syntax ● hosts: – one or more group or host patterns ● vars: – Playbook variables ● tasks: – List of tasks to run for the play ● handlers: – List of handlers – handler are called by notify parameter to a task ● remote_user : (not shown in example) – the name of the remote user account (per play or task) ● become/sudo: (not shown in example) – run tasks using sudo (per play or task) ● become_user/sudo_user: (not shown in example) – sudo to a different user than root
  • 19. Playbook Syntax - Tasks ● Are executed in order against all machines matched by the host pattern ● May be Included from other files ● Hosts with failed tasks are taken out for the entire playbook ● Each task executes a module with specific options ● Modules are idempotent in order to bring the system to the desired state tasks: - include: tasks/foo.yml Task Syntax tasks: - name: {task name} {module}: {options}
  • 20. Playbooks Tasks - Handlers ● Notifications may be triggered at the end of each task whenever a change has been made on the remote system ● Handlers are referenced by name tasks: - name: template configuration file template: src=template.j2 dest=/etc/foo.conf notify: - restart apache ... handlers: - name: restart apache service: name=apache state=restarted
  • 21. Ansible Inventory Parameters ● Used in – inventory file, – hosts_vars files, – group_vars files ● ansible_connection: local, ssh or paramiko ● ansible_ssh_host: the name of the host to connect to ● ansible_ssh_port: the ssh port number if not 22 ● ansible_ssh_user: the ssh user name to use ● ansible_ssh_pass: the ssh password to use(insecure) ● ansible_ssh_private_key_file: private key file used by ssh ● ansible_python_interpreter: path to python interpreter tou es
  • 22. Ansible Variables ● Variables are defined – in yaml as ● “name: value” – In ini files as ● “name=value” ● Variables can be defined on a per – host, ● Inventory file ● host_vars folder – playbook, – group, ● Inventory file ● group_vars folder – Roles ● host_vars, ● group_vars ● defaults
  • 23. Roles ● A way to organise tasks in a DRY way, ● Based on known folder structure and file name – Each folder should contain a file named ● “main.yml” – The playbooks contain set up and configuration parameters. Roles contains tasks, handler and variables Referenced in playbook via the “roles” key Referenced in playbook via the “roles” key
  • 24. Roles main.yml ● Tasks defined in the tasks/main.yml are just a list of tasks as per an ordinary playbook, ● For var/main.yml, handlers/main.yml etc the yaml files simply contain a list of variables, handlers etc as per playbooks not using roles, ● Roles are primarily a way to manage and organise task
  • 25. Docker Vault ● Allows keeping encrypted data in source control ● Used to encrypt enitre playbook or can be used to encrypt passwords in plain text files ● Created encrypted files – “ansible-vault create foo.yml” ● Editing encrypted files – “ansible-vault edit foo.yml” ● Encrypting unencrypted files – “ansible-vault encrypt foo.yml” ● Decrypting encrypted files – “ansible-vault decrypt foo.yml” ● Running ad-hoc or playbook with vault – “ansible-playbook site.yml –vault-password-file ~/.vault_pass.txt”