From 0f3af63d9f94a2f6a6f12e4d4639850045ad1358 Mon Sep 17 00:00:00 2001 From: fraliv13 <5892139+fraliv13@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:42:31 +0200 Subject: [PATCH] AVD init script - always execute (#105) * AVD init script - always execute * Update --- .../provisioners/pulumi/azure_virtual_desktop.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go b/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go index 6dd69a6..a6c8c22 100644 --- a/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go +++ b/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/google/uuid" "github.com/pulumi/pulumi-azure-native-sdk/authorization/v2" "github.com/pulumi/pulumi-azure-native-sdk/compute/v2" "github.com/pulumi/pulumi-azure-native-sdk/desktopvirtualization/v2" @@ -297,13 +298,16 @@ func NewAzureVirtualDesktopVM(ctx *pulumi.Context, name string, args *AzureVirtu }) } + // Append a forceUpdateTag line to ensure the script is always executed + initScript := args.Spec.InitScript + fmt.Sprintf("\n# Force update tag: %s\n", uuid.New().String()) + _, err = compute.NewVirtualMachineRunCommandByVirtualMachine(ctx, fmt.Sprintf("%s-init-cmd", name), &compute.VirtualMachineRunCommandByVirtualMachineArgs{ ResourceGroupName: args.ResourceGroupName, VmName: avdVM.VirtualMachine.Name, AsyncExecution: pulumi.Bool(false), RunCommandName: pulumi.String("InitVM"), Source: compute.VirtualMachineRunCommandScriptSourceArgs{ - Script: pulumi.String(args.Spec.InitScript), + Script: pulumi.String(initScript), }, Parameters: params, TimeoutInSeconds: pulumi.Int(60),