# Constructed Inventory does not get passed extra vars - AWX

**URL:** <https://forum.ansible.com/t/constructed-inventory-does-not-get-passed-extra-vars-awx/3848>\
**Category:** Get Help\
**Tags:** ubuntu, awx, ee\
**Created:** [February 13, 2024, 1:10pm UTC](https://forum.ansible.com/t/constructed-inventory-does-not-get-passed-extra-vars-awx/3848 "2024-02-13T13:10:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![j-oss2023](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/j-oss2023/32/2260_2.png) [@j-oss2023](https://forum.ansible.com/u/j-oss2023)\
**Post date:** [February 13, 2024, 1:10pm UTC](https://forum.ansible.com/t/constructed-inventory-does-not-get-passed-extra-vars-awx/3848/1 "2024-02-13T13:10:15Z")

</div>

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

> <https://github.com/ansible/awx/issues/14868>
>
> \### 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”

 ![Screenshot 2024-02-13 at 12 32 42 pm](https://us1.discourse-cdn.com/ansible/original/2X/8/8ae9d3be805e09b16db81cb301310caf932b47de.png)

Set source vars for constructed inventory:

 ![Screenshot 2024-02-13 at 12 44 04 pm](https://us1.discourse-cdn.com/ansible/original/2X/f/f0dae61b7535154504c63fe7b9d52fa99c45a5f0.png)

Run Job / Workflow Job (tested both) - with extra\_vars or survey vars:

 ![Screenshot 2024-02-13 at 12 47 15 pm](https://us1.discourse-cdn.com/ansible/original/2X/8/8de3cc8bc97e5e1110adfbb0bd8fd2143e368180.png)

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

> **[ansible.builtin.constructed inventory – Uses Jinja2 to construct vars and...](https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/constructed_inventory.html)**

Anyone got any ideas ??  
The invocation of the constructed inventory sync job is not being passed the extra vars

thank you all in advance 🙂

---

<div class="post-metadata">

**Author:** ![aj2s](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@aj2s](https://forum.ansible.com/u/aj2s)\
**Post date:** [September 17, 2024, 8:32pm UTC](https://forum.ansible.com/t/constructed-inventory-does-not-get-passed-extra-vars-awx/3848/2 "2024-09-17T20:32:06Z")

</div>

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](https://github.com/ansible/awx/blob/devel/docs/inventory/scm_inventory.md)

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…
