uri action plugin check_mode support update (#82484)

Also updated base action messages to be more specific
pull/82503/head
Brian Coca 4 months ago committed by GitHub
parent 6c2895fd88
commit 596c75c2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- uri action plugin now skipped during check mode (not supported) instead of even trying to execute the module, which already skipped, this does not really change the result, but returns much faster.

@ -115,11 +115,11 @@ class ActionBase(ABC):
del tmp
if self._task.async_val and not self._supports_async:
raise AnsibleActionFail('async is not supported for this task.')
raise AnsibleActionFail('This action (%s) does not support async.' % self._task.action)
elif self._task.check_mode and not self._supports_check_mode:
raise AnsibleActionSkip('check mode is not supported for this task.')
raise AnsibleActionSkip('This action (%s) does not support check mode.' % self._task.action)
elif self._task.async_val and self._task.check_mode:
raise AnsibleActionFail('check mode and async cannot be used on same task.')
raise AnsibleActionFail('"check mode" and "async" cannot be used on same task.')
# Error if invalid argument is passed
if self._VALID_ARGS:

@ -20,6 +20,7 @@ class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
self._supports_async = True
self._supports_check_mode = False
if task_vars is None:
task_vars = dict()

@ -162,7 +162,7 @@
assert:
that:
- script_result3 is failed
- script_result3.msg == "async is not supported for this task."
- script_result3.msg == "This action (script) does not support async."
# check mode

@ -697,3 +697,14 @@
- name: Test unix socket
import_tasks: install-socat-and-test-unix-socket.yml
- name: ensure skip action
uri:
url: http://example.com
check_mode: True
register: uri_check
- name: check that we skipped at action
assert:
that:
- uri_check.msg == "This action (uri) does not support check mode."

Loading…
Cancel
Save