Commit 183330a9 by Michael DeHaan

Merge pull request #662 from tima/regex-cond-tasks

Importing re in runner for doing conditional tasks using pattern matching i.e. re.search(). Also conditionally outputting item when skipping.
parents cbea17e4 4b9b9a8a
......@@ -291,8 +291,11 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
else:
print >>sys.stderr, "err: [%s] => %s" % (host, err)
def on_skipped(self, host):
def on_skipped(self, host, item=None):
if item:
print "skipping: [%s] => (item=%s)" % (host, item)
else:
print "skipping: [%s]" % host
def on_no_hosts(self):
......
......@@ -31,6 +31,7 @@ import base64
import getpass
import codecs
import collections
import re
import ansible.constants as C
import ansible.inventory
......@@ -555,7 +556,7 @@ class Runner(object):
conditional = utils.template(self.conditional, inject)
if not eval(conditional):
result = utils.jsonify(dict(skipped=True))
self.callbacks.on_skipped(host)
self.callbacks.on_skipped(host, inject.get('item',None))
return ReturnData(host=host, result=result)
conn = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment