Soumettre la recherche
Mettre en ligne
Ansible
•
Télécharger en tant que PPTX, PDF
•
0 j'aime
•
1,386 vues
Vladimír Smitka
Suivre
Infrastructure automation for sysadmins
Lire moins
Lire la suite
Technologie
Signaler
Partager
Signaler
Partager
1 sur 45
Télécharger maintenant
Recommandé
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
Network Automation: Ansible 102
Network Automation: Ansible 102
APNIC
Ansible Automation to Rule Them All
Ansible Automation to Rule Them All
Tim Fairweather
Ansible 101
Ansible 101
Gena Mykhailiuta
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
fmaccioni
Network Automation with Ansible
Network Automation with Ansible
Anas
ansible why ?
ansible why ?
Yashar Esmaildokht
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Jeff Geerling
Recommandé
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
Network Automation: Ansible 102
Network Automation: Ansible 102
APNIC
Ansible Automation to Rule Them All
Ansible Automation to Rule Them All
Tim Fairweather
Ansible 101
Ansible 101
Gena Mykhailiuta
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
fmaccioni
Network Automation with Ansible
Network Automation with Ansible
Anas
ansible why ?
ansible why ?
Yashar Esmaildokht
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Jeff Geerling
Automation with ansible
Automation with ansible
Khizer Naeem
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
ansiblebrno
Tips for a Faster Website
Tips for a Faster Website
Rayed Alrashed
Ansible presentation
Ansible presentation
Suresh Kumar
Ansible presentation
Ansible presentation
John Lynch
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
Jeff Geerling
Getting Started with Ansible
Getting Started with Ansible
Ahmed AbouZaid
Introduction to ansible
Introduction to ansible
Mukul Malhotra
How Ansible Makes Automation Easy
How Ansible Makes Automation Easy
Peter Sankauskas
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Timothy Appnel
Getting started with Ansible
Getting started with Ansible
Ivan Serdyuk
Ansible intro
Ansible intro
Marcelo Quintiliano da Silva
Ansible Case Studies
Ansible Case Studies
Greg DeKoenigsberg
Deploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Orestes Carracedo
Automation with Ansible and Containers
Automation with Ansible and Containers
Rodolfo Carvalho
Jenkins and ansible reference
Jenkins and ansible reference
laonap166
IT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
Introduction to Ansible
Introduction to Ansible
Michael Bahr
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Keith Resar
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef
Container Monitoring with Sysdig
Container Monitoring with Sysdig
Sreenivas Makam
Automating Complex Setups with Puppet
Automating Complex Setups with Puppet
Kris Buytaert
Contenu connexe
Tendances
Automation with ansible
Automation with ansible
Khizer Naeem
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
ansiblebrno
Tips for a Faster Website
Tips for a Faster Website
Rayed Alrashed
Ansible presentation
Ansible presentation
Suresh Kumar
Ansible presentation
Ansible presentation
John Lynch
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
Jeff Geerling
Getting Started with Ansible
Getting Started with Ansible
Ahmed AbouZaid
Introduction to ansible
Introduction to ansible
Mukul Malhotra
How Ansible Makes Automation Easy
How Ansible Makes Automation Easy
Peter Sankauskas
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Timothy Appnel
Getting started with Ansible
Getting started with Ansible
Ivan Serdyuk
Ansible intro
Ansible intro
Marcelo Quintiliano da Silva
Ansible Case Studies
Ansible Case Studies
Greg DeKoenigsberg
Deploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Orestes Carracedo
Automation with Ansible and Containers
Automation with Ansible and Containers
Rodolfo Carvalho
Jenkins and ansible reference
Jenkins and ansible reference
laonap166
IT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
Introduction to Ansible
Introduction to Ansible
Michael Bahr
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Keith Resar
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef
Tendances
(20)
Automation with ansible
Automation with ansible
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
Tips for a Faster Website
Tips for a Faster Website
Ansible presentation
Ansible presentation
Ansible presentation
Ansible presentation
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
Getting Started with Ansible
Getting Started with Ansible
Introduction to ansible
Introduction to ansible
How Ansible Makes Automation Easy
How Ansible Makes Automation Easy
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Getting started with Ansible
Getting started with Ansible
Ansible intro
Ansible intro
Ansible Case Studies
Ansible Case Studies
Deploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Automation with Ansible and Containers
Automation with Ansible and Containers
Jenkins and ansible reference
Jenkins and ansible reference
IT Automation with Ansible
IT Automation with Ansible
Introduction to Ansible
Introduction to Ansible
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Similaire à Ansible
Container Monitoring with Sysdig
Container Monitoring with Sysdig
Sreenivas Makam
Automating Complex Setups with Puppet
Automating Complex Setups with Puppet
Kris Buytaert
Thrombus Training Dec. 2013
Thrombus Training Dec. 2013
CREATIS
Sydney Drupal News May 2012
Sydney Drupal News May 2012
Ryan Cross
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
IT Event
Automating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
Kris Buytaert
Staying on Topic - Invoke OpenFaaS functions with Kafka
Staying on Topic - Invoke OpenFaaS functions with Kafka
Richard Gee
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
Sander Temme
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Altoros
Intro to HPC
Intro to HPC
Wendi Sapp
Provisioning Heterogenous Bare Metal with Stacki
Provisioning Heterogenous Bare Metal with Stacki
StackIQ
Social Connections 13 - Troubleshooting Connections Pink
Social Connections 13 - Troubleshooting Connections Pink
Nico Meisenzahl
Cypress.pptx
Cypress.pptx
Arshad QA
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga
OpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef Workshop
Matt Ray
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i
Zend by Rogue Wave Software
Build Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
Beyond Puppet
Beyond Puppet
Kris Buytaert
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
Bryan Ollendyke
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShift
Shekhar Gulati
Similaire à Ansible
(20)
Container Monitoring with Sysdig
Container Monitoring with Sysdig
Automating Complex Setups with Puppet
Automating Complex Setups with Puppet
Thrombus Training Dec. 2013
Thrombus Training Dec. 2013
Sydney Drupal News May 2012
Sydney Drupal News May 2012
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Automating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
Staying on Topic - Invoke OpenFaaS functions with Kafka
Staying on Topic - Invoke OpenFaaS functions with Kafka
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Intro to HPC
Intro to HPC
Provisioning Heterogenous Bare Metal with Stacki
Provisioning Heterogenous Bare Metal with Stacki
Social Connections 13 - Troubleshooting Connections Pink
Social Connections 13 - Troubleshooting Connections Pink
Cypress.pptx
Cypress.pptx
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
OpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef Workshop
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i
Build Automation of PHP Applications
Build Automation of PHP Applications
Beyond Puppet
Beyond Puppet
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShift
Plus de Vladimír Smitka
Google Tag Manager a analytika ve WordPress
Google Tag Manager a analytika ve WordPress
Vladimír Smitka
WordCamp Bratislava 2019 - Cache!
WordCamp Bratislava 2019 - Cache!
Vladimír Smitka
Webmeetup #3
Webmeetup #3
Vladimír Smitka
Co ukázal globální scan přístupných .git repozitářů?
Co ukázal globální scan přístupných .git repozitářů?
Vladimír Smitka
Hesla a vícefaktorová autentizace ve WP
Hesla a vícefaktorová autentizace ve WP
Vladimír Smitka
WP Weekend 2018
WP Weekend 2018
Vladimír Smitka
Drobné chyby, které vám mohou zlomit vaz
Drobné chyby, které vám mohou zlomit vaz
Vladimír Smitka
Sysops tipy pro lepší WP
Sysops tipy pro lepší WP
Vladimír Smitka
Najčastejšie problémy WordPress webov
Najčastejšie problémy WordPress webov
Vladimír Smitka
Http/2 vs Image Sprites
Http/2 vs Image Sprites
Vladimír Smitka
WordCamp Brno 2017 - rychlý a bezpečný web
WordCamp Brno 2017 - rychlý a bezpečný web
Vladimír Smitka
WordPress - základy bezpečnosti
WordPress - základy bezpečnosti
Vladimír Smitka
Nejčastejší problémy WordPress webů
Nejčastejší problémy WordPress webů
Vladimír Smitka
Wordfence 2016
Wordfence 2016
Vladimír Smitka
WordPress Security:Defend yourself against digital invaders
WordPress Security:Defend yourself against digital invaders
Vladimír Smitka
WordPress: Základy - bezpečnost 3x3
WordPress: Základy - bezpečnost 3x3
Vladimír Smitka
Instalace WordPress
Instalace WordPress
Vladimír Smitka
WP výkon a jeho profilování
WP výkon a jeho profilování
Vladimír Smitka
WordCamp Praha 2016 - Bezpečnost WordPress
WordCamp Praha 2016 - Bezpečnost WordPress
Vladimír Smitka
WordPress performance tuning
WordPress performance tuning
Vladimír Smitka
Plus de Vladimír Smitka
(20)
Google Tag Manager a analytika ve WordPress
Google Tag Manager a analytika ve WordPress
WordCamp Bratislava 2019 - Cache!
WordCamp Bratislava 2019 - Cache!
Webmeetup #3
Webmeetup #3
Co ukázal globální scan přístupných .git repozitářů?
Co ukázal globální scan přístupných .git repozitářů?
Hesla a vícefaktorová autentizace ve WP
Hesla a vícefaktorová autentizace ve WP
WP Weekend 2018
WP Weekend 2018
Drobné chyby, které vám mohou zlomit vaz
Drobné chyby, které vám mohou zlomit vaz
Sysops tipy pro lepší WP
Sysops tipy pro lepší WP
Najčastejšie problémy WordPress webov
Najčastejšie problémy WordPress webov
Http/2 vs Image Sprites
Http/2 vs Image Sprites
WordCamp Brno 2017 - rychlý a bezpečný web
WordCamp Brno 2017 - rychlý a bezpečný web
WordPress - základy bezpečnosti
WordPress - základy bezpečnosti
Nejčastejší problémy WordPress webů
Nejčastejší problémy WordPress webů
Wordfence 2016
Wordfence 2016
WordPress Security:Defend yourself against digital invaders
WordPress Security:Defend yourself against digital invaders
WordPress: Základy - bezpečnost 3x3
WordPress: Základy - bezpečnost 3x3
Instalace WordPress
Instalace WordPress
WP výkon a jeho profilování
WP výkon a jeho profilování
WordCamp Praha 2016 - Bezpečnost WordPress
WordCamp Praha 2016 - Bezpečnost WordPress
WordPress performance tuning
WordPress performance tuning
Dernier
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Kalema Edgar
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
LoriGlavin3
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
Alfredo García Lavilla
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
ScyllaDB
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
UiPathCommunity
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
Fwdays
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
MounikaPolabathina
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
DianaGray10
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
LoriGlavin3
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
Alan Dix
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
2toLead Limited
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
gvaughan
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
Addepto
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Sergiu Bodiu
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Databarracks
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Pixlogix Infotech
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
Rizwan Syed
Dernier
(20)
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
How to write a Business Continuity Plan
How to write a Business Continuity Plan
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
Ansible
1.
https://lynt.cz Ing. Vladimir Smitka vladimir.smitka@lynt.cz @smitka Lynt
services s.r.o. 6. 12. 2017 1
2.
https://lynt.cz Intro • Manual ->
Script -> Infrastructure automatization • Easy • Procedural • Idempotent • Push • Agent-less • Batteries included 6. 12. 2017 2 No OS abstraction (e.g. Packages) No good noop
3.
https://lynt.cz Platforms • Linux/Mac/BSD –
SSH + Python • Windows – PowerShell • SSH raw mode: – Cisco IOS/ASA – Juniper Junos – VyOS – Any SSH enabled node • Mikrotik – unofficial/experimental via API 6. 12. 2017 3
4.
https://lynt.cz Content • http://edu.lynt.cz/course/ansible 6. 12.
2017 4 • Inventory • Patterns • Tasks • Playbooks • Lookups • Modules • Jinja • Handlers • Roles • Variables • Facts • Vault • Galaxy • Troubleshooting • Performance • Strategies
5.
https://lynt.cz Lab 6. 12. 2017
5
6.
https://lynt.cz Versions • https://github.com/ansible/ansible/blob/devel/CHANGELOG.md • … •
1.9 • … • 2.2 – Python 3 (3.5+), Stretch • 2.3 – dest->path (backward compatible) • 2.4 – Centos 7 (Centos 6 - Epel) • deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main 6. 12. 2017 6
7.
https://lynt.cz Installation • apt install
ansible • alias apl="ansible-playbook" 6. 12. 2017 7
8.
https://lynt.cz Inventory • /etc/ansible/hosts • ansible
--list-hosts all • Localhost: ansible ansible_connection=local • ansible -m ping all • ansible -m command -a "uptime" all • ansible -a "uptime" all 6. 12. 2017 8 Default module INI, YAML
9.
https://lynt.cz Groups [apps] 192.168.1.115 hostname [mgmt] ansible ansible_connection=local 6. 12.
2017 9
10.
https://lynt.cz Local Inventory • …./work_dir/hosts •
ansible -i hosts --list-hosts all • (-i <dir> - "inventory" file lookup) • Config overloading: – ENV ANSIBLE_CONFIG – ./ansible.cfg – ~/.ansible.cfg 6. 12. 2017 10 [defaults] inventory = ./hosts group_vars host_vars
11.
https://lynt.cz Patterns • http://docs.ansible.com/ansible/latest/intro_ patterns.html • ansible
--list-hosts all • ansible --list-hosts * • ansible --list-hosts 192* • ansible --list-hosts ansible • ansible --list-hosts 'all,!ansible' 6. 12. 2017 11
12.
https://lynt.cz Dynamic inventory Script output: { "app":
{ "hosts": [ "192.168.1.115" ] }, "mgmt": [ "ansible" ], "_meta": { "hostvars": { "ansible": { "ansible_connection": "local" } } } } 6. 12. 2017 12
13.
https://lynt.cz Tasks • Base building
blocks • ansible –m module –a mod_arguments hosts • ansible –m command –a uptime all • Options -f 5 / --forks=5 - FORKS, parallel runs -b / --become – privileged mode (su, sudo) -l / --limit – subset of hosts 6. 12. 2017 13
14.
https://lynt.cz Modules • http://docs.ansible.com/ansible/latest/modules_ by_category.html • Commands
– command, shell, raw, … • Packing – yum, apt, pip,… • System – service, cron, iptables, authorized_keys … • Cloud – various cloud providers • Files – various files operations • Utilities – playlist logic helpers 6. 12. 2017 14
15.
https://lynt.cz Playbooks • tasks YAML
format --- - hosts: all tasks: - command: uptime https://gist.github.com/lynt- smitka/6d915fd1deff917ac2bf2c45ceb39c82 http://docs.ansible.com/ansible/latest/common_return_values.html 6. 12. 2017 15
16.
https://lynt.cz Add SSH key --- -
hosts: new tasks: - name: Add SSH key authorized_key: user: root state: present key: "{{lookup('file', '~/.ssh/id_rsa.pub') }}" • apl sshkey.yml --ask-pass -u user --become --become-method=su -- ask-become-pass --ssh-common-args='-o StrictHostKeyChecking=no' 6. 12. 2017 16
17.
https://lynt.cz Lookups • http://docs.ansible.com/ansible/latest/playbo oks_lookups.html • File •
Password 6. 12. 2017 17
18.
https://lynt.cz Inventory arguments [new] 192.168.1.117 192.168.1.118 192.168.1.119 [new:vars] ansible_user=user ansible_become=yes ansible_become_method=su ansible_ssh_common_args='-o StrictHostKeyChecking=no' 6.
12. 2017 18
19.
https://lynt.cz APT --- - hosts: all tasks: -
name: install package apt:name=mc state=present update_cache=yes 6. 12. 2017 19
20.
https://lynt.cz APT multiple packages --- -
hosts: all tasks: - name: install packages apt:name=mc,curl state=present update_cache=yes 6. 12. 2017 20
21.
https://lynt.cz APT multiple packages
– yaml syntax --- - hosts: all tasks: - name: install packages apt: name: mc,curl state: present update_cache: yes 6. 12. 2017 21
22.
https://lynt.cz APT multiple packages
- loop --- - hosts: all tasks: - name: install packages apt: name={{item}} state=present update_cache=yes with_items: - mc - curl - vim - git http://docs.ansible.com/ansible/latest/playbooks_loops.html 6. 12. 2017 22
23.
https://lynt.cz Files operations • http://docs.ansible.com/ansible/latest/list_of_fil es_modules.html •
Copy • File • LineInFile/BlockInFile • Ini_file • Replace • Template 6. 12. 2017 23
24.
https://lynt.cz File module • http://docs.ansible.com/ansible/latest/file_m odule.html •
Set owner, mode • Create dir (whole path), symlink, hardlink • Touch file (state=touch) • Remove file (state=absent) 6. 12. 2017 24
25.
https://lynt.cz Copy module • http://docs.ansible.com/ansible/latest/copy_mo dule.html -
copy: src: nginx.conf dest: /etc/nginx/nginx.conf backup: yes • content/src • force 6. 12. 2017 25
26.
https://lynt.cz Copy content - copy: dest:
/etc/hosts backup: yes content: | 127.0.0.1 localhost 192.168.1.115 ansible 6. 12. 2017 26
27.
https://lynt.cz LineInFile module http://docs.ansible.com/ansible/latest/lineinfile_module.html - lineinfile: dest:
/etc/hosts line: '8.8.8.8 dns' - lineinfile: dest: /etc/nginx/nginx.conf regexp: '^user ' line: 'user www-data;' * last instance 6. 12. 2017 27
28.
https://lynt.cz Replace module - replace: dest:
/etc/nginx/web.conf regexp: old.domain' replace: 'new.domain' backup: yes * All instances 6. 12. 2017 28
29.
https://lynt.cz BlockInFile module http://docs.ansible.com/ansible/latest/blockinfile_ module.html - blockinfile: dest:
/etc/ssh/sshd_config block: | … # BEGIN ANSIBLE MANAGED BLOCK … # END ANSIBLE MANAGED BLOCK 6. 12. 2017 29
30.
https://lynt.cz IniFile module http://docs.ansible.com/ansible/latest/ini_file_ module.html - ini_file: dest="/etc/php/7.0/fpm/php.ini" section="Date" option="date.timezone" value="Europe/Prague" 6.
12. 2017 30
31.
https://lynt.cz Template module http://docs.ansible.com/ansible/latest/template _module.html - template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf 6.
12. 2017 31
32.
https://lynt.cz Jinja Templates • http://jinja.pocoo.org/docs/2.10/templates •
Variables {{ ansible_distribution }} • Filters {{ ansible_distribution|capitalize }} • Loops {% for item in groups.app %} server {{ item }}; {% endfor %} • Conditionals + tests 6. 12. 2017 32
33.
https://lynt.cz Jinja Conditionals +
tests {% if variable is defined %} value of variable: {{ variable }} {% else %} variable is not defined {% endif %} 6. 12. 2017 33
34.
https://lynt.cz Handlers tasks: - name: config
nginx template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf notify: - restart nginx handlers: - name: restart nginx service: name=nginx state=restarted 6. 12. 2017 34
35.
https://lynt.cz Roles • ansible-galaxy init
<role-name> test-role/ ├── defaults │ └── main.yml ├── files │ └── file.txt ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── templates │ └── template.j2 ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml 6. 12. 2017 35
36.
https://lynt.cz Variables • http://docs.ansible.com/ansible/latest/playbo oks_variables.html#variable-precedence- where-should-i-put-a-variable • apl
x.yml --extra-vars "…" • roles: - { role: mysql, db_name: demo } • group_vars folder • host_vars folder 6. 12. 2017 36
37.
https://lynt.cz Facts • ansible –m
setup all • /etc/ansible/facts.d/*.fact - name: Upload simple fact copy: content: "1" dest: /etc/ansible/facts.d/test.fact 6. 12. 2017 37
38.
https://lynt.cz Facts • ansible –m
setup all … "ansible_local": { "one": 1 } … 6. 12. 2017 38
39.
https://lynt.cz Dynamic facts • chmod
+x ;-) • Json output #!/bin/bash curl --silent --connect-timeout 1 ifconfig.co/json 6. 12. 2017 39
40.
https://lynt.cz Vault • ansible-vault create
vault.file • ansible-vault edit vault.file • apl stack-init.yml --ask-vault-pass [default] vault_password:file = ~/.vaultpass 6. 12. 2017 40
41.
https://lynt.cz Vault example --- - pass:
'secret' cat vault.file $ANSIBLE_VAULT;1.1;AES256 326564303339633037383163333836653564633339313130306632323635313336353 36637373162… --- - hosts: mgmt vars_files: - 'vault.file' tasks: - debug: msg: '{{pass}}' 6. 12. 2017 41
42.
https://lynt.cz Galaxy • https://galaxy.ansible.com/ • ansible-galaxy
install username.role_name • ansible-galaxy install -p roles -r requirements.yml requirements.yml: # from galaxy - src: yatesr.timezone # from GitHub - src: https://github.com/bennojoy/nginx 6. 12. 2017 42
43.
https://lynt.cz Performance • gather_facts: false -
hosts: all become: true gather_facts: false tasks: - name: update apt cache apt: update_cache=yes cache_valid_time=86400 [ssh_connection] Pipelining = True 6. 12. 2017 43
44.
https://lynt.cz Ansible-pull • https://github.com/ansible/ansible- examples/blob/master/language_features/ans ible_pull.yml 6. 12.
2017 44
45.
https://lynt.cz Discussion • Strategies • Troubleshooting 6.
12. 2017 45
Télécharger maintenant