Merge pull request #1000 from mavimo/patch-1

Add support to removes control param
This commit is contained in:
Michael DeHaan 2012-09-06 17:52:02 -07:00
commit 3df57c699e

15
command
View file

@ -114,6 +114,21 @@ class CommandModule(AnsibleModule):
rc=0
)
args = args.replace(x,'')
elif x.startswith("removes="):
# do not run the command if the line contains removes=filename
# and the filename do not exists. This allows idempotence
# of command executions.
(k,v) = x.split("=",1)
if not os.path.exists(v):
self.exit_json(
cmd=args,
stdout="skipped, since %s do not exists" % v,
skipped=True,
changed=False,
stderr=False,
rc=0
)
args = args.replace(x,'')
elif x.startswith("chdir="):
(k,v) = x.split("=", 1)
v = os.path.expanduser(v)