Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nova/core/galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: nova
name: core
version: 7.4.0
version: 7.4.1
readme: README.md
authors:
- https://github.com/novateams
Expand Down
25 changes: 5 additions & 20 deletions nova/core/roles/configure_networking/tasks/proxmox/netplan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions nova/core/roles/finalize/tasks/windows.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
12 changes: 11 additions & 1 deletion nova/core/roles/snapshots/vsphere/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,24 @@
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 }}"
folder: "{{ folder }}"
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...
Expand Down
9 changes: 8 additions & 1 deletion nova/core/roles/template_os_configuration/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions nova/core/roles/template_os_configuration/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions nova/core/roles/win_sysprep/tasks/sysprep.yml
Original file line number Diff line number Diff line change
@@ -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