如何指定不同于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)
答案 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)