From 64763b0c4c78a0ae037fcbf250410caeca320aa3 Mon Sep 17 00:00:00 2001 From: Allar Viik Date: Mon, 23 Feb 2026 15:30:33 +0200 Subject: [PATCH 1/4] Fixed an issue where Ubuntu Desktop netplan did not apply --- nova/core/galaxy.yml | 2 +- .../tasks/proxmox/netplan.yml | 25 ++++--------------- .../tasks/vsphere/netplan.yml | 5 ++-- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/nova/core/galaxy.yml b/nova/core/galaxy.yml index b909c2f9..2fa1bdae 100644 --- a/nova/core/galaxy.yml +++ b/nova/core/galaxy.yml @@ -1,6 +1,6 @@ namespace: nova name: core -version: 7.4.0 +version: 7.4.1 readme: README.md authors: - https://github.com/novateams diff --git a/nova/core/roles/configure_networking/tasks/proxmox/netplan.yml b/nova/core/roles/configure_networking/tasks/proxmox/netplan.yml index e63057ab..253d4f17 100644 --- a/nova/core/roles/configure_networking/tasks/proxmox/netplan.yml +++ b/nova/core/roles/configure_networking/tasks/proxmox/netplan.yml @@ -46,24 +46,6 @@ validate_certs: "{{ proxmox_validate_certs }}" register: network_config_command - - name: Fixing permissions on netplan configuration file... - ansible.builtin.uri: - url: "{{ proxmox_api_url }}/nodes/{{ cfg_net_proxmox_node }}/qemu/{{ cfg_net_proxmox_vmid }}/agent/exec" - headers: - Authorization: PVEAPIToken={{ proxmox_defaults.api_user }}!{{ proxmox_defaults.api_token_id }}={{ proxmox_defaults.api_token_secret }} - method: POST - body: - command: - - chmod - - 600 - - /etc/netplan/01-netcfg.yaml - body_format: json - validate_certs: "{{ proxmox_validate_certs }}" - register: network_config_command - - - name: Including command run check task... - ansible.builtin.include_tasks: command_run_check.yml - - name: Applying netplan... ansible.builtin.uri: url: "{{ proxmox_api_url }}/nodes/{{ cfg_net_proxmox_node }}/qemu/{{ cfg_net_proxmox_vmid }}/agent/exec" @@ -72,8 +54,11 @@ method: POST body: command: - - netplan - - apply + - sh + - -c + # 3x netplan apply is required for Ubuntu Desktop versions otherwise the network configuration doesn't get applied correctly for some reason + # Doing that is still cheaper than a single reboot + - "chmod 600 /etc/netplan/01-netcfg.yaml && netplan apply && netplan apply && netplan apply" body_format: json validate_certs: "{{ proxmox_validate_certs }}" register: network_config_command diff --git a/nova/core/roles/configure_networking/tasks/vsphere/netplan.yml b/nova/core/roles/configure_networking/tasks/vsphere/netplan.yml index 870500f7..71a99fa9 100644 --- a/nova/core/roles/configure_networking/tasks/vsphere/netplan.yml +++ b/nova/core/roles/configure_networking/tasks/vsphere/netplan.yml @@ -76,8 +76,9 @@ body: credentials: "{{ rest_api_credentials }}" spec: - # 2x netplan is required for Ubuntu 20.04 for some reason - arguments: -c "chmod 600 /etc/netplan/01-netcfg.yaml && netplan apply && netplan apply" + # 3x netplan apply is required for Ubuntu Desktop versions otherwise the network configuration doesn't get applied correctly for some reason + # Doing that is still cheaper than a single reboot + arguments: -c "chmod 600 /etc/netplan/01-netcfg.yaml && netplan apply && netplan apply && netplan apply" path: /bin/bash status_code: 201 body_format: json From 465fed598721e5850babc9ccba9f9631deca5cce Mon Sep 17 00:00:00 2001 From: Allar Viik Date: Mon, 23 Feb 2026 15:49:18 +0200 Subject: [PATCH 2/4] Added more Windows sysprep cleanup paths to `finalize` role --- nova/core/roles/finalize/tasks/windows.yml | 11 ++++++++--- nova/core/roles/win_sysprep/tasks/sysprep.yml | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/nova/core/roles/finalize/tasks/windows.yml b/nova/core/roles/finalize/tasks/windows.yml index 4c468ef3..07601bbd 100644 --- a/nova/core/roles/finalize/tasks/windows.yml +++ b/nova/core/roles/finalize/tasks/windows.yml @@ -1,9 +1,14 @@ --- -# Sometimes unattend.xml is not removed automatically -- name: Removing Unattend.xml... +- name: Removing following sysprep files... ansible.windows.win_file: - path: C:/Windows/System32/Sysprep/unattend.xml + path: "{{ sysprep_file }}" state: absent + loop: + - C:/Windows/Panther/unattend-original.xml + - C:/Windows/Panther/unattend.xml + - C:/Windows/System32/Sysprep/unattend.xml # Created by nova.core.win_sysprep role + loop_control: + loop_var: sysprep_file - name: Removing {{ post_scripts_folder_on_target }}... ansible.windows.win_file: diff --git a/nova/core/roles/win_sysprep/tasks/sysprep.yml b/nova/core/roles/win_sysprep/tasks/sysprep.yml index 8c724e0e..9f07b6d3 100644 --- a/nova/core/roles/win_sysprep/tasks/sysprep.yml +++ b/nova/core/roles/win_sysprep/tasks/sysprep.yml @@ -1,14 +1,14 @@ --- - name: Encoding Administrator's password... - ansible.windows.win_shell: "{{ lookup('template', 'Encode-UnattendPassword.ps1') }}" + ansible.windows.win_shell: "{{ lookup('ansible.builtin.template', 'Encode-UnattendPassword.ps1') }}" register: win_shell -- name: Templating Unattend.xml to machine... +- name: Templating C:/Windows/System32/Sysprep/Unattend.xml... ansible.windows.win_template: src: Unattend.xml dest: C:/Windows/System32/Sysprep/Unattend.xml -- name: Running sysprep... - ansible.windows.win_shell: "{{ lookup('template', 'Windows-Sysprep.ps1') }}" +- name: Running Sysprep... + ansible.windows.win_shell: "{{ lookup('ansible.builtin.template', 'Windows-Sysprep.ps1') }}" async: 60 poll: 0 From aa66a0bf536d0307306a5b51224a1f898389ca8f Mon Sep 17 00:00:00 2001 From: Allar Viik Date: Mon, 23 Feb 2026 21:07:08 +0200 Subject: [PATCH 3/4] Changed the default vSphere behaviour where existing snapshot is overwritten if a new one is created with the same name in `snapshots` role --- nova/core/roles/snapshots/vsphere/snapshot.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nova/core/roles/snapshots/vsphere/snapshot.yml b/nova/core/roles/snapshots/vsphere/snapshot.yml index 95cc871c..c051bf51 100644 --- a/nova/core/roles/snapshots/vsphere/snapshot.yml +++ b/nova/core/roles/snapshots/vsphere/snapshot.yml @@ -27,6 +27,16 @@ ansible.builtin.setup: filter: "*_time" + # This is to avoid overwriting existing snapshots with the same name since that's the default behavior of the vmware.vmware.vm_snapshot + - name: Appending timestamp to snapshot name if it already exists... + ansible.builtin.set_fact: + snapshot_name_with_timestamp: "{{ snapshot_name }}_{{ ansible_facts.date_time.iso8601 }}" + when: + - snapshot_name is defined + - snapshot_mode == 'snap' + - vcenter_vm_info.guests[0].snapshots != [] + - snapshot_name in vcenter_vm_info.guests[0].snapshots | map(attribute='name') | list + - name: Creating a snapshot - {{ snapshot_name | default(ansible_facts.date_time.iso8601) }}... vmware.vmware.vm_snapshot: datacenter: "{{ datacenter }}" @@ -34,7 +44,7 @@ name: "{{ custom_vm_name | default(vm_name) }}" state: present memory_dump: "{{ true if live_snap else false }}" - snapshot_name: "{{ snapshot_name | default(ansible_facts.date_time.iso8601) }}" + snapshot_name: "{{ snapshot_name_with_timestamp | default(snapshot_name) | default(ansible_facts.date_time.iso8601) }}" description: Created at {{ ansible_facts.date_time.iso8601 }} by {{ project_deployer_username | default(deployer_username) }} - name: Including powerstate role... From 8e4eb564e4652e7eb79d02518e9aa9c6a0be974d Mon Sep 17 00:00:00 2001 From: Allar Viik Date: Mon, 23 Feb 2026 21:07:52 +0200 Subject: [PATCH 4/4] Added variables to define snapshot name and mode in `template_os_configuration` role --- .../roles/template_os_configuration/defaults/main.yml | 9 ++++++++- nova/core/roles/template_os_configuration/tasks/main.yml | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/nova/core/roles/template_os_configuration/defaults/main.yml b/nova/core/roles/template_os_configuration/defaults/main.yml index e3deafc8..1c240c40 100644 --- a/nova/core/roles/template_os_configuration/defaults/main.yml +++ b/nova/core/roles/template_os_configuration/defaults/main.yml @@ -8,6 +8,13 @@ template_os_configuration_update_system: true # Update OS during this role template_os_configuration_increase_maxauthtries: true template_os_configuration_increase_maxauthtries_value: 20 -# Will remove existing and creating a fresh snapshot after all configuration is done on the template VM +# Will create a fresh snapshot after all configuration is done on the template VM # Set to false to skip snapshot creation template_os_configuration_create_snapshot: true + +# By default will remove all previous snapshots and create a new one +# Set value to "snap" to avoid removing previous snapshots +template_os_configuration_create_snapshot_mode: clean-snap + +# Name of the snapshot to create after configuration is done. Only used if template_os_configuration_create_snapshot is true +template_os_configuration_create_snapshot_name: LinkedCloneSource diff --git a/nova/core/roles/template_os_configuration/tasks/main.yml b/nova/core/roles/template_os_configuration/tasks/main.yml index e464d7db..bd942445 100644 --- a/nova/core/roles/template_os_configuration/tasks/main.yml +++ b/nova/core/roles/template_os_configuration/tasks/main.yml @@ -62,8 +62,8 @@ ansible.builtin.include_role: name: nova.core.snapshots vars: - snapshot_mode: clean-snap - snapshot_name: LinkedCloneSource + snapshot_mode: "{{ template_os_configuration_create_snapshot_mode }}" + snapshot_name: "{{ template_os_configuration_create_snapshot_name }}" start_vm_after_snapshot: false when: template_os_configuration_create_snapshot