Don't skip an inventory source just because it has a comma (#35002)
* Don't skip an inventory source just because it has a comma, make sure it's also doesn't exist as a path. Fixes #34931
* Add integration test for inventory path with commas
(cherry picked from commit 1ac04ba52e
)
This commit is contained in:
parent
71f6573bf5
commit
2924ad1bbf
6 changed files with 18 additions and 1 deletions
|
@ -285,7 +285,7 @@ class VariableManager:
|
|||
''' merges all entities by inventory source '''
|
||||
data = {}
|
||||
for inventory_dir in self._inventory._sources:
|
||||
if ',' in inventory_dir: # skip host lists
|
||||
if ',' in inventory_dir and not os.path.exists(inventory_dir): # skip host lists
|
||||
continue
|
||||
elif not os.path.isdir(inventory_dir): # always pass 'inventory directory'
|
||||
inventory_dir = os.path.dirname(inventory_dir)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
posix/ci/group3
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Ensure we can see group_vars from path with comma
|
||||
assert:
|
||||
that:
|
||||
- inventory_var_from_path_with_commas is defined
|
||||
- inventory_var_from_path_with_commas == 'here'
|
5
test/integration/targets/inventory_path_with_comma/runme.sh
Executable file
5
test/integration/targets/inventory_path_with_comma/runme.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ux
|
||||
|
||||
ansible-playbook -i this,path,has,commas/hosts playbook.yml -v "$@"
|
|
@ -0,0 +1 @@
|
|||
inventory_var_from_path_with_commas: 'here'
|
|
@ -0,0 +1 @@
|
|||
localhost ansible_connect=local
|
Loading…
Reference in a new issue