-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Host_vars and group_vars from different sources are not merged together in one inventory #9762
Comments
@AlanCoding any thoughts on this one? |
Hi @ryanpetrello @AlanCoding, ENVIRONMENT
Unforetunatly the variables are still not combined in the hosts/groups. I used the same configuration as mentioned above. There should be an additional variable "hostvar2": "This is a host var for a virtual machine" Here is the variable data from the host vm01.testing.local (via the API): HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
X-API-Node: awx-b5f6cf4d4-rt6qk
X-API-Product-Name: AWX
X-API-Product-Version: 19.0.0
X-API-Time: 0.017s
{
"ansible_host": "vm01.testing.local",
"ansible_uuid": "5016bbd9-8ba0-c9ce-4549-5dd6f6e545ed",
"config": {
"instanceUuid": "5016bbd9-8ba0-c9ce-4549-5dd6f6e545ed",
"name": "vm01.testing.local"
},
"config.instanceUuid": "5016bbd9-8ba0-c9ce-4549-5dd6f6e545ed",
"config.name": "vm01.testing.local",
"configIssue": [],
"configStatus": "green",
"configissue": [],
"configstatus": "green",
"name": "vm01.testing.local",
"runtime": {
"connectionState": "connected"
},
"runtime.connectionState": "connected"
} |
You say that your second source that got updated was your file source.
But you checked It doesn't matter if the first source has set to overwrite vars or not. It's the 2nd import that will be doing the overwriting. Can you check to make extra sure that the SCM-based inventory source which imports from a file has "overwrite variables" set to False? We have a weird behavior where SCM inventory sources will default this field to True. Maybe it shouldn't be that way. This is my best guess as to the thing that's messing you up. I created a test case here: That combines variables (does not overwrite) when both files are added as SCM inventory sources. But it only does this if I specifically set overwrite variables to False for them. |
I cannot reproduce, so closing for now. If you have any new information I'll adjust and re-run my test case. |
ISSUE TYPE
SUMMARY
I am trying to merge multiple inventory sources together in one inventory. The sync of hosts and groups works fine but variables are not merged.
The host vm01.testing.local should have an additional variable „hostvar2“ which is coming from the project. The variable is not merged to the host, as you can see in the variables I get in the AWX-web-ui:
Here are my vCenter source variables:
Here is the project (git repo) layout:
ENVIRONMENT
STEPS TO REPRODUCE
Create an inventory with two sources:
- First source syncs virtual machines from VMware vCenter (for source variables see summary above)
- Second source syncs hosts from a hosts file in a (Git) project (for repo setup see summary above)
- Project source also contains host_vars/group_vars for virtual machines and groups created by the first source
- Sync both sources
EXPECTED RESULTS
Host and group variables from the project source should be merged with hosts/groups created by vCenter source
ACTUAL RESULTS
Additional custom host_vars and group_vars from a project are not merged to hosts/groups created by vCenter source
It doesn’t matter if the project source has „overwrite variables“ enabled or not.
ADDITIONAL INFORMATION
I put the vCenter source variables in a file and ran the ansible-inventory command manually in the awx_task container:
If i now look at output.json, I get the exptected result (As you can see the variables for the testing group and vm01.testing.local are merged successfully to the hosts and groups created by vCenter import):
Any help is much appreciated
The text was updated successfully, but these errors were encountered: