# Strange deprecation warning wanting me to turn an equality statement into something that returns a boolean?

**URL:** <https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191>\
**Category:** Ansible Developer\
**Created:** [February 10, 2020, 6:30pm UTC](https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191 "2020-02-10T18:30:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurtis\_Rainbolt-Gre1](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@Kurtis\_Rainbolt-Gre1](https://forum.ansible.com/u/Kurtis_Rainbolt-Gre1)\
**Post date:** [February 10, 2020, 6:30pm UTC](https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191/1 "2020-02-10T18:30:39Z")

</div>

[DEPRECATION WARNING]: evaluating node\_leader\_hostname == service\_fqdn.stdout as a bare variable, this behaviour will go away and you might need to add |bool to the expression  
in the future. Also see CONDITIONAL\_BARE\_VARS configuration toggle… This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting  
deprecation\_warnings=False in ansible.cfg.

Here’s the step:

- name: Determine if leader  
set\_fact:  
node\_leader: node\_leader\_hostname == service\_fqdn.stdout

Does anyone have any idea what it’s talking about?

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [February 10, 2020, 7:38pm UTC](https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191/2 "2020-02-10T19:38:53Z")

</div>

The value is a string that looks like a boolean. Today, ansible does magic to turn it into a boolean, but in the future, it won't.

V/r,  
James Cassell

---

<div class="post-metadata">

**Author:** ![Kurtis\_Rainbolt-Gree](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@Kurtis\_Rainbolt-Gree](https://forum.ansible.com/u/Kurtis_Rainbolt-Gree)\
**Post date:** [February 11, 2020, 2:20am UTC](https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191/3 "2020-02-11T02:20:49Z")

</div>

Ah, I thought that might be it, however when I changed to:

node\_leader: node\_leader\_hostname == service\_fqdn.stdout | bool

Like it suggested it still complained.

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [February 11, 2020, 2:47am UTC](https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191/4 "2020-02-11T02:47:11Z")

</div>

[cut]

> \>  
> \> \> [DEPRECATION WARNING]: evaluating node\_leader\_hostname ==  
> \> \> service\_fqdn.stdout as a bare variable, this behaviour will go away and  
> \> \> you might need to add |bool to the expression  
> \> \> in the future. Also see CONDITIONAL\_BARE\_VARS configuration toggle..  
> \> \> This feature will be removed in version 2.12. Deprecation warnings can  
> \> \> be disabled by setting  
> \> \> deprecation\_warnings=False in ansible.cfg.  
> \> \>  
> \> \> Here's the step:  
> \> \>  
> \> \> - name: Determine if leader  
> \> \> set\_fact:  
> \> \> node\_leader: node\_leader\_hostname == service\_fqdn.stdout  
> \> \>  
> \> \>  
> \> \> Does anyone have any idea what it's talking about?  
> \> \>  
> \>  
> \> The value is a string that looks like a boolean. Today, ansible does magic to turn it into a boolean, but in the future, it won't.  
> \>

[paste]

> Ah, I thought that might be it, however when I changed to:
> 
> node\_leader: node\_leader\_hostname == service\_fqdn.stdout | bool
> 
> Like it suggested it still complained.

Indeed, the real problem is that you're setting the fact to the literal string `node_leader_hostname == service_fqdn.stdout | bool`.

You need jinja braces: `"{{ node_leader_hostname == service_fqdn.stdout }}"`

V/r,  
James Cassell

---

<div class="post-metadata">

**Author:** ![Kurtis\_Rainbolt-Gree](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@Kurtis\_Rainbolt-Gree](https://forum.ansible.com/u/Kurtis_Rainbolt-Gree)\
**Post date:** [February 11, 2020, 11:52pm UTC](https://forum.ansible.com/t/strange-deprecation-warning-wanting-me-to-turn-an-equality-statement-into-something-that-returns-a-boolean/32191/5 "2020-02-11T23:52:06Z")

</div>

Ah, okay, that makes sense now.
