# disable\_service\_controls is not working

**URL:** <https://forum.ansible.com/t/disable-service-controls-is-not-working/33110>\
**Category:** Ansible Project\
**Created:** [June 7, 2020, 12:41am UTC](https://forum.ansible.com/t/disable-service-controls-is-not-working/33110 "2020-06-07T00:41:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishwas\_Govekar](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@Vishwas\_Govekar](https://forum.ansible.com/u/Vishwas_Govekar)\
**Post date:** [June 7, 2020, 12:41am UTC](https://forum.ansible.com/t/disable-service-controls-is-not-working/33110/1 "2020-06-07T00:41:05Z")

</div>

Hi

I have ansible roles for each app which has stop and start tasks ,I have global role deploy\_all which use stop all ,deploy apps in sequential order and start all  
When I call the global role deploy\_all the local start and stop should not work .I have passed the when: “{{ disable\_service\_controls | default(false) }}” == false in start.yml But it is failing  
Anys suggestions how to fix it

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [June 7, 2020, 3:15am UTC](https://forum.ansible.com/t/disable-service-controls-is-not-working/33110/2 "2020-06-07T03:15:29Z")

</div>

Hi Vishwas,

Without looking at logs and playbooks used, it is very difficult to tell what is wrong. Please provide details about background, roles used, a snippet of playbook failing, console log of the run, debugging steps taken, etc.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 7, 2020, 3:45am UTC](https://forum.ansible.com/t/disable-service-controls-is-not-working/33110/3 "2020-06-07T03:45:00Z")

</div>

> &nbsp;&nbsp;when: "{{ disable\_service\_controls|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default(false) }}" == false

See "The When Statement"  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_conditionals.html#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

&nbsp;&nbsp;\> cat pb.yml  
&nbsp;&nbsp;- hosts: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: Disabled  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: disable\_service\_controls|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default(false)|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- set\_fact:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disable\_service\_controls: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: Disabled  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: disable\_service\_controls|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default(false)|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool

It will skip the first debug. (Gives abridged)

&nbsp;&nbsp;TASK [debug] \*\*\*\*  
&nbsp;&nbsp;skipping: [localhost]  
&nbsp;&nbsp;TASK [set\_fact] \*\*\*\*  
&nbsp;&nbsp;ok: [localhost]  
&nbsp;&nbsp;TASK [debug] \*\*\*\*  
&nbsp;&nbsp;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](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.

&nbsp;&nbsp;\> ansible-playbook pb.yml -e "disable\_service\_controls=true"

HTH,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 7, 2020, 6:33pm UTC](https://forum.ansible.com/t/disable-service-controls-is-not-working/33110/4 "2020-06-07T18:33:22Z")

</div>

> \> \> when: "{{ disable\_service\_controls|  
> \> \> default(false) }}" == false

> \> when: disable\_service\_controls|  
> \> default(false)|  
> \> bool

> Does the script look good  
> [...]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: "disable\_service\_controls is not defined or  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disable\_service\_controls == false"

No. It does not. This one (in the previous email) looks good

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: disable\_service\_controls|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default(false)|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool
