While running a simple playbook (see below) to export the configuration using filetreee_create role the filetree_create/templates/current_inventory_sources.j2 complains about an undefined variable and fails.
When I remove the line 25-27 in the filetree_create/templates/current_inventory_sources.j2, then the export will be completed successfully. But it will skip the inventory credential information for sure.
{% if inventory_source.credential is defined %}
credential: "{{ inventory_source.summary_fields.credential.name }}"
{% endif %}
TASK [infra.controller_configuration.filetree_create : Add current inventory source to the inventory sources flat file] ***
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'credential'. 'dict object' has no attribute 'credential'. 'dict object' has no attribute 'credential'. 'dict object' has no attribute 'credential'\n\nThe error appears to be in '/home/gmadappa/collections/ansible_collections/infra/controller_configuration/roles/filetree_create/tasks/inventory_sources.yml': line 21, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: \"Add current inventory source to the inventory sources flat file\"\n ^ here\n"}
PLAY RECAP *************************************************************************************************
localhost : ok=20 changed=3 unreachable=0 failed=1 skipped=5 rescued=0 ignored=0
STEPS TO REPRODUCE
Create the playbook and use the execute as follow.
Summary
While running a simple playbook (see below) to export the configuration using
filetreee_create
role thefiletree_create/templates/current_inventory_sources.j2
complains about an undefined variable and fails.When I remove the line 25-27 in the
filetree_create/templates/current_inventory_sources.j2
, then the export will be completed successfully. But it will skip the inventory credential information for sure.Issue Type
Ansible, Collection, Controller details
OS / ENVIRONMENT
Desired Behavior
Export/save the configuration without any error.
Actual Behavior
Please give some details of what is actually happening. Include a [minimum complete verifiable example] with:
filetree_create/templates/current_inventory_sources.j2
STEPS TO REPRODUCE