Difference between revisions of "Ansible"
Jump to navigation
Jump to search
(A bit more info on ansible-galaxy) |
(link to the docs on setup) |
||
Line 12: | Line 12: | ||
source ./hacking/env-setup | source ./hacking/env-setup | ||
</source> | </source> | ||
− | |||
− | |||
If you see this error message: | If you see this error message: | ||
Line 44: | Line 42: | ||
== Modules == | == 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. | 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]. | 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 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. | ||
Line 57: | Line 53: | ||
Note: control verbosity with <code>-vvvv</code> | Note: control verbosity with <code>-vvvv</code> | ||
# <code>ansible -c local -i ~/ansible_hosts -m ping all</code> ping all the hosts in the inventory file | # <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> | + | # <code>ansible '''-m setup''' wiki.example.com</code> 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 '''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 | # <code>ansible all -m setup -a '''"filter=ansible_distribution*"'''</code> use a filter action to see specific variables |