Changes

Jump to navigation Jump to search
1,202 bytes added ,  22:08, 3 August 2020
no edit summary
== Installation ==
The preferred way to [http://docs.ansible.com/intro_installation.html install] is to just <code>git clone</code> the source. Having the source makes it easy to upgrade, and it's self-contained, plus best of all you get all the examples and contribs.
 
<source lang="bash">
cd
mkdir ~/bin
cd bin
git clone git://github.com/ansible/ansible.git --recursive
cd ./ansible
source ./hacking/env-setup
</source>
 
If you see this error message:
<pre>
=== Initialize a Project ===
'''Ansible Galaxy''' If you want to do a new project, you can use the <code>ansible-galaxy foo init</code> command which will create the directory and file structure for 'foo' in the current working directory.
 
Also, if you want to install other Ansible Galaxy projects, you can either do it "manually" <code> ansible-galaxy install -r </code> Or, setup a 'requirements.yml' file in your playbook that then gets run by your stack. <ref>https://stackoverflow.com/questions/25230376/how-to-automatically-install-ansible-galaxy-roles</ref> <code>ansible-galaxy [delete|import|info|init|install|list|login|remove|search|setup] [--help] [options]</code>
== 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].
There are a bunch of modules in Ansible, like You can use the [https://docs.ansible.com/ansible/mysql_db_module.html MySQL module], the [https://docs.ansible.com/ansible/monit_module.html Monit '''command module], ''' (secure but simple) or the '''[https://docs.ansible.com/ansible/file_moduleshell_module.html File shell module] and other interesting modules like jabber, mail, sendgrid, dpkg_selections, composer, yum, redhat_subscription, the [https://docs'''.ansible.com The latter may be useful if you need to run bash explicitly (defaults to /ansiblebin/authorized_key_module.html authorized_key module] for working with SSH keys, sh); or anytime you need $HOME and a whole section of [https://docs.ansible.com/ansible/list_of_system_modules.html system modules]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 ==
== Ansible with Vagrant ==
https://docs.ansible.com/ansible/guide_vagrant.htmland [[Private:QualityBox/Vagrant]]
== Ansible with MediaWiki ==
* [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