Ansible is not bash for you. Sergey Pechenko

I suggest that you read the decoding of the 2019 report by Sergei Pechenko "Ansible - this is not for you bash!"



A few words about me.



Engineer. I know something about IT and am ready to share this knowledge. Like people who come up with specific questions; they donā€™t like people who want someone to do everything for them.



Short outline of the story:


  • Preparing the soil.
  • (Ā«bashsibleĀ»).
  • ?
  • , .
  • .
  • .
  • .
  • Jinja, !


Ansible, . .



-, . Ansible . . ā€“ . , Ansible <.. group_vars> . yaml, - , Git, . . . Ansible 5 , .



< > . 2.1, ā€“ , , . , , , - .


ā€“ . AWS. Ansible , . . .



ā€“ , Ansible @pro_ansible.



ā€” . , , , Ansible. , . : Ā« ?Ā». , , .



. . , ā€“ , Ansible.


Ansible , . , . , . Ansible, , , . , ā€“ , , , , . .


, .



, Ansible, Ansible. . 4 . , , . ā€“ , - . ā€“ . - Ā«playĀ» ā€” , . Ā«PlaybookĀ» ā€” . 2 play playbook.


Ansible Ā«allĀ». , . Ansible ā€” inventory. , . , . , , inventory , . . < > all, 2, 3, host3 <>. , . , ?


. . ā€“ ? , , ? , ? Ā«Ā» Ā«Ā».



. . . , . , , Ā«Ā» Ā«Ā».


ā€“ 80% 20% , . 20% 80% . , .



, , . Ansible . Python .


Python , Python - . Ansible . .


, Python, . , . , , Senoir YAML Developer.


, , . ā€“ . , , , . , , .



. , , , (Ā« Ā»). , - , , .


, , , , . , inventory, , . YaML, Senior YaML Developer, Ā« AnsibleĀ» ā€” , .


, . Ansible , , ā€” . Ā«libraryĀ». . . , , ā€“ Python , , , . .


Python- - Ā« Ā» ā€” - Ā« Ā», Ā«module_utilsĀ». , . , . .



. ? , , ā€“ . , , , IT, , , . . GPL'. . . , exception .


? Ansible. , , . . exceptions, , . . ā€“ . , , . . , , , , , .



. 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 , , ; , Ā«Ā» . , . , . , , .



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. ? . .



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. , - , . .



. . , , . action plugins, callback plugins .. , Ā«*_pluginsĀ» library " ". , , .


Ansible . , , . ā€” , .



action-. - < >. : tasks, assert . , . .



. , , - . Python- c if __name__ == '__main__', . . : , Ā«runĀ». Ansible . , .. , .


import Ansible, ā€“ action-.



ā€” , , . , . ā€” .



? - . Jinja. Jinja2 (2.10). , , Ansible.



Jinja . , . .


ā€“ , , , . . , .


ā€“ . , - Jinja, - , . , Ansible , . . , .


, , Jinja2 . , . , . Jinja .



ā€“ , , . - . , .


. ā€“ cache behavior = merge. . . ā€“ Ā«combineĀ». Ā«combineĀ», .



? , . group_vars/all ā€“ , - , . . group1, group2.


, Ā«allĀ». ā€“ hostvars. , . . - , , . . , .



ā„–2 ā€“ . , , . , .



? . YaML Jinja. ā€” Ā«from_yamlĀ» ā€” .



, ! , 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 ā€“ , ?


I had Ansible experience without a bunch of Terraform. It was a deployment, it was Amazon, it was five regions. When after two regions they said that a third was needed, I added several lines and unfolded.


Video:



All Articles