fix shell/command/script tasks skipping in check mode (#76353)

* fix shell/command/script tasks skipping in check mode

* changelog
pull/76426/head
Sloane Hertel 3 years ago committed by GitHub
parent b50f16db91
commit de11a1ce78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- shell/command - only skip in check mode if the options `creates` and `removes` are both None.
- script - skip in check mode since the plugin cannot determine if a change will occur.

@ -373,7 +373,8 @@ def main():
# this is partial check_mode support, since we end up skipping if we get here
r['rc'] = 0
r['msg'] = "Command would have run if not in check mode"
r['skipped'] = True
if creates is None and removes is None:
r['skipped'] = True
r['changed'] = True

@ -119,7 +119,9 @@ class ActionModule(ActionBase):
script_cmd = ' '.join([env_string, target_command])
if self._play_context.check_mode:
raise _AnsibleActionDone()
# If the script doesn't return changed in the result, it defaults to True,
# but since the script may override 'changed', just skip instead of guessing.
raise AnsibleActionSkip('Check mode is not supported for this task.')
script_cmd = self._connection._shell.wrap_for_exec(script_cmd)

Loading…
Cancel
Save