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

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)?




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!

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

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

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

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

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

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

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