mirror of
https://gitea.0xace.cc/ansible-galaxy/hosts.git
synced 2025-06-28 21:13:07 +00:00
add hosts role
This commit is contained in:
16
tasks/main.yaml
Normal file
16
tasks/main.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
- 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
|
||||
- hostvars[item].pin_hosts is defined
|
||||
with_items: "{{ groups.all }}"
|
||||
tags:
|
||||
- hosts
|
||||
|
||||
become: true
|
Reference in New Issue
Block a user