ansible rychlý úvod - soit · deploying new servers “install this software on this servers.”...
TRANSCRIPT
![Page 1: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/1.jpg)
Ansiblerychlý úvod
Věroš Kaplan@verosk
http://inuits.eu/
http://veroskaplan.cz/
![Page 2: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/2.jpg)
Managing computers
“It’s quick change here and there…”“And fix this, please.”“Install this software. Fix it.”
![Page 3: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/3.jpg)
Deploying new servers
“Install this software on this servers.”“Make a copy of this machine and change something.”ASAP
2 servers ->
![Page 4: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/4.jpg)
Image by Torkild Retvedt, CC BY SA
![Page 5: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/5.jpg)
PuppetOne manifest rules them all!
… a potom!
![Page 6: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/6.jpg)
![Page 7: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/7.jpg)
… but after some time
● lost in curly brackets● lost in manifest dependencies● lost in duplicate resource names
● a bit lost in Ruby● puppet master can’t be bootstrapped by
Puppet● OOM
DISCLAIMER: in fact, not Puppet problem, but my bad usage of Puppet!
![Page 8: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/8.jpg)
Ansible
You can start in minutesNo agent installation
Readable recipesPython insideJinja inside
http://ansible.com/http://github.com/ansible/ansible
![Page 9: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/9.jpg)
AnsibleIn fact, it’s parallel ssh...
…. but done in smart way.
![Page 10: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/10.jpg)
● deployment of internal systems○ owncloud, iSCSI…○ whatever…
● automation of error-prone tasks○ resize file system, LVM and pack it○ mass configuration of KVM guests○ deploy testing machine (6 times a day)
● authorized_keys
(My) usage
![Page 11: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/11.jpg)
Installation
$ yum install ansible||
$ pip install ansible
![Page 12: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/12.jpg)
Hello, Ansible!
$ ansible -i hosts -m ping all
astarte | success >> { "changed": false, "ping": "pong"}
![Page 13: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/13.jpg)
Run ansible module
$ ansible -i hosts -m ping all
inventory file
module
host selection
![Page 14: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/14.jpg)
![Page 15: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/15.jpg)
SSH key distribution
$ ansible -i hosts -m authorized_key \-a “user=root key=’ssh-rsa …. verosk’ ” \all
…40 hosts OK
![Page 16: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/16.jpg)
Simple playbook
● YAML based● list of tasks
$ ansible-playbook -i hosts playbook.yml -v
![Page 17: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/17.jpg)
![Page 18: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/18.jpg)
![Page 19: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/19.jpg)
![Page 20: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/20.jpg)
Role based playbook
● machine roles are defined○ webserver, DB server, KVM server,...○ role is YAML playbook
● machines in groups○ by inventory file
● roles are applied to machines || groups
● roles depends on each other
![Page 21: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/21.jpg)
![Page 22: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/22.jpg)
![Page 23: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/23.jpg)
Interesting features
handlersregister_variablefailed_whenignore_errorsnotifydelegate_touser, sudo_user
tagsasync_taskwith_items, with_*
ansible-pullansible-vault
![Page 24: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/24.jpg)
FAQ
![Page 26: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/26.jpg)
$ ansible -c local localhost -m setup
local facts in/etc/ansible/facts.d/
Facts
![Page 27: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/27.jpg)
Distribution dependent playbooks
- message: Debian when: ansible_os_distribution == ‘debian’
- include_vars: {{ansible_os_distribution}}
https://galaxy.ansible.com/list#/roles/1229
![Page 28: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/28.jpg)
Demo time?
![Page 29: Ansible rychlý úvod - SOIT · Deploying new servers “Install this software on this servers.” “Make a copy of this machine and change something.” ASAP 2 servers ->](https://reader036.vdocument.in/reader036/viewer/2022081406/5f0fb7317e708231d44587bf/html5/thumbnails/29.jpg)
in Vagrant
https://github.com/VerosK/vagrant-playground-logstash-kibana
Logstash (E+L+K)