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:
Sam Doran 2020-01-28 11:50:34 -05:00 committed by ansibot
parent 3f16752ed2
commit cc2376b782
5 changed files with 15 additions and 4 deletions

View file

@ -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)

View file

@ -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

View file

@ -0,0 +1 @@
shippable/posix/group2

View file

@ -0,0 +1 @@
porter: cable

View 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' "$@"