From 5d069ff5ee8aa7e3bf89bcba14b63f3082369bd3 Mon Sep 17 00:00:00 2001 From: Luca Carrogu Date: Thu, 9 Sep 2021 23:09:38 +0200 Subject: [PATCH] Disable Ubuntu unattended upgrade also in update component Signed-off-by: Luca Carrogu --- .../pcluster/resources/imagebuilder/parallelcluster.yaml | 7 ++++--- .../pcluster/resources/imagebuilder/update_and_reboot.yaml | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml b/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml index 5ad46e6cd9..e98691f130 100644 --- a/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml +++ b/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml @@ -198,9 +198,10 @@ phases: grub2-mkconfig -o /boot/grub2/grub.cfg fi elif [[ ${!PLATFORM} == DEBIAN ]]; then - [ ${CfnParamUpdateOsAndReboot} == false ] && flock $(apt-config shell StateDir Dir::State/d | sed -r "s/.*'(.*)\/?'$/\1/")/daily_lock systemctl stop apt-daily.timer apt-daily.service apt-daily-upgrade.timer apt-daily-upgrade.service - sed -i "s/Update-Package-Lists \"1\"/Update-Package-Lists \"0\"/g" /etc/apt/apt.conf.d/20auto-upgrades - sed -i "s/Unattended-Upgrade \"1\"/Unattended-Upgrade \"0\"/g" /etc/apt/apt.conf.d/20auto-upgrades + if [[ "${CfnParamUpdateOsAndReboot}" == "false" ]]; then + flock $(apt-config shell StateDir Dir::State/d | sed -r "s/.*'(.*)\/?'$/\1/")/daily_lock systemctl disable --now apt-daily.timer apt-daily.service apt-daily-upgrade.timer apt-daily-upgrade.service + sed "/Update-Package-Lists/s/\"1\"/\"0\"/; /Unattended-Upgrade/s/\"1\"/\"0\"/;" /etc/apt/apt.conf.d/20auto-upgrades > "/etc/apt/apt.conf.d/51pcluster-unattended-upgrades" + fi apt-cache search build-essential apt-get clean apt-get -y update diff --git a/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml b/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml index ac5122940f..12e02d045b 100644 --- a/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml +++ b/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml @@ -117,7 +117,8 @@ phases: yum -y install kernel-devel elif [[ ${!PLATFORM} == DEBIAN ]]; then while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done - flock $(apt-config shell StateDir Dir::State/d | sed -r "s/.*'(.*)\/?'$/\1/")/daily_lock systemctl stop apt-daily.timer apt-daily.service apt-daily-upgrade.timer apt-daily-upgrade.service + flock $(apt-config shell StateDir Dir::State/d | sed -r "s/.*'(.*)\/?'$/\1/")/daily_lock systemctl disable --now apt-daily.timer apt-daily.service apt-daily-upgrade.timer apt-daily-upgrade.service + sed "/Update-Package-Lists/s/\"1\"/\"0\"/; /Unattended-Upgrade/s/\"1\"/\"0\"/;" /etc/apt/apt.conf.d/20auto-upgrades > "/etc/apt/apt.conf.d/51pcluster-unattended-upgrades" DEBIAN_FRONTEND=noninteractive apt-get -y update && apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --with-new-pkgs upgrade && apt-get --purge autoremove -y apt-get -y install linux-aws fi @@ -149,4 +150,4 @@ phases: inputs: commands: - | - echo "Check the OS has been updated" \ No newline at end of file + echo "Check the OS has been updated"