[stable-2.9] include_vars - fix stack trace when run ad-hoc with dirs parameter (#66581) (#66910)

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.
(cherry picked from commit cc2376b782)

Co-authored-by: Sam Doran <sdoran@redhat.com>
pull/67297/head
Sam Doran 5 years ago committed by GitHub
parent aaadf71438
commit a2b5af86dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -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…
Cancel
Save