Load modules before creating ansible playbook

TaskQueueManager loads ansible modules from os-faults
and it should be initialized first. Otherwise, if we use
custom module as a first task, then Play class raises
an error.

Change-Id: I78d7c8441517f7b951e525b90f6512a21387b188
This commit is contained in:
Anton Studenov 2017-02-07 13:27:31 +03:00
parent 7eb1f4a038
commit c4dbe868e9
1 changed files with 13 additions and 14 deletions

View File

@ -155,29 +155,28 @@ class AnsibleRunner(object):
host_list=host_list)
variable_manager.set_inventory(inventory_inst)
storage = []
callback = MyCallback(storage)
tqm = task_queue_manager.TaskQueueManager(
inventory=inventory_inst,
variable_manager=variable_manager,
loader=loader,
options=self.options,
passwords=self.passwords,
stdout_callback=callback,
)
# create play
play_inst = play.Play().load(play_source,
variable_manager=variable_manager,
loader=loader)
storage = []
callback = MyCallback(storage)
# actually run it
tqm = None
try:
tqm = task_queue_manager.TaskQueueManager(
inventory=inventory_inst,
variable_manager=variable_manager,
loader=loader,
options=self.options,
passwords=self.passwords,
stdout_callback=callback,
)
tqm.run(play_inst)
finally:
if tqm is not None:
tqm.cleanup()
tqm.cleanup()
return storage