Ansible Python API连接不同的端口

时间:2017-09-07 20:06:12

标签: python ansible

如何指定不同于22的端口。 我尝试没有成功:

inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=[192.168.0.1:3300])

Options = namedtuple('Options',['remote_port'])    
options = Options(remote_port=3300)

1 个答案:

答案 0 :(得分:0)

我通过阅读源代码找到了:

 play_source = dict(
     name="Ansible Play",
     hosts=host_list,
     gather_facts='no',
     port=222,
     tasks=[dict(action=dict(module='command', args=dict(cmd='/usr/bin/uptime')))]
 )
 play = Play().load(play_source, variable_manager=variable_manager, loader=loader)