Skip to content

Commit

Permalink
[vm] disable unattended upgrades on debian/ubuntu on EC2
Browse files Browse the repository at this point in the history
  • Loading branch information
pducolin committed Oct 18, 2024
1 parent fd73f9b commit 55d457c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
8 changes: 8 additions & 0 deletions components/os/debian_disable_upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package os

import (
_ "embed"
)

//go:embed scripts/debian-disable-unattended-upgrades.sh
var DebianDisableUnattendedUpgradesScriptContent string
2 changes: 2 additions & 0 deletions components/os/scripts/debian-disable-unattended-upgrades.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
apt-get -y remove unattended-upgrades
2 changes: 1 addition & 1 deletion components/os/windows_setup_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import (
)

//go:embed scripts/setup-ssh.ps1
var SetupSSHScriptContent string
var WindowsSetupSSHScriptContent string
2 changes: 1 addition & 1 deletion resources/azure/compute/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func NewWindowsInstance(e azure.Environment, name, imageUrn, instanceType string
AsyncExecution: pulumi.Bool(false),
RunCommandName: pulumi.String("InitVM"),
Source: compute.VirtualMachineRunCommandScriptSourceArgs{
Script: pulumi.String(strings.Join([]string{setupSSHParamScriptContent, componentsos.SetupSSHScriptContent}, "\n\n")),
Script: pulumi.String(strings.Join([]string{setupSSHParamScriptContent, componentsos.WindowsSetupSSHScriptContent}, "\n\n")),
},
Parameters: compute.RunCommandInputParameterArray{
compute.RunCommandInputParameterArgs{
Expand Down
2 changes: 1 addition & 1 deletion scenarios/aws/ec2/os_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func getWindowsOpenSSHUserData(publicKeyPath string) (string, error) {
}

return buildAWSPowerShellUserData(
componentsos.SetupSSHScriptContent,
componentsos.WindowsSetupSSHScriptContent,
windowsPowerShellArgument{name: "authorizedKey", value: string(publicKey)},
),
nil
Expand Down
3 changes: 2 additions & 1 deletion scenarios/aws/ec2/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ func defaultVMArgs(e aws.Environment, vmArgs *vmArgs) error {
if err != nil {
return err
}

vmArgs.userData = vmArgs.userData + sshUserData
} else if vmArgs.osInfo.Flavor == os.Ubuntu || vmArgs.osInfo.Flavor == os.Debian {
vmArgs.userData = vmArgs.userData + os.DebianDisableUnattendedUpgradesScriptContent
}

return nil
Expand Down

0 comments on commit 55d457c

Please sign in to comment.