Hello all!
I have playbook with following parts:

vars:
  servers:
    - { address: "192.168.122.12", role: "upstream" }
    - { address: "192.168.122.13", role: "downstream" }
    - { address: "192.168.122.14", role: "downstream" }
task:
  - name: Task
     command: "/usr/sbin/somecommand"

How I can execute task only on upstream or downstream servers? Any help 
appreciated.

P.S. I try following part, but it doesn't work:
task:
  - name: Task
    command: "/usr/sbin/somecommand"
    when: "servers.role == upstream"

And got error: 
fatal: [vm12-centos7] => error while evaluating conditional: servers.role 
== upstream
fatal: [vm13-centos7] => error while evaluating conditional: servers.role 
== upstream
fatal: [vm14-centos7] => error while evaluating conditional: servers.role 
== upstream

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/49234d35-06db-4a7a-8929-9d23ea542f69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to