diff options
-rw-r--r-- | inventory.yaml.example | 2 | ||||
-rw-r--r-- | tasks/pve_setup.yaml | 8 | ||||
-rw-r--r-- | templates/hosts.j2 | 2 | ||||
-rw-r--r-- | vars/main.yaml | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/inventory.yaml.example b/inventory.yaml.example index 115fb2b..69081ac 100644 --- a/inventory.yaml.example +++ b/inventory.yaml.example @@ -4,7 +4,7 @@ all: ansible_host: 10.11.12.13 ansible_user: root ansible_ssh_private_key_file: id_rsa - hostname: proxmox-ve-test + hostname: proxmox nat_subnet: 10.10.10.0/24 nat_bridge_ip: 10.10.10.1 wg_subnet: 10.13.37.0/24 diff --git a/tasks/pve_setup.yaml b/tasks/pve_setup.yaml index 9fcea47..9de9489 100644 --- a/tasks/pve_setup.yaml +++ b/tasks/pve_setup.yaml @@ -1,3 +1,11 @@ +- name: set hostname to {{ pve_hostname }} + copy: + content: "{{ pve_hostname }}" + dest: /etc/hostname + owner: root + group: root + mode: '0644' + - name: generate /etc/hosts from template template: src: templates/hosts.j2 diff --git a/templates/hosts.j2 b/templates/hosts.j2 index 3d811dc..647360e 100644 --- a/templates/hosts.j2 +++ b/templates/hosts.j2 @@ -1,5 +1,5 @@ 127.0.0.1 localhost -{{ ansible_host }} {{ hostname }} {{ hostname }} +{{ ansible_host }} {{ pve_hostname }} {{ pve_hostname }} # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback diff --git a/vars/main.yaml b/vars/main.yaml index 8c2d0b2..759bcfb 100644 --- a/vars/main.yaml +++ b/vars/main.yaml @@ -29,6 +29,8 @@ wireguard_packages: - iproute2 fail2ban_jail_dir: /etc/fail2ban/jail.d +random_hex: "{{ lookup('password', '/dev/null', length=8, chars='abcdefghijklmnopqrstuvwxyz0123456789') }}" +pve_hostname: "{{ hostname }}-{{ random_hex }}" wg_server_home: /etc/wireguard wg_peers_home: "{{ wg_server_home }}/peers.d" wg_ip_file: "{{ wg_server_home }}/ips.txt" |