Alexey,
The easiest way to do this is to use hostvars in your inventory and set a
"role" variable for each host. Then, in your task you could be:
tasks:
- name: Task
command: "/usr/bin/somecommand"
when: role == "upstream"
Alternatively, if you want to set the variables here, this would work
(tested):
---
- name: Playbook
hosts: all
vars:
servers:
"192.168.122.12": "upstream"
"192.168.122.13": "downstream"
"192.168.122.14": "downstream"
tasks:
- name: Task
command: "/usr/bin/somecommand"
when: servers[ansible_default_ipv4.address] == "upstream"
This evaluates the ip address of whatever host is being used and evaluates
the correct variable inside the "servers" hash. There are other ways to
organize the variables, and it isn't best practice to have numbers as
variable names, but it works!
\Chip
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/fa7276fe-b8fa-416a-abe5-6e3a9540b247%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.