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

[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.

V/r,
James Cassell

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.

[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

Ah, okay, that makes sense now.