When using "when:", you don't have to wrap variables in braces. Just do
this:

when: item.key == "php" or item.key == "perl"

For example, the following works for me:

$ cat test_with_dict.yml
- hosts: localhost
  connection: local
  gather_facts: no
  vars:
  - values:
      foo:
        val1: "this is foo value 1"
        val2: "this is foo value 2"
      bar:
        val1: "this is bar value 1"
        val2: "this is bar value 2"
      baz:
        val1: "this is baz value 1"
        val2: "this is baz value 2"
      bam:
        val1: "this is bam value 1"
        val2: "this is bam value 2"
  tasks:
  - name: do loop over values dictionary
    debug: var=item.value.val1
    with_dict: values
    when: item.key == 'foo' or item.key == 'bar'




On Mon, May 5, 2014 at 3:57 PM, Samnang Sen <[email protected]> wrote:

> I have a list of modules I would like to deploy. With certain modules, I
> want to run a specific command against it. For example, if the module is a
> PHP or PERL module, I want to modify the ownership of the folder. If it's
> anything else, ignore the task.
>
> The task below fails
>
> - name: Modify ownership
>       shell: chown www:www {{ module_path }}
>       with_dict: deploy_modules
>       when: '"{{ item.key }} == "php" or {{ item.key }} == "perl"'
>
> TASK: [web | Modify ownership]
> *****************************************************
> fatal: [web01] => error while evaluating conditional: "php == "perl" or
> php == "php"
> fatal: [web02] => error while evaluating conditional: "php == "perl" or
> php == "php"
>
> --
> 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/11fc9d73-a04b-42c3-955b-d555015253b4%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/11fc9d73-a04b-42c3-955b-d555015253b4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMFyvFgsyeJbZQuv-7OAdxMKF6ciFLXL-bNDEjZd8tzvuvR3oQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to