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

349 views
Skip to first unread message

Kurtis Rainbolt-Greene

unread,
Feb 10, 2020, 1:30:39 PM2/10/20
to Ansible Development
[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?

James Cassell

unread,
Feb 10, 2020, 2:39:25 PM2/10/20
to Ansible Development List
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

Kurtis Rainbolt-Greene

unread,
Feb 10, 2020, 9:21:31 PM2/10/20
to James Cassell, Ansible Development List
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/07b80394-a644-4986-a271-429aa75ed6fe%40www.fastmail.com.


--
Kurtis Rainbolt-Greene, Software Developer
Founder of Difference Engineers

James Cassell

unread,
Feb 10, 2020, 9:47:39 PM2/10/20
to Ansible Development List

On Mon, Feb 10, 2020, at 9:20 PM, Kurtis Rainbolt-Greene wrote:
[cut]
> On Mon, Feb 10, 2020 at 11:39 AM James Cassell
> <fedora...@cyberpear.com> wrote:
> >
> > On Mon, Feb 10, 2020, at 1:30 PM, Kurtis Rainbolt-Greene wrote:
> > > [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

Kurtis Rainbolt-Greene

unread,
Feb 11, 2020, 6:52:47 PM2/11/20
to James Cassell, Ansible Development List
Ah, okay, that makes sense now.

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages