Ansible:ssh_host 包含 IP 范围

kiv*_*ant 1 ansible ansible-playbook

我的主机没有稳定的主机名,但具有预定义的 ip 范围。如何设置 ansible 清单文件的 IP 范围?我正在尝试设置这样的东西:

    test.ini:
    [database]
    db ansible_ssh_host=1.1.1.[20:25] ansible_ssh_port=22
    [lemp]
    lemp ansible_ssh_host=1.1.1.[10:15] ansible_ssh_port=22
Run Code Online (Sandbox Code Playgroud)

现在我在运行 ansible-playbook -i test.ini 后收到此错误:

    fatal: [db] => SSH Error: ssh: Could not resolve hostname 1.1.1.[20:25]: Name or service not known
Run Code Online (Sandbox Code Playgroud)

谢谢你。

kiv*_*ant 5

我为我的问题找到了这个可行的解决方案:

    test.ini:
    # I removed hostname section and ansible_ssh_host=
    10.0.3.[20:25] ansible_ssh_port=22
Run Code Online (Sandbox Code Playgroud)