We’re setting up a new project and have come across a surprising failure.
Warning: : Failed to parse inventory with ‘auto’ plugin: Error evaluating filter condition ‘True’ for host [redacted]: The value ‘{% if True %} True {% else %} False {% endif %}’ is not a valid boolean. Valid booleans include: ‘n’, ‘on’, 1, ‘false’, 0, ‘no’, ‘true’, ‘0’, ‘off’, ‘t’, ‘yes’, ‘1’, ‘y’, ‘f’
This seems to indicate to me that the expression in the plugin is being treated a string literal and not executed to return the True value expected.
I note that there’s some conditional logic which might play a part
from ansible.template import trust_as_template
except ImportError:
trust_as_template = None
...
conditional = "{{% if {0} %}}true{{% else %}}false{{% endif %}}".format(condition)
if trust_as_template:
conditional = trust_as_template(conditional)
try:
if boolean(self.templar.template(conditional)):
return True
except Exception as e:
if boolean(self.get_option('fail_on_template_errors')):
raise AnsibleParserError("Error evaluating filter condition '{0}' for host {1}: {2}".format(condition, inventory_hostname, to_native(e)))
So I’m wondering if trust_as_template
is failing to import silently, resulting in this failure? I don’t know what self.templar.template
is so lose the track here unfortunately.
Our inventory file is simple
development_azure_rm.yml
plugin: azure.azcollection.azure_rm
include_vm_resource_groups:
- [redacted]
auth_source: env
strict: yes
ansible_user: [redacted]
executed by ansible-playbook -i deploy/inventory/development_azure_rm.yml deploy/deploy.yml --limit="all"
I’d appreciate any insight.