Constructed Inventory does not get passed extra vars - AWX

I will start by stating that I already have an issue with GitHub, just adding here for more exposure and hopefully a solution…

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:

Screenshot 2024-02-13 at 12 44 04 pm

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 :slight_smile:

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…