hosts/tasks/main.yaml

17 lines
425 B
YAML
Raw Permalink Normal View History

2021-11-02 14:14:48 +00:00
---
- block:
2022-12-12 08:58:34 +00:00
- name: Add ip address of all hosts to all hosts
2021-11-02 14:14:48 +00:00
lineinfile:
dest: /etc/hosts
regexp: '.*{{ item }} {{ item.split(".")[0] }}$'
line: "{{ hostvars[item].ansible_host }} {{ item }} {{ item.split('.')[0] }}"
state: present
when:
- hostvars[item].ansible_host is defined
2022-12-12 08:58:34 +00:00
- hosts_pin
2021-12-22 16:16:52 +00:00
with_items: "{{ ansible_play_hosts_all }}"
2021-11-02 14:14:48 +00:00
tags:
- hosts
become: true