Ansible greatest trick: iterate over a set of host
While running a playbook on a host you can request some information about other nodes.
The task will look like this:
- name: build account ring |
Please note that I had to escape the {
with a \
so you can actually see it. Remove it from your task.
The above task is extremely useful since it allows me to retrieve the IP address on a specific network card (the one referred in the iface
variable) of a group of hosts.
Basically I am executing the swift-ring-builder
command where I register a couple of nodes.
Here the hosts are called storages
, thus somewhere on my host
file I have a [storages] section that defines several machines.
Ansible Magic! This start at thing is pretty neat too!
Comments