question about 'when' conditional

Hi,

It’s look like i don’t understand perfectly when condition:

tasks:

  • set_fact:
    sensu_remote_plugins:

  • process-checks

  • http

  • disk-checks

  • memory-checks

  • load-checks

  • cpu-checks

  • io-checks

  • rabbitmq

  • network-checks

  • name: debug
    debug:
    var=sensu_remote_plugins
    when: “‘aws’ in sensu_remote_plugins”

It’s work as expected, (skiping on this exemple) :

TASK [debug] **********************************************************************************************************************
skipping: [xxxx]

But i want a more complex when condition to filter with ansible_os_family

After sevral search, this when condition work’s for me :

when:

  • ansible_os_family == “RedHat”
  • “‘aws’ in sensu_remote_plugins”
    TASK [debug] **********************************************************************************************************************
    skipping: [xxxx]

But why these are not working ? :

when: ( ansible_os_family == “RedHat” and “‘aws’ in sensu_remote_plugins”)
TASK [debug] **********************************************************************************************************************
ok: [xxxx] => {

when: (“‘aws’ in sensu_remote_plugins”) and ansible_os_family == “RedHat”

TASK [debug] **********************************************************************************************************************
ok: [xxxx] => {

when: (“‘aws’ in sensu_remote_plugins”) and (ansible_os_family == “RedHat”)
TASK [debug] **********************************************************************************************************************
ok: [xxxx] => {

Thanks in advance

ansible 2.3.2.0

too many quotes, in the first one they are needed for YAML
restrictions, if you start a value with a quote, it must finish with a
quote. These quotes are removed when passing to the evaluator, but not
in other cases.

This should work:
  when: ansible_os_family == "RedHat" and 'aws' in sensu_remote_plugins

Also, lists are 'implicit AND'
  when:
     - ansible_os_family == "RedHat"
     - "'aws' in sensu_remote_plugins"