各ノードのプライベート IP を取得する方法はありますか?
このテンプレートでは:
{{ ansible_managed }}
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
{% for item in groups['all'] %}
{{ hostvars[item]['ansible_ssh_host'] }} {{ item }}
{% endfor %}
次の結果が得られます。
Ansible managed
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 arithproducer
127.0.0.1 controller
127.0.0.1 restapi
私のインベントリファイルであること:
[control]
controller ansible_ssh_host=192.168.50.3 ansible_ssh_user=vagrant
[servers]
restapi ansible_ssh_host=192.168.50.5 ansible_ssh_user=vagrant
[producers]
arithproducer ansible_ssh_host=192.168.50.4 ansible_ssh_user=vagrant
[services:children]
servers
producers
アイデアは、この情報を取得/etc/hosts/
して、制御ノードにファイルを入力できるようにすることです