Permalink
Browse files

Merge pull request #1000 from mavimo/patch-1

Add support to removes control param
  • Loading branch information...
2 parents 7ef3e7d + 2dd430d commit 4280e00d5698e71d59b420db5299636bb9794973 @mpdehaan mpdehaan committed Sep 7, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 library/command
View
@@ -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)

0 comments on commit 4280e00

Please sign in to comment.