You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is precisely #16116. But since it was closed and I can't reopen it, I have to open a new one. The fix in that issue fixes order only for vars, while the issue itself was about host definitions as well.
So jump to the issue itself:
When using multiple inventory files with nested groups, any inventory file that contains children referenced in an earlier inventory file is not seen and causes an error.
The patch was suggested here: ShiwenMa#1 or here 47326e8, but it fixes nothing! It just removes the error message.
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t allCONFIG_FILE() = NoneDEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/peter/.ansible_vault_password_lfstrmEDITOR(env: EDITOR) = /usr/bin/vimPAGER(env: PAGER) = /usr/bin/less
OS / Environment
CentOS, Gentoo Linux and everywhere
Steps to Reproduce
The inventory contains the following inventory files
1.parentgoup
2.childgroup
Contents of inventory files are
$ cat inventory/1.parentgoup
The current behavior is expected. We specifically added this check because of the risk of a user mistyping the child group name. As such we currently raise an error if the child group has not yet been defined.
We are going to look into potentially adding a configuration toggle that can change the behavior to create the group when missing, however we do not plan to change default behavior.
I should note that due to how the YAML inventory works, listing a child group actually creates it due to the structure. So it's not necessarily 1:1.
sivel
added
P3
Priority 3 - Approved, No Time Limitation
and removed
needs_triage
Needs a first human triage before being processed.
labels
Nov 7, 2023
Summary
This is precisely #16116. But since it was closed and I can't reopen it, I have to open a new one. The fix in that issue fixes order only for vars, while the issue itself was about host definitions as well.
So jump to the issue itself:
When using multiple inventory files with nested groups, any inventory file that contains children referenced in an earlier inventory file is not seen and causes an error.
The patch was suggested here: ShiwenMa#1 or here 47326e8, but it fixes nothing! It just removes the error message.
This is a bug report about documented behavior: https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html#managing-inventory-load-order, so probably this is a feature request.
Also, if I use multiple YAML inventory files, my tests show that the order is insignificant, and everything works as expected.
Issue Type
Bug Report
Component Name
inventory
Ansible Version
Configuration
OS / Environment
CentOS, Gentoo Linux and everywhere
Steps to Reproduce
The inventory contains the following inventory files
1.parentgoup
2.childgroup
Contents of inventory files are
$ cat inventory/1.parentgoup
[testgroup:children] childgroup
$ cat inventory/2.childgroup
[childgroup] child
Command is
$
ansible-playbook playbooks/common.yml --limit 'testgroup' --list-hosts
Expected Results
playbook: playbooks/common.yml
Actual Results
ERROR! /etc/ansible/inventory/1.parentgoup:2: Section [testgroup:children] includes undefined group: childgroup
The text was updated successfully, but these errors were encountered: