j-oss2023
(Jad Seifeddine)
February 13, 2024, 1:10pm
1
I will start by stating that I already have an issue with GitHub, just adding here for more exposure and hopefully a solution…
opened 01:51AM - 13 Feb 24 UTC
type:bug
needs_triage
community
### Please confirm the following
- [X] I agree to follow this project's [code o… f conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
- [X] I am **NOT** reporting a (potential) security vulnerability. (These should be emailed to `security@ansible.com` instead.)
### Bug Summary
_No response_
### AWX version
Ansible AWX 23.5.2
### Select the relevant components
- [ ] UI
- [ ] UI (tech preview)
- [ ] API
- [ ] Docs
- [ ] Collection
- [ ] CLI
- [X] Other
### Installation method
docker development environment
### Modifications
no
### Ansible version
2.15.9
### Operating system
Ubuntu
### Web browser
_No response_
### Steps to reproduce
Ansible AWX - constructed inventory doesn't get the extra_vars / survey variables passed to it...
Create "constructed inventory"
![Screenshot 2024-02-13 at 12 32 42 pm](https://github.com/ansible/awx/assets/144011572/9e0aad4c-863a-4fad-941c-c05c40214fc6)
Set source vars for constructed inventory:
![Screenshot 2024-02-13 at 12 44 04 pm](https://github.com/ansible/awx/assets/144011572/973af630-a704-4d38-9d28-8f9edd821672)
Run Job / Workflow Job (tested both) - with extra_vars or survey vars:
![Screenshot 2024-02-13 at 12 47 15 pm](https://github.com/ansible/awx/assets/144011572/87739a67-ad29-48bc-866f-6a3eb18a79ed)
[WARNING]: * Failed to parse /runner/inventory/constructed.yml with auto
plugin: failed to parse /runner/inventory/constructed.yml: Could not set
play_customer for host HOST123: 'play_customer' is undefined. 'play_customer' is undefined
. Could not set play_customer for host HOST234: 'play_customer' is undefined.
'play_customer' is undefined
On Ansible CLI (outside AWX) - it works perfectly.
`ansible-playbook -i ./dynamic-mysql.yml -i ./constructed.yml playbooks/setup.yml -e "play_customer='Ferrari'" -l target`
### Expected results
play_customer variable being interpolated in constructed inventory
### Actual results
[WARNING]: * Failed to parse /runner/inventory/constructed.yml with auto
plugin: failed to parse /runner/inventory/constructed.yml: Could not set
play_customer for host HOST123: 'play_customer' is undefined. 'play_customer' is undefined
. Could not set play_customer for host HOST234: 'play_customer' is undefined.
'play_customer' is undefined
### Additional information
I've done lot of testing and confirmed that the 'Control Plane' execution environment that runs the inventory source job for the constructed inventory, does not have the extra vars
All the other jobs in the workflow - do have the extra vars
Installation method
docker development environment
Modifications
no
Ansible version
2.15.9
Operating system
Ubuntu
Web browser
No response
Steps to reproduce
Ansible AWX - constructed inventory doesn’t get the extra_vars / survey variables passed to it…
Create “constructed inventory”
Set source vars for constructed inventory:
Run Job / Workflow Job (tested both) - with extra_vars or survey vars:
[WARNING]: * Failed to parse /runner/inventory/constructed.yml with auto
plugin: failed to parse /runner/inventory/constructed.yml: Could not set
play_customer for host HOST123: ‘play_customer’ is undefined. ‘play_customer’ is undefined
. Could not set play_customer for host HOST234: ‘play_customer’ is undefined.
‘play_customer’ is undefined
On Ansible CLI (outside AWX) - it works perfectly.
ansible-playbook -i ./dynamic-mysql.yml -i ./constructed.yml playbooks/setup.yml -e "play_customer='Ferrari'" -l target
Expected results
play_customer variable being interpolated in constructed inventory
Actual results
[WARNING]: * Failed to parse /runner/inventory/constructed.yml with auto
plugin: failed to parse /runner/inventory/constructed.yml: Could not set
play_customer for host HOST123: ‘play_customer’ is undefined. ‘play_customer’ is undefined
. Could not set play_customer for host HOST234: ‘play_customer’ is undefined.
‘play_customer’ is undefined
Additional information
I’ve done lot of testing and confirmed that the ‘Control Plane’ execution environment that runs the inventory source job for the constructed inventory, does not have the extra vars
All the other jobs in the workflow - do have the extra vars
Please also see:
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/constructed_inventory.html#parameter-use_extra_vars
Anyone got any ideas ??
The invocation of the constructed inventory sync job is not being passed the extra vars
thank you all in advance
aj2s
(AJ)
September 17, 2024, 8:32pm
2
Hey I just discovered today that “Source vars” in AWX are passed to inventory sources via the environment. I was tearing my hair out with the same issue as you
awx/docs/inventory/scm_inventory.md at devel · ansible/awx · GitHub
So this means that your source vars would have to be the “environment variable” variant of it, which “compose” doesn’t have, but e.g. use_extra_vars: true
would become ANSIBLE_INVENTORY_USE_EXTRA_VARS: true
most likely…