I recently started using ansible to automate some server administration tasks.
Its very cool and easy to learn/extend. One nice feature is the “facts” gathering. It will collect information about the host(s) and stores them in its internal variables. This is useful for conditional execution of tasks (see below) but also as a ad-hoc way to gather information like DMI information or the running kernel.
To see all “facts” known to ansible about the hosts, run:
$ ansible all -m setup
To execute tasks conditionally you can do something like this:
- name: install vmware packages action: apt pkg=open-vm-tools only_if: "'$ansible_virtualization_type' == 'VMware'"
Note that ansible 1.2+ has a different (and simpler) conditional called “when”.
Ansible is available in Ubuntu 12.04+ via:
$ sudo apt-get install ansible
It is also available in Debian unstable and testing.
May 31, 2013 at 11:32 am |
Ansible is not available from the default Ubuntu repos(yet?). You have to install some custom PPA which provides it.
May 31, 2013 at 1:14 pm |
Yeah, its not part of the normal repo, but it is available via the {precise,quantal,raring}-backports repository. I should have mentioned that in the post.
September 19, 2020 at 5:03 am |
áo lá cờ việt nam giá rẻ
Ansible and the facts from the “setup” module | Michael Vogt's blog