【发布时间】:2021-04-20 08:05:14
【问题描述】:
我是 Ansible 的新手,无法从文档中弄清楚如何实现这一点: 我有一个这样的库存文件:
example_site:
children:
...
example_hosts:
hosts:
h1:
ansible_host: "192.168.0.1"
h2:
ansible_host: "192.168.0.2"
现在我想在 playbook 中启动一个 Gluster 集群:
tasks:
- name: Create a trusted storage pool
become: yes
gluster.gluster.gluster_peer:
state: present
nodes:
- "192.168.0.1"
- "192.168.0.2"
有没有办法不对这个 IP 地址列表进行硬编码?我试过node: groups['example_hosts'],但没用。
如何从库存中获取 IP 地址列表?
【问题讨论】:
-
谢谢参考,不过我不想把所有的ip地址都写第二遍在变量里,而是直接用库存的hosts部分定义的ip地址
标签: ansible yaml jinja2 glusterfs