fix collection adjacent loading with --playbook-dir (#56194)
* added inventory adjacent test
This commit is contained in:
parent
4f89c1d508
commit
69b2d7e0f3
3 changed files with 11 additions and 3 deletions
2
changelogs/fragments/playbookdir_coll_adj_fix.yml
Normal file
2
changelogs/fragments/playbookdir_coll_adj_fix.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- Add missing directory provided via ``--playbook-dir`` to adjacent collection loading
|
|
@ -15,20 +15,21 @@ import sys
|
||||||
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
from ansible.cli.arguments import option_helpers as opt_help
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible import context
|
from ansible import context
|
||||||
from ansible.cli.arguments import option_helpers as opt_help
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.inventory.manager import InventoryManager
|
from ansible.inventory.manager import InventoryManager
|
||||||
from ansible.module_utils.six import with_metaclass, string_types
|
from ansible.module_utils.six import with_metaclass, string_types
|
||||||
from ansible.module_utils._text import to_bytes, to_text
|
from ansible.module_utils._text import to_bytes, to_text
|
||||||
from ansible.parsing.dataloader import DataLoader
|
from ansible.parsing.dataloader import DataLoader
|
||||||
|
from ansible.parsing.vault import PromptVaultSecret, get_file_vault_secret
|
||||||
|
from ansible.plugins.loader import add_all_plugin_dirs
|
||||||
from ansible.release import __version__
|
from ansible.release import __version__
|
||||||
|
from ansible.utils.collection_loader import set_collection_playbook_paths
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
from ansible.utils.path import unfrackpath
|
from ansible.utils.path import unfrackpath
|
||||||
from ansible.vars.manager import VariableManager
|
from ansible.vars.manager import VariableManager
|
||||||
from ansible.parsing.vault import PromptVaultSecret, get_file_vault_secret
|
|
||||||
from ansible.plugins.loader import add_all_plugin_dirs
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import argcomplete
|
import argcomplete
|
||||||
|
@ -433,6 +434,7 @@ class CLI(with_metaclass(ABCMeta, object)):
|
||||||
if basedir:
|
if basedir:
|
||||||
loader.set_basedir(basedir)
|
loader.set_basedir(basedir)
|
||||||
add_all_plugin_dirs(basedir)
|
add_all_plugin_dirs(basedir)
|
||||||
|
set_collection_playbook_paths(basedir)
|
||||||
|
|
||||||
vault_ids = list(options['vault_ids'])
|
vault_ids = list(options['vault_ids'])
|
||||||
default_vault_ids = C.DEFAULT_VAULT_IDENTITY_LIST
|
default_vault_ids = C.DEFAULT_VAULT_IDENTITY_LIST
|
||||||
|
|
|
@ -32,3 +32,7 @@ fi
|
||||||
|
|
||||||
# run test playbook
|
# run test playbook
|
||||||
ansible-playbook -i "${INVENTORY_PATH}" -i ./a.statichost.yml -v "${TEST_PLAYBOOK}"
|
ansible-playbook -i "${INVENTORY_PATH}" -i ./a.statichost.yml -v "${TEST_PLAYBOOK}"
|
||||||
|
|
||||||
|
# test adjacent with --playbook-dir
|
||||||
|
export ANSIBLE_COLLECTIONS_PATHS=''
|
||||||
|
ANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=1 ansible-inventory -i a.statichost.yml --list --export --playbook-dir=. -v "$@"
|
||||||
|
|
Loading…
Reference in a new issue