Allow globbing in creates= and removes= directives

Fixes 1904
This commit is contained in:
Federico G. Schwindt 2014-12-14 22:53:21 +00:00
parent b0c94cd6f6
commit 3fca5e5876

View file

@ -20,6 +20,7 @@
import sys import sys
import datetime import datetime
import glob
import traceback import traceback
import re import re
import shlex import shlex
@ -161,7 +162,7 @@ def main():
# and the filename already exists. This allows idempotence # and the filename already exists. This allows idempotence
# of command executions. # of command executions.
v = os.path.expanduser(creates) v = os.path.expanduser(creates)
if os.path.exists(v): if glob.glob(v):
module.exit_json( module.exit_json(
cmd=args, cmd=args,
stdout="skipped, since %s exists" % v, stdout="skipped, since %s exists" % v,
@ -175,7 +176,7 @@ def main():
# and the filename does not exist. This allows idempotence # and the filename does not exist. This allows idempotence
# of command executions. # of command executions.
v = os.path.expanduser(removes) v = os.path.expanduser(removes)
if not os.path.exists(v): if not glob.glob(v):
module.exit_json( module.exit_json(
cmd=args, cmd=args,
stdout="skipped, since %s does not exist" % v, stdout="skipped, since %s does not exist" % v,