Changes

Jump to navigation Jump to search
115 bytes added ,  22:08, 3 August 2020
no edit summary
You can use the '''command module''' (secure but simple) or the '''[https://docs.ansible.com/ansible/shell_module.html shell module]'''. The latter may be useful if you need to run bash explicitly (defaults to /bin/sh); or anytime you need $HOME and redirection.
To sanitize any variables passed to the shell module, you should use <nowiki>"{{ var | quote }}" instead of just "{{ var }}"</nowiki> to make sure they don't include evil things like semicolons. 
The array notation is preferred over the dot notation for accessing variables.
<nowiki>{{ ansible_eth0["ipv4"]["address"] }} over {{ ansible_eth0.ipv4.address }} </nowiki> because some keywords in Python would conflict
Reserved words:
* environemnt
'''inventory_hostname''' is the name of the hostname as configured in Ansible's inventory host file. '''ansible_hostname''' is the discovered hostname
You can use a variables file to put sensitive data in a different file (one excluded from git).
* [http://jinja.pocoo.org/docs/dev/ Jinja] - the template engine for Ansible
* [https://cheat.readthedocs.io/en/latest/ansible/index.html Dan's Cheat Sheets]
{{References}}
[[Category:Virtualization]]
[[Category:Configuration Management]]
[[Category:DevOps]]

Navigation menu