Te sugiero que leas la decodificación del informe de 2019 de Sergey Pechenko "Ansible, ¡esto no es para ti!"
![](https://habrastorage.org/webt/qu/6p/ie/qu6pied7yneriwzio_7bz_mzzmu.png)
Algunas palabras sobre mi.
![](https://habrastorage.org/webt/o1/ky/xu/o1kyxuaxusmyl803qv0poxkba1g.png)
Ingeniero. Sé algo sobre TI y estoy listo para compartir este conocimiento. Como las personas que tienen preguntas específicas; no les gusta la gente que quiere que alguien haga todo por ellos.
![](https://habrastorage.org/webt/sw/iq/wa/swiqwarpy72jgjszumpl5vmhxpc.png)
Breve resumen de la historia:
- Preparando el suelo.
- («bashsible»).
- ?
- , .
- .
- .
- .
- Jinja, !
![](https://habrastorage.org/webt/4b/p2/xz/4bp2xzcvqlvhps18y5ocu9ndbkk.png)
Ansible, . .
![](https://habrastorage.org/webt/zn/4g/9i/zn4g9in7l2cfvlju2fyhn7zlkjs.png)
-, . Ansible . . – . , Ansible <.. group_vars> . yaml, - , Git, . . . Ansible 5 , .
![](https://habrastorage.org/webt/3o/fo/su/3ofosu2hombis_qqg4c7dsqe-su.png)
< > . 2.1, – , , . , , , - .
– . AWS. Ansible , . . .
![](https://habrastorage.org/webt/gr/cx/qh/grcxqh4bz8xorq0chokkdadeozw.png)
– , Ansible @pro_ansible.
![](https://habrastorage.org/webt/xs/os/-r/xsos-rly8ivdv6o9qmw0umabcfg.png)
— . , , , Ansible. , . : « ?». , , .
![](https://habrastorage.org/webt/e3/jr/hc/e3jrhcf1n1afp4c31x4wvidbnwe.png)
. . , – , Ansible.
Ansible , . , . , . Ansible, , , . , – , , , , . .
, .
![](https://habrastorage.org/webt/3r/mq/_e/3rmq_eilsrqwo6awfovbfhpjrim.png)
, Ansible, Ansible. . 4 . , , . – , - . – . - «play» — , . «Playbook» — . 2 play playbook.
Ansible «all». , . Ansible — inventory. , . , . , , inventory , . . < > all, 2, 3, host3 <>. , . , ?
. . – ? , , ? , ? «» «».
![](https://habrastorage.org/webt/st/o1/vo/sto1vodtbovmhkixjebbvjlgtzy.png)
. . . , . , , «» «».
– 80% 20% , . 20% 80% . , .
![](https://habrastorage.org/webt/bg/yj/cy/bgyjcy38cdp7uqnwwwcqyzm0qjq.png)
, , . Ansible . Python .
Python , Python - . Ansible . .
, Python, . , . , , Senoir YAML Developer.
, , . – . , , , . , , .
![](https://habrastorage.org/webt/nt/xx/xl/ntxxxlfpl0btoiogrltwup4xyqg.png)
. , , , (« »). , - , , .
, , , , . , inventory, , . YaML, Senior YaML Developer, « Ansible» — , .
, . Ansible , , — . «library». . . , , – Python , , , . .
Python- - « » — - « », «module_utils». , . , . .
![](https://habrastorage.org/webt/yl/mr/n3/ylmrn3i1oip1e6fsurvqqghom8u.png)
. ? , , – . , , , IT, , , . . GPL'. . . , exception .
? Ansible. , , . . exceptions, , . . – . , , . . , , , , , .
![](https://habrastorage.org/webt/lv/s7/wb/lvs7wb1jfufr3nj78tnjqoivkfa.png)
. Changed = False. , changed – ok. . message, . – - .
. , Ansible’ «». «host_vars». «host_vars[_]» . Ansible.
? , , ansible_facts - host_vars , . Controller , host_vars.
set_fact - . . , - , - . Python-, .
AnsibleModule, . Argument_spec – , . : « -, -». argument_spec Ansible , , ; , «» . , . , . , , .
![](https://habrastorage.org/webt/4n/mf/a1/4nmfa105ay7l4oa3jyet14mdc9g.png)
Ansible. . , - 2.4, , , , Grafana'. - «uri», bashsible, — shell, curl, JSON c Grafana' . , , Grafana' .
, , . , — , . . , «_spec», . , «file», , : , owner, group, chmod. , c . , , . .
, — - , , Ansible, , . : – .
Ansible aliases (<>). «grafana_url» «url» — . , . «required = true». - . .
, Grafana. ? . .
![](https://habrastorage.org/webt/54/xv/b4/54xvb4vlu1jokm0jgoid9ndal_e.png)
argument_spec, , . , check_mode.
, check_mode? . : , , . , , production.
production ? , . check_mode? , production. , — - . , 100 . ? , check_mode .
, , check_mode, Grafana . : Grafana, , .
, . «required_together», Ansible , , . — , Ansible , .
mutually_exclusive, . . : , , . . , . - , , , , , .
exception, .
— production , . Ansible. , - , . .
![](https://habrastorage.org/webt/9p/uw/8t/9puw8t_rau095udqhr1kw2kmsme.png)
. . , , . action plugins, callback plugins .. , «*_plugins» library " ". , , .
Ansible . , , . — , .
![](https://habrastorage.org/webt/lc/aw/lu/lcawlutf6p9z4at14cbj-tkuoaq.png)
action-. - < >. : tasks, assert . , . .
![](https://habrastorage.org/webt/vf/ff/ai/vfffai8lwzed2jbxwlx0xnh_vwe.png)
. , , - . Python- c if __name__ == '__main__'
, . . : , «run». Ansible . , .. , .
import Ansible, – action-.
![](https://habrastorage.org/webt/lk/qj/ti/lkqjtisr94sqrvy3riw-jac0p-0.png)
— , , . , . — .
![](https://habrastorage.org/webt/iz/1b/lc/iz1blcgayuxqs52cpdxikyn3scw.png)
? - . Jinja. Jinja2 (2.10). , , Ansible.
![](https://habrastorage.org/webt/xj/jo/uj/xjjoujmbx2mpwtxkfh7ub0juq0u.png)
Jinja . , . .
– , , , . . , .
– . , - Jinja, - , . , Ansible , . . , .
, , Jinja2 . , . , . Jinja .
![](https://habrastorage.org/webt/ks/td/b_/kstdb_kdfvn0xprjs2z3zpxscha.png)
– , , . - . , .
. – cache behavior = merge. . . – «combine». «combine», .
![](https://habrastorage.org/webt/sn/8a/cd/sn8acdxj2hgz-rkr34_ohe0oezc.png)
? , . group_vars/all – , - , . . group1, group2.
, «all». – hostvars. , . . - , , . . , .
![](https://habrastorage.org/webt/-v/tz/2p/-vtz2pu9tqilib0qnnd6drbeftw.png)
№2 – . , , . , .
![](https://habrastorage.org/webt/qu/dw/pi/qudwpizhh8emfiz906jifmiax98.png)
? . YaML Jinja. — «from_yaml» — .
![](https://habrastorage.org/webt/vp/xp/52/vpxp52otcedgoe3ejkoc7cmqeli.png)
, ! , Ansible , . ?
. , . ? , , Ansible, Ansible 2.4. . , «uri», REST API, Consul'. , key-value Ansible. . . backend , « ». curl — , - . , «library», requests , backend'. .
. c Zabbix - . , , . . . < >, , . , Zabbix « ».
. , Ansible .
, . – - daemon, , . «agentless» Ansible – SSH, . , , .
. : , , Ansible Tower?
Ansible Tower , , , – , .
OpenSource .
OpenSource – AWX.
.
-, , - AWX , , . Ansible- . Ansible CI/CD, jobs, Jenkins, , , Rundeck. , shell-, ansible-playbook .
, DevOps Ansible , , ?
job, , Jenkins , job . job. . . .
?
.
! , , ? , , - . , - .
-, ansible-lint, . , . ? ansible-lint? – . .
. . ?
— molecule.
! Ansible. Linux . , . , - , .
, . , , Ansible, , 5 ? , - -. , open-source’ ( napalm).
Linux .
Cisco , .
Terraform – , ?
Tuve experiencia Ansible sin un montón de Terraform. Fue un despliegue, fue Amazon, fueron cinco regiones. Cuando después de dos regiones dijeron que se necesitaba un tercero, agregué varias líneas y las desplegué.
Vídeo: