role hosts

This commit is contained in:
Ruben Blanco 2024-02-14 15:50:02 +01:00
parent 01b7e2ba94
commit 43f2f82066
4 changed files with 20 additions and 0 deletions

View File

@ -5,6 +5,8 @@ hostname: 'test-playbook'
hosts:
- ip: 127.0.0.1
name: localhost
- ip: 127.0.1.1
name: test-playbook.lab.dc.verdnatura.es test-playbook
################################################################################
### FAIL2BAN ####################################################################

View File

@ -0,0 +1,10 @@
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- name: Replace old /etc/hosts with new /etc/hosts
template:
src: hosts.j2
dest: "{{ path_hosts }}"
owner: root
group: root
mode: '0644'
backup: true
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -0,0 +1,5 @@
{% if hosts is defined %}
{% for host in hosts %}
{{host.ip}} {{host.name}}
{% endfor %}
{% endif %}

View File

@ -0,0 +1,3 @@
---
# vars file
path_hosts: /etc/hosts