# how to import variables from inventories/my-project/group\_wars in the inventory, at the source of which the script is specified?

**URL:** <https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 21, 2023, 9:23am UTC](https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137 "2023-06-21T09:23:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![user13](https://avatars.discourse-cdn.com/v4/letter/u/a88e57/32.png) [@user13](https://forum.ansible.com/u/user13)\
**Post date:** [June 21, 2023, 9:23am UTC](https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137/1 "2023-06-21T09:23:00Z")

</div>

hi everybody

I can’t solve my problem for several days. maybe someone had a similar situation.

I have an inventory in awx. in this inventory, I have a script written in python as a source. this script is hosted in gitlab. variables are also used in this script. I have successfully added a yaml file with my variables that are necessary for the script to work to the **inventories/my-project/group\_vars/** directory. these permutations have been successfully pulled up from gitlab and are located in inventory variables ( **the Variables** field). but how do I make sure that these same variables are still displayed in the source variables ( **Source variables** field)?

 ![Снимок веб-страницы_21-6-2023_11591_awx.apps.citydrive-infra.prod.citydrive.tech.jpeg](https://us1.discourse-cdn.com/ansible/original/2X/a/a58e7d9d50bb3aa38f92ba5dd5ac38ca51963d1f.jpeg)  
 ![Снимок веб-страницы_21-6-2023_12032_awx.apps.citydrive-infra.prod.citydrive.tech.jpeg](https://us1.discourse-cdn.com/ansible/original/2X/c/c579982094f06efc51405f726075b1438c9d0a8e.jpeg)  
 ![Снимок веб-страницы_21-6-2023_1210_awx.apps.citydrive-infra.prod.citydrive.tech.jpeg](https://us1.discourse-cdn.com/ansible/original/2X/b/b140b4bd6fe43cab1995856f652fd3e50c8345bc.jpeg)  
 ![Снимок веб-страницы_21-6-2023_12347_awx.apps.citydrive-infra.prod.citydrive.tech.jpeg](https://us1.discourse-cdn.com/ansible/original/2X/5/57d60f2b167c708b84f590cc4c9a0db7747ea07e.jpeg)

I also tried this way, for example, to access variables from a script, but an error occurs  
**BRANCH\_NAME = os.environ[‘branch\_name’]**

that is, I need to understand how to make sure that automatically variables from gitlab are transferred to **Source variables** or how to correctly access variables from the **Variables** inventory from the script.

awx version 21.7.

thanks!

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 23, 2023, 5:41pm UTC](https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137/2 "2023-06-23T17:41:08Z")

</div>

Hi,

Source variables are those that are used by a plugin to configure for syncing inventories. They are not a reflection of variables from individual hosts/groups/inventories:

[https://docs.ansible.com/automation-controller/4.2.2/html/userguide/inventories.html#amazon-web-services-ec2](https://docs.ansible.com/automation-controller/4.2.2/html/userguide/inventories.html#amazon-web-services-ec2)

If you use the above link as a reference, you can see that source variables are used by the plugin/script and not populated from the inventory.

I hope this helps.

Thanks,

AWX Team

---

<div class="post-metadata">

**Author:** ![user13](https://avatars.discourse-cdn.com/v4/letter/u/a88e57/32.png) [@user13](https://forum.ansible.com/u/user13)\
**Post date:** [June 26, 2023, 5:46am UTC](https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137/3 "2023-06-26T05:46:03Z")

</div>

I am using a python script as a source for dynamic inventory

 ![Снимок веб-страницы_26-6-2023_8445_awx.apps.citydrive-infra.prod.citydrive.tech.jpeg](https://us1.discourse-cdn.com/ansible/original/2X/2/2e0211b9c1802c8c5fd55d68c7817077a1b7f1bb.jpeg)

пятница, 23 июня 2023 г. в 20:41:08 UTC+3, AWX Project:

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 28, 2023, 6:43pm UTC](https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137/4 "2023-06-28T18:43:25Z")

</div>

If your script runs successfully, you should see the variables populated under “hosts” or “inventory” page. You WON"T see them populated on the screenshot you pasted above. Do you see the variables under hosts or inventory?

AWX Team

---

<div class="post-metadata">

**Author:** ![user13](https://avatars.discourse-cdn.com/v4/letter/u/a88e57/32.png) [@user13](https://forum.ansible.com/u/user13)\
**Post date:** [June 29, 2023, 6:44am UTC](https://forum.ansible.com/t/how-to-import-variables-from-inventories-my-project-group-wars-in-the-inventory-at-the-source-of-which-the-script-is-specified/38137/5 "2023-06-29T06:44:46Z")

</div>

You see, in order for the script to run successfully, I need to pass variables to the python script that are located in the gitlab **inventory/my-project/group\_vars/all/my-variables.yml** repository. My variables are successfully transferred from the gitlab repository to the awx inventory (the second screenshot from my first message), but are not transferred to the inventory source (the fourth screenshot from my first message). How do I make variables from the gitlab inventory **repository/my-project/group\_vars/all/my-variables.yml** to the inventory source?

at the moment I am getting variables to successfully run a python script like this. but this is wrong. it is necessary that they are pulled up automatically from **inventory/my-project/group\_vars/all/my-variables.yml**

 ![Снимок веб-страницы_29-6-2023_9425.jpeg](https://us1.discourse-cdn.com/ansible/original/2X/a/a51db1e970e643eded928c2826e738485626605d.jpeg)

среда, 28 июня 2023 г. в 21:43:26 UTC+3, AWX Project:
