Remove hosts hardcode

This commit is contained in:
Андрей Лимачко 2022-03-09 09:01:02 +04:00
parent 1b4696fabd
commit 9cd23a3b68

View File

@ -59,12 +59,12 @@
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
- name: register nodes in /etc/hosts #- name: register nodes in /etc/hosts
lineinfile: # lineinfile:
path: /etc/hosts # path: /etc/hosts
regexp: ".*{{ item }}$" # regexp: ".*{{ item }}$"
line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}" # line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}"
state: present # state: present
when: hostvars[item].ansible_default_ipv4.address is defined # when: hostvars[item].ansible_default_ipv4.address is defined
with_items: "{{ play_hosts }}" # with_items: "{{ play_hosts }}"
tags: [ prepare ] tags: [ prepare ]