ansible - 具有 IP 范围的主机

标签 ansible

我的主机没有稳定的主机名,但有预定义的 IP 范围。
如何为 Ansible list 文件设置 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

现在我在运行 ansible-playbook -i test.ini 后得到这个错误:

fatal: [db] => SSH Error: ssh: Could not resolve hostname 1.1.1.[20:25]: Name or service not known

最佳答案

我为我的问题找到了这个有效的解决方案:

test.ini:

# I removed hostname section and ansible_ssh_host=
10.0.3.[20:25] ansible_ssh_port=22

关于ansible - 具有 IP 范围的主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33648627/

相关文章:

azure - ansible - 错误!我们无法读取 JSON 或 YAML

linux - Ansible:无法删除用户

ansible - 如何使用 sudo -E 运行单个 ansible 任务?

ansible - 如何将 Ansible 剧本变量从主剧本传递到链接剧本?

Ansible 角色。默认值

regex - 如何提取ansible变量中的最后一个数字

ansible - 如何让 Ansible 仅显示执行中的错误?

ssh - 使用 ansible 添加多个 SSH key

cron - Ansible 中的幂等性和随机变量

wait - 在 ansible 中继续执行下一个任务,无需等待其他主机完成该任务