From 3fca5e587694989cf74808d49341b83b487a782b Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Sun, 14 Dec 2014 22:53:21 +0000 Subject: [PATCH 1/2] Allow globbing in creates= and removes= directives Fixes 1904 --- commands/command.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/command.py b/commands/command.py index c584d6feed8..bc286d6855d 100644 --- a/commands/command.py +++ b/commands/command.py @@ -20,6 +20,7 @@ import sys import datetime +import glob import traceback import re import shlex @@ -161,7 +162,7 @@ def main(): # and the filename already exists. This allows idempotence # of command executions. v = os.path.expanduser(creates) - if os.path.exists(v): + if glob.glob(v): module.exit_json( cmd=args, stdout="skipped, since %s exists" % v, @@ -175,7 +176,7 @@ def main(): # and the filename does not exist. This allows idempotence # of command executions. v = os.path.expanduser(removes) - if not os.path.exists(v): + if not glob.glob(v): module.exit_json( cmd=args, stdout="skipped, since %s does not exist" % v, From 9e381264ae599788f77a629ce3ffc7d24cf7c20a Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Wed, 7 Jan 2015 04:47:58 +0000 Subject: [PATCH 2/2] Document globbing support --- commands/command.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/command.py b/commands/command.py index bc286d6855d..f9d2b18c921 100644 --- a/commands/command.py +++ b/commands/command.py @@ -47,12 +47,12 @@ options: aliases: [] creates: description: - - a filename, when it already exists, this step will B(not) be run. + - a filename or glob pattern, when it already exists, this step will B(not) be run. required: no default: null removes: description: - - a filename, when it does not exist, this step will B(not) be run. + - a filename or glob pattern, when it does not exist, this step will B(not) be run. version_added: "0.8" required: no default: null