include_vars - fix stack trace when run ad-hoc with dirs parameter (#66581)
Add integration test There are a number of other parameters that result in stack traces as well when this module is used ad-hoc. I'm not sure if we're interested in fixing them all since this module isn't meant to be run ad-hoc.
This commit is contained in:
parent
3f16752ed2
commit
cc2376b782
5 changed files with 15 additions and 4 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- include_vars - fix stack trace when passing ``dirs`` in an ad-hoc command (https://github.com/ansible/ansible/issues/62633)
|
|
@ -158,10 +158,11 @@ class ActionModule(ActionBase):
|
|||
)
|
||||
self.source_dir = path_to_use
|
||||
else:
|
||||
current_dir = (
|
||||
"/".join(self._task._ds._data_source.split('/')[:-1])
|
||||
)
|
||||
self.source_dir = path.join(current_dir, self.source_dir)
|
||||
if hasattr(self._task._ds, '_data_source'):
|
||||
current_dir = (
|
||||
"/".join(self._task._ds._data_source.split('/')[:-1])
|
||||
)
|
||||
self.source_dir = path.join(current_dir, self.source_dir)
|
||||
|
||||
def _traverse_dir_depth(self):
|
||||
""" Recursively iterate over a directory and sort the files in
|
||||
|
|
1
test/integration/targets/include_vars-ad-hoc/aliases
Normal file
1
test/integration/targets/include_vars-ad-hoc/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
shippable/posix/group2
|
1
test/integration/targets/include_vars-ad-hoc/dir/inc.yml
Normal file
1
test/integration/targets/include_vars-ad-hoc/dir/inc.yml
Normal file
|
@ -0,0 +1 @@
|
|||
porter: cable
|
6
test/integration/targets/include_vars-ad-hoc/runme.sh
Executable file
6
test/integration/targets/include_vars-ad-hoc/runme.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible testhost -i ../../inventory -m include_vars -a 'dir/inc.yml' "$@"
|
||||
ansible testhost -i ../../inventory -m include_vars -a 'dir=dir' "$@"
|
Loading…
Reference in a new issue