本文整理匯總了Python中ansible.playbook.play_context.PlayContext.connection方法的典型用法代碼示例。如果您正苦於以下問題:Python PlayContext.connection方法的具體用法?Python PlayContext.connection怎麽用?Python PlayContext.connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ansible.playbook.play_context.PlayContext
的用法示例。
在下文中一共展示了PlayContext.connection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: debug
# 需要導入模塊: from ansible.playbook.play_context import PlayContext [as 別名]
# 或者: from ansible.playbook.play_context.PlayContext import connection [as 別名]
debug("starting")
cur_worker = 0
pending_results = 0
var_manager = VariableManager()
debug("loading inventory")
inventory = Inventory(host_list='/tmp/med_inventory', loader=loader, variable_manager=var_manager)
hosts = inventory.get_hosts()[:]
debug("done loading inventory")
play_context = PlayContext()
play_context.connection = 'local'
for i in range(NUM_TASKS):
#for j in range(NUM_HOSTS):
for h in hosts:
debug("queuing %s %d" % (h, i))
#h = Host(name="host%06d" % j)
t = Task().load(dict(name="task %d" % (i,), debug="msg='hello from %s, %d'" % (h,i)))
#t = Task().load(dict(name="task %d" % (i,), ping=""))
#task_vars = var_manager.get_vars(loader=loader, host=h, task=t)
task_vars = dict()
new_t = t.copy()
new_t.post_validate(task_vars)
send_data((h, t, task_vars, play_context))
debug("done queuing %s %d" % (h, i))
_process_pending_results()