hosts/tasks/main.yaml

17 lines
413 B
YAML
Raw Normal View History

2021-11-02 14:14:48 +00:00
---
- block:
- name: add ip address of all hosts to all hosts
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
2021-11-02 14:16:47 +00:00
- pin_hosts
2021-11-02 14:14:48 +00:00
with_items: "{{ groups.all }}"
tags:
- hosts
become: true