From 6d7fc713a24271c7c7fbf5a87f4d55af69af4be0 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 6 Dec 2025 07:06:38 +0100 Subject: [PATCH] fix: add optional FQDN configuration to VM template and Cloud-Init user-data --- defaults/main.yml | 4 ++++ tasks/configure-vm.yml | 1 - templates/cloudinit_userdata.yaml.j2 | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index f080a53..b0e9d73 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,6 +13,10 @@ vm_id: 150 # Hostname for the base VM (template) hostname: debian-template-base +# optional fqdn +# fqdn: myvm.example.com + + # Memory in MB memory: 2048 diff --git a/tasks/configure-vm.yml b/tasks/configure-vm.yml index 45760d7..c28c44a 100644 --- a/tasks/configure-vm.yml +++ b/tasks/configure-vm.yml @@ -156,7 +156,6 @@ qm set {{ vm_id }} --ciuser {{ ci_user }} --sshkeys local:snippets/{{ vm_id }}-sshkey.pub - --hostname {{ hostname }} --citype nocloud --cicustom "user=local:snippets/{{ vm_id }}-user.yaml,vendor=local:snippets/{{ vm_id }}-vendor.yaml" --ipconfig0 {{ ipconfig0 }} diff --git a/templates/cloudinit_userdata.yaml.j2 b/templates/cloudinit_userdata.yaml.j2 index 5dfdfae..af6e6e4 100644 --- a/templates/cloudinit_userdata.yaml.j2 +++ b/templates/cloudinit_userdata.yaml.j2 @@ -1,5 +1,10 @@ #cloud-config +hostname: {{ hostname }} +{% if domain is defined and domain %} +fqdn: {{ hostname }}.{{ domain }} +{% endif %} + users: - name: {{ ci_user }} sudo: ALL=(ALL) NOPASSWD:ALL