summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2016-03-24 19:52:06 -0700
committerBrian Coca <bcoca@ansible.com>2016-03-24 19:52:06 -0700
commit1c4cfee415b115a1e281c8ec078635599049c2eb (patch)
tree7fc234f1152ddb34ec9773c412374e0bf23cca57
parent1a48d10bffe7eb16a178e2955fedbb4ec9018ff8 (diff)
parent1ebc2fda713447d8d59c1334a4f4e48961241daa (diff)
downloadansible-1c4cfee415b115a1e281c8ec078635599049c2eb.tar.gz
Merge pull request #15046 from bcoca/script_raw
removes python requirement to script
-rw-r--r--lib/ansible/plugins/action/script.py15
-rw-r--r--test/integration/roles/test_script/tasks/main.yml2
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/ansible/plugins/action/script.py b/lib/ansible/plugins/action/script.py
index a0d6640548..c16fc227c4 100644
--- a/lib/ansible/plugins/action/script.py
+++ b/lib/ansible/plugins/action/script.py
@@ -26,6 +26,13 @@ from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
TRANSFERS_FILES = True
+ def _get_remote_raw_stat(self, path):
+ cmd = ['test', '-e', path]
+ result = self._low_level_execute_command(cmd=' '.join(cmd), sudoable=True)
+ if result['rc'] == 0:
+ return True
+ return False
+
def run(self, tmp=None, task_vars=None):
''' handler for file transfer operations '''
if task_vars is None:
@@ -47,9 +54,7 @@ class ActionModule(ActionBase):
# do not run the command if the line contains creates=filename
# and the filename already exists. This allows idempotence
# of command executions.
- res = self._execute_module(module_name='stat', module_args=dict(path=creates), task_vars=task_vars, tmp=tmp, persist_files=True)
- stat = res.get('stat', None)
- if stat and stat.get('exists', False):
+ if self._get_remote_raw_stat(creates):
return dict(skipped=True, msg=("skipped, since %s exists" % creates))
removes = self._task.args.get('removes')
@@ -57,9 +62,7 @@ class ActionModule(ActionBase):
# do not run the command if the line contains removes=filename
# and the filename does not exist. This allows idempotence
# of command executions.
- res = self._execute_module(module_name='stat', module_args=dict(path=removes), task_vars=task_vars, tmp=tmp, persist_files=True)
- stat = res.get('stat', None)
- if stat and not stat.get('exists', False):
+ if self._get_remote_raw_stat(removes):
return dict(skipped=True, msg=("skipped, since %s does not exist" % removes))
# the script name is the first item in the raw params, so we split it
diff --git a/test/integration/roles/test_script/tasks/main.yml b/test/integration/roles/test_script/tasks/main.yml
index ffbe40d600..75a75d9d69 100644
--- a/test/integration/roles/test_script/tasks/main.yml
+++ b/test/integration/roles/test_script/tasks/main.yml
@@ -66,4 +66,4 @@
- name: assert that the file was removed by the script
assert:
that:
- - "script_result1.changed != True"
+ - "script_result1|changed"