我想用python ansible api操作服务器,但是想要操作的服务器并不确定,请问怎么指定hosts。代码类似这样
play_source = dict(
name = "Ansible Play",
hosts = hosts,
gather_facts = 'no',
tasks = [
dict(action=dict(module=module))
]
)
play = Play().load(play_source, variable_manager=variable_manager, loader=loader)
如果hosts是不确定的话,可以用动态inventory来实现。
而且hosts应该是支持正则匹配的吧~