summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2022-04-13 13:07:45 -0400
committerGitHub <noreply@github.com>2022-04-13 12:07:45 -0500
commitdb69d93c1c6defe5590d539f1fe44670c250432b (patch)
tree1de87c0444a5c4e61f687e1cee412660091d881e /lib
parent374882e4df9b2e2e4c66c5701f2b604fc0167c4a (diff)
downloadansible-db69d93c1c6defe5590d539f1fe44670c250432b.tar.gz
[2.12] fix shell/command/script tasks skipping in check mode (#76353) (#77389)
* fix shell/command/script tasks skipping in check mode (#76353) * fix shell/command/script tasks skipping in check mode * changelog (cherry picked from commit de11a1ce781482e280c55d99ce571a130ae474bc) * Add portion of tests from #76429 for skipping/not skipping shell/command tasks in check mode
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/command.py3
-rw-r--r--lib/ansible/plugins/action/script.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/ansible/modules/command.py b/lib/ansible/modules/command.py
index cb29b10728..1e0ff2f615 100644
--- a/lib/ansible/modules/command.py
+++ b/lib/ansible/modules/command.py
@@ -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
diff --git a/lib/ansible/plugins/action/script.py b/lib/ansible/plugins/action/script.py
index ad73be88f4..ff7f2f3a76 100644
--- a/lib/ansible/plugins/action/script.py
+++ b/lib/ansible/plugins/action/script.py
@@ -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)