autogenerate hosts

This commit is contained in:
dogeystamp 2023-08-23 17:54:55 -04:00
parent 523cfec521
commit dce5b25702
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
4 changed files with 16 additions and 3 deletions

View File

@ -4,7 +4,5 @@
# LAN static IP address
local_subnet: 192.168.0.0/24
# local IP of bastion node
bastion_ip: null
sshd_port: 2500

View File

@ -14,7 +14,7 @@
- name: Set default sources (fleet server)
set_fact:
default_firewall_src: "{{ bastion_ip }}"
default_firewall_src: "{{ host_vars[groups['bastion'][0]]['local_ip'] }}"
when: "fleet" in group_names
- name: Allow service ports

View File

@ -0,0 +1,6 @@
---
- name: Deploy /etc/hosts template
template:
src: hosts.j2
dest: /etc/hosts

View File

@ -0,0 +1,9 @@
# Static table lookup for hostnames.
# See hosts(5) for details.
# This file (/etc/hosts) is automatically generated via Ansible.
# Modifications will be lost!
{% for host in groups["all"] %}
{{ host_vars[host]["local_ip"] }} {{ host }}
{% endfor %}