strange jinja logic

I have:

`

  • debug: var=_consul_install_agent
  • debug: var=consul_use_dnsmasq
  • debug: msg=“{{_consul_install_agent and consul_use_dnsmasq}}”

`

The two variables are true and false respectively, but the expression evaluates to true?

`
TASK: [consul | debug var=_consul_install_agent] ******************************
ok: [10.0.196.112] => {
“var”: {
“_consul_install_agent”: “False”
}
}

TASK: [consul | debug var=consul_use_dnsmasq] *********************************
ok: [10.0.196.112] => {
“var”: {
“consul_use_dnsmasq”: “True”
}
}

TASK: [consul | debug msg=“{{_consul_install_agent and consul_use_dnsmasq}}”] ***
ok: [10.0.196.112] => {
“msg”: “True”
}

`

But if the expression is

`

  • debug: msg=“{{_consul_install_agent == true and consul_use_dnsmasq == true}}”
    `

Then it evals to false.

Is this expected with jinja? Without the ‘and’ the ‘== true’ seems not necessary.

There’s a high likelihood that their type is actually ‘string’ instead of boolean, try

  • debug: msg=“{{ (_consul_install_agent | bool) and (consult_use_dnsmasq | bool) }}”

Indeed. The values were “== True” not “== True”. Thanks!