mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
adding quiet option to assert (ansible#27124) (#52032)
* adding quiet option to assert (ansible#27124) * adding doc for quiet to assert.py * fixing PEP8 failure * improving example * improving docs * adding changelog fragment * adding . at end of descriptions * removing trailing blank line * adding integration test for assert * fixing CI complaints * disabling gather_facts in quiet.yml test * rerunning to capture skip * cleaning up python 2 vs 3 * following rebase * fixing CI complaints * fixing CI complaints * fixing CI complaints * fixing CI complaints * fixing CI complaints
This commit is contained in:
parent
0e9a79a589
commit
d2bdbadb03
9 changed files with 134 additions and 7 deletions
|
@ -21,13 +21,14 @@ from ansible.errors import AnsibleError
|
|||
from ansible.playbook.conditional import Conditional
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
''' Fail with custom message '''
|
||||
|
||||
TRANSFERS_FILES = False
|
||||
_VALID_ARGS = frozenset(('fail_msg', 'msg', 'success_msg', 'that'))
|
||||
_VALID_ARGS = frozenset(('fail_msg', 'msg', 'quiet', 'success_msg', 'that'))
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
if task_vars is None:
|
||||
|
@ -54,6 +55,8 @@ class ActionModule(ActionBase):
|
|||
elif not isinstance(success_msg, string_types):
|
||||
raise AnsibleError('Incorrect type for success_msg, expected string and got %s' % type(success_msg))
|
||||
|
||||
quiet = boolean(self._task.args.get('quiet', False), strict=False)
|
||||
|
||||
# make sure the 'that' items are a list
|
||||
thats = self._task.args['that']
|
||||
if not isinstance(thats, list):
|
||||
|
@ -65,7 +68,9 @@ class ActionModule(ActionBase):
|
|||
# by this point, and is not used again, so we don't care about mangling
|
||||
# that value now
|
||||
cond = Conditional(loader=self._loader)
|
||||
result['_ansible_verbose_always'] = True
|
||||
if not quiet:
|
||||
result['_ansible_verbose_always'] = True
|
||||
|
||||
for that in thats:
|
||||
cond.when = [that]
|
||||
test_result = cond.evaluate_conditional(templar=self._templar, all_vars=task_vars)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue