Changes

Jump to navigation Jump to search
427 bytes added ,  22:08, 3 August 2020
no edit summary
source ./hacking/env-setup
</source>
 
 
If you see this error message:
== Modules ==
Ansible comes with [https://docs.ansible.com/ansible/modules_by_category.html over 200 modules] that you should get familiar with in order to use the system effectively.
 
There are a bunch of modules in Ansible, like the [https://docs.ansible.com/ansible/mysql_db_module.html MySQL module], the [https://docs.ansible.com/ansible/monit_module.html Monit module], or the [https://docs.ansible.com/ansible/file_module.html File module] and other interesting modules like jabber, mail, sendgrid, dpkg_selections, composer, yum, redhat_subscription, [https://github.com/ansible/ansible-modules-core/blob/devel/cloud/digital_ocean/digital_ocean.py digital ocean], the [https://docs.ansible.com/ansible/authorized_key_module.html authorized_key module] for working with SSH keys, and a whole section of [https://docs.ansible.com/ansible/list_of_system_modules.html system modules].
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.
You can use the '''command module''' (secure but simple) or To sanitize any variables passed to the '''[https://docs.ansible.com/ansible/shell_module.html shell module]'''. The latter may be useful if , you need should use <nowiki>"{{ var | quote }}" instead of just "{{ var }}"</nowiki> to run bash explicitly (defaults to /bin/sh); or anytime you need $HOME and redirectionmake sure they don't include evil things like semicolons.
 
== Example Commands ==
Note: control verbosity with <code>-vvvv</code>
# <code>ansible --help</code> display help
# <code>ansible --version</code> show version info
# <code>ansible -c local -i ~/ansible_hosts -m ping all</code> ping all the hosts in the inventory file
# <code>ansible '''-m setup''' wiki.example.com</code> will show you all Use the '''[https://docs.ansible.com/ansible/latest/setup_module.html setup]''' module to gather ansible 'facts' (aka [[ansible_variables]]) about that host.
# <code>ansible '''localhost''' -m setup -a 'gather_subset=!all'</code> or look at the localhost
# <code>ansible all -m setup -a '''"filter=ansible_distribution*"'''</code> use a filter action to see specific variables
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).
</source>
<code>ansible-playbook release.yml --extra-vars "hosts=vipers user=starbuck"</code>
 
Check [https://www.ansible.com/blog/ansible-performance-tuning Performance Tuning] like enabling <code>pipelining</code> which is off by default.
== Scope ==
* [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