Merge "Allow find on the executor"

This commit is contained in:
Zuul 2020-09-30 23:50:13 +00:00 committed by Gerrit Code Review
commit 1237e28dd9
5 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
features:
- |
The ``find`` module is now allowed to run on the executor.

View File

@ -0,0 +1,5 @@
- hosts: localhost
tasks:
- name: Find in a bad location
find:
paths: '/tmp/'

View File

@ -0,0 +1,5 @@
- hosts: localhost
tasks:
- name: Find in a good location
find:
paths: '{{ zuul.executor.work_root }}'

View File

@ -2958,6 +2958,8 @@ class FunctionalAnsibleMixIn(object):
('file_local_bad', 'FAILURE'),
('fileglob_local_good', 'SUCCESS'),
('fileglob_local_bad', 'FAILURE'),
('find_local_good', 'SUCCESS'),
('find_local_bad', 'FAILURE'),
('zuul_return', 'SUCCESS'),
('password_create_good', 'SUCCESS'),
('password_null_good', 'SUCCESS'),

View File

@ -103,3 +103,15 @@ class ActionModule(normal.ActionModule):
path = self._task.args.get(arg)
if path:
paths._fail_if_unsafe(path)
def handle_find(self):
'''Allow find module on localhost if it doesn't traverse unsafe files.
The :ansible:module:`find` can be used from the executor to
gather a list of files.
'''
find_paths = self._task.args.get('paths')
if not isinstance(find_paths, list):
find_paths = (find_paths,)
for path in find_paths:
paths._fail_if_unsafe(path)