On Sat, 6 Jun 2020 17:41:05 -0700 (PDT)
Vishwas Govekar <[email protected]> wrote:

>   when: "{{ disable_service_controls|
>             default(false) }}" == false

See "The When Statement"
https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#the-when-statement
" ... which contains a raw Jinja2 expression without double curly braces."

Try this playbook

  shell> cat pb.yml
  - hosts: localhost
    tasks:
      - debug:
          msg: Disabled
        when: disable_service_controls|
              default(false)|
              bool
      - set_fact:
          disable_service_controls: true
      - debug:
          msg: Disabled
        when: disable_service_controls|
              default(false)|
              bool

It will skip the first debug. (Gives abridged)

  TASK [debug] ****
  skipping: [localhost]
  TASK [set_fact] ****
  ok: [localhost]
  TASK [debug] ****
  ok: [localhost] => { "msg": "Disabled" }


Use "bool" filters. See "Bare variables in conditionals"
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html#bare-variables-in-conditionals
" ... update your conditional statements so they accept only boolean values."

In addition to this, try --extra-vars. Extra vars pass the values always as
strings. The explicit conversion to boolean is necessary.

  shell> ansible-playbook pb.yml -e "disable_service_controls=true"

HTH,

        -vlado

-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200607054500.1f15beef%40gmail.com.

Attachment: pgpw00fB2zmTR.pgp
Description: OpenPGP digital signature

Reply via email to