diff --git a/nova/core/galaxy.yml b/nova/core/galaxy.yml index b909c2f9f..2fa1bdae5 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 e63057ab2..253d4f177 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 870500f70..71a99fa99 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 diff --git a/nova/core/roles/finalize/tasks/windows.yml b/nova/core/roles/finalize/tasks/windows.yml index 4c468ef3e..07601bbd1 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/snapshots/vsphere/snapshot.yml b/nova/core/roles/snapshots/vsphere/snapshot.yml index 95cc871ce..c051bf517 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... diff --git a/nova/core/roles/template_os_configuration/defaults/main.yml b/nova/core/roles/template_os_configuration/defaults/main.yml index e3deafc8f..1c240c40a 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 e464d7dba..bd9424450 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 diff --git a/nova/core/roles/win_sysprep/tasks/sysprep.yml b/nova/core/roles/win_sysprep/tasks/sysprep.yml index 8c724e0ec..9f07b6d38 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