Upgrade callbacks further, now '.play', '.task', and so on are also available!
This commit is contained in:
parent
5b845510b3
commit
42b0e51223
2 changed files with 11 additions and 1 deletions
|
@ -69,7 +69,7 @@ Bugfixes and Misc Changes:
|
||||||
* 'magic' variable 'inventory_basedir' now gives path to inventory file
|
* 'magic' variable 'inventory_basedir' now gives path to inventory file
|
||||||
* 'magic' variable 'vars' works like 'hostvars' but gives global scope variables, useful for debugging in templates mostly
|
* 'magic' variable 'vars' works like 'hostvars' but gives global scope variables, useful for debugging in templates mostly
|
||||||
* conditionals can be used on plugins like add_host
|
* conditionals can be used on plugins like add_host
|
||||||
* all callbacks now have access to a ".runner" and ".playbook" object (.playbook is only set by ansible-playbook)
|
* developers: all callbacks now have access to a ".runner" and ".playbook", ".play", and ".task" object (use getattr, they may not always be set!)
|
||||||
|
|
||||||
Facts:
|
Facts:
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,10 @@ class PlayBook(object):
|
||||||
self.callbacks.on_start()
|
self.callbacks.on_start()
|
||||||
for (play_ds, play_basedir) in zip(self.playbook, self.play_basedirs):
|
for (play_ds, play_basedir) in zip(self.playbook, self.play_basedirs):
|
||||||
play = Play(self, play_ds, play_basedir)
|
play = Play(self, play_ds, play_basedir)
|
||||||
|
|
||||||
|
self.callbacks.play = play
|
||||||
|
self.runner_callbacks.play = play
|
||||||
|
|
||||||
matched_tags, unmatched_tags = play.compare_tags(self.only_tags)
|
matched_tags, unmatched_tags = play.compare_tags(self.only_tags)
|
||||||
matched_tags_all = matched_tags_all | matched_tags
|
matched_tags_all = matched_tags_all | matched_tags
|
||||||
unmatched_tags_all = unmatched_tags_all | unmatched_tags
|
unmatched_tags_all = unmatched_tags_all | unmatched_tags
|
||||||
|
@ -306,6 +310,9 @@ class PlayBook(object):
|
||||||
def _run_task(self, play, task, is_handler):
|
def _run_task(self, play, task, is_handler):
|
||||||
''' run a single task in the playbook and recursively run any subtasks. '''
|
''' run a single task in the playbook and recursively run any subtasks. '''
|
||||||
|
|
||||||
|
self.callbacks.task = task
|
||||||
|
self.runner_callbacks.task = task
|
||||||
|
|
||||||
self.callbacks.on_task_start(utils.template(play.basedir, task.name, task.module_vars, lookup_fatal=False), is_handler)
|
self.callbacks.on_task_start(utils.template(play.basedir, task.name, task.module_vars, lookup_fatal=False), is_handler)
|
||||||
if hasattr(self.callbacks, 'skip_task') and self.callbacks.skip_task:
|
if hasattr(self.callbacks, 'skip_task') and self.callbacks.skip_task:
|
||||||
return True
|
return True
|
||||||
|
@ -380,6 +387,9 @@ class PlayBook(object):
|
||||||
self.callbacks.on_setup()
|
self.callbacks.on_setup()
|
||||||
self.inventory.restrict_to(host_list)
|
self.inventory.restrict_to(host_list)
|
||||||
|
|
||||||
|
self.callbacks.task = None
|
||||||
|
self.runner_callbacks.task = None
|
||||||
|
|
||||||
# push any variables down to the system
|
# push any variables down to the system
|
||||||
setup_results = ansible.runner.Runner(
|
setup_results = ansible.runner.Runner(
|
||||||
pattern=play.hosts, module_name='setup', module_args={}, inventory=self.inventory,
|
pattern=play.hosts, module_name='setup', module_args={}, inventory=self.inventory,
|
||||||
|
|
Loading…
Reference in a new issue