I am new to terraform and when creating the server and using a remote-exec call I keep getting an error where it fails because it looks like terraform is expecting a user input to restart services.
Is there a way to do these updates?
This is what it looks like from my terminal when running the commands.
This is the remote-exec code:
provisioner "remote-exec" { inline = ["export PATH=$PATH:/usr/bin", # update server"sudo apt update","sudo apt upgrade -y", # I think this is the one doing causing the error. ] }
So far I have tried using Ubuntu 22.04 and 22.10. Thinking that the update that is causing this could be resolved in that release. It did not.
Originally the box did not start fast enough that terraform would be able to connect to the new instance. To correct this I added a 30 second delay.
Edit: Error text
digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning candidates...digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning processor microc [ ]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning processor microc [====== ]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning processor microc [============]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning processor microcode...digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning linux images... [ ]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning linux images... [==== ]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning linux images... [======== ]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning linux images... [=============]digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Scanning linux images...digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Running kernel seems to be up-to-date.digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Failed to check for processor microcodedigitalocean_droplet.tailscale-exitnode-ne (remote-exec): upgrades.digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Restarting services...digitalocean_droplet.tailscale-exitnode-ne (remote-exec): Package configuration ─┤ Daemons using outdated libraries ├───digitalocean_droplet.tailscale-exitnode-ne (remote-exec): digitalocean_droplet.tailscale-exitnode-ne (remote-exec): hich services should bedigitalocean_droplet.tailscale-exitnode-ne (remote-exec): estarted?digitalocean_droplet.tailscale-exitnode-ne (remote-exec): digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] cloud-final.service digitalocean_droplet.tailscale-exitnode-ne: Still creating... [1m40s elapsed] digitalocean_droplet.tailscale-exitnode-ne: Still creating... [1m50s elapsed]rvice digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] ssh.service digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] systemd-journald... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [ ] systemd-logind.s... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] systemd-manager digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] systemd-networkd... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] systemd-resolved... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] systemd-timesync... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [*] systemd-udevd.se... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): [ ] unattended-upgra... digitalocean_droplet.tailscale-exitnode-ne (remote-exec): digitalocean_droplet.tailscale-exitnode-ne (remote-exec): digitalocean_droplet.tailscale-exitnode-ne (remote-exec): <Ok> <Cancel>digitalocean_droplet.tailscale-exitnode-ne (remote-exec): digitalocean_droplet.tailscale-exitnode-ne (remote-exec): ────────────────────────────────────────
---- edit 2 ----
When upgrading manually this is what is upgraded. I do the restart and it works. Just trying to confirm how to do it so terraform apply is successful.
root@docker:~# apt upgrade -yReading package lists... DoneBuilding dependency tree... DoneReading state information... DoneCalculating upgrade... DoneThe following packages will be upgraded: dbus dbus-bin dbus-daemon dbus-session-bus-common dbus-system-bus-common dbus-user-session distro-info-data kpartx libdbus-1-3 libksba8 libntfs-3g89 libpython3.10 libpython3.10-minimal libpython3.10-stdlib libssl3 multipath-tools ntfs-3g openssl python3.10 python3.10-minimal tzdata ubuntu-advantage-tools22 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.Need to get 12.3 MB of archives.After this operation, 20.5 kB disk space will be freed.Get:1 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libpython3.10 amd64 3.10.7-1ubuntu0.1 [1938 kB]Get:2 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libssl3 amd64 3.0.5-2ubuntu2 [1893 kB]Get:3 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 python3.10 amd64 3.10.7-1ubuntu0.1 [497 kB]Get:4 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libpython3.10-stdlib amd64 3.10.7-1ubuntu0.1 [1785 kB]Get:5 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 python3.10-minimal amd64 3.10.7-1ubuntu0.1 [2115 kB]Get:6 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libpython3.10-minimal amd64 3.10.7-1ubuntu0.1 [803 kB]Get:7 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 ntfs-3g amd64 1:2022.5.17-1ubuntu1.1 [410 kB]Get:8 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libntfs-3g89 amd64 1:2022.5.17-1ubuntu1.1 [160 kB]Get:9 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 dbus-session-bus-common all 1.14.0-2ubuntu3 [73.0 kB]Get:10 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 dbus-user-session amd64 1.14.0-2ubuntu3 [10.1 kB]Get:11 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 dbus-daemon amd64 1.14.0-2ubuntu3 [118 kB]Get:12 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libdbus-1-3 amd64 1.14.0-2ubuntu3 [200 kB]Get:13 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 dbus-system-bus-common all 1.14.0-2ubuntu3 [74.2 kB]Get:14 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 dbus amd64 1.14.0-2ubuntu3 [24.2 kB]Get:15 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 dbus-bin amd64 1.14.0-2ubuntu3 [39.4 kB]Get:16 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 distro-info-data all 0.54ubuntu0.1 [5242 B]Get:17 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 openssl amd64 3.0.5-2ubuntu2 [1178 kB]Get:18 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 tzdata all 2022f-0ubuntu0.22.10.1 [400 kB]Get:19 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 ubuntu-advantage-tools amd64 27.11.3~22.10.1 [142 kB]Get:20 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 libksba8 amd64 1.6.0-3ubuntu1 [119 kB]Get:21 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 kpartx amd64 0.8.8-1ubuntu1.22.10.1 [28.0 kB]Get:22 http://mirrors.digitalocean.com/ubuntu kinetic-updates/main amd64 multipath-tools amd64 0.8.8-1ubuntu1.22.10.1 [328 kB]Fetched 12.3 MB in 1s (9704 kB/s) Preconfiguring packages ...(Reading database ... 65170 files and directories currently installed.)Preparing to unpack .../00-libpython3.10_3.10.7-1ubuntu0.1_amd64.deb ...Unpacking libpython3.10:amd64 (3.10.7-1ubuntu0.1) over (3.10.7-1) ...Preparing to unpack .../01-libssl3_3.0.5-2ubuntu2_amd64.deb ...Unpacking libssl3:amd64 (3.0.5-2ubuntu2) over (3.0.5-2ubuntu1) ...Preparing to unpack .../02-python3.10_3.10.7-1ubuntu0.1_amd64.deb ...Unpacking python3.10 (3.10.7-1ubuntu0.1) over (3.10.7-1) ...Preparing to unpack .../03-libpython3.10-stdlib_3.10.7-1ubuntu0.1_amd64.deb ...Unpacking libpython3.10-stdlib:amd64 (3.10.7-1ubuntu0.1) over (3.10.7-1) ...Preparing to unpack .../04-python3.10-minimal_3.10.7-1ubuntu0.1_amd64.deb ...Unpacking python3.10-minimal (3.10.7-1ubuntu0.1) over (3.10.7-1) ...Preparing to unpack .../05-libpython3.10-minimal_3.10.7-1ubuntu0.1_amd64.deb ...Unpacking libpython3.10-minimal:amd64 (3.10.7-1ubuntu0.1) over (3.10.7-1) ...Preparing to unpack .../06-ntfs-3g_1%3a2022.5.17-1ubuntu1.1_amd64.deb ...Unpacking ntfs-3g (1:2022.5.17-1ubuntu1.1) over (1:2022.5.17-1ubuntu1) ...Preparing to unpack .../07-libntfs-3g89_1%3a2022.5.17-1ubuntu1.1_amd64.deb ...Unpacking libntfs-3g89 (1:2022.5.17-1ubuntu1.1) over (1:2022.5.17-1ubuntu1) ...Preparing to unpack .../08-dbus-session-bus-common_1.14.0-2ubuntu3_all.deb ...Unpacking dbus-session-bus-common (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../09-dbus-user-session_1.14.0-2ubuntu3_amd64.deb ...Unpacking dbus-user-session (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../10-dbus-daemon_1.14.0-2ubuntu3_amd64.deb ...Unpacking dbus-daemon (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../11-libdbus-1-3_1.14.0-2ubuntu3_amd64.deb ...Unpacking libdbus-1-3:amd64 (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../12-dbus-system-bus-common_1.14.0-2ubuntu3_all.deb ...Unpacking dbus-system-bus-common (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../13-dbus_1.14.0-2ubuntu3_amd64.deb ...Unpacking dbus (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../14-dbus-bin_1.14.0-2ubuntu3_amd64.deb ...Unpacking dbus-bin (1.14.0-2ubuntu3) over (1.14.0-2ubuntu2) ...Preparing to unpack .../15-distro-info-data_0.54ubuntu0.1_all.deb ...Unpacking distro-info-data (0.54ubuntu0.1) over (0.54) ...Preparing to unpack .../16-openssl_3.0.5-2ubuntu2_amd64.deb ...Unpacking openssl (3.0.5-2ubuntu2) over (3.0.5-2ubuntu1) ...Preparing to unpack .../17-tzdata_2022f-0ubuntu0.22.10.1_all.deb ...Unpacking tzdata (2022f-0ubuntu0.22.10.1) over (2022e-0ubuntu2) ...Preparing to unpack .../18-ubuntu-advantage-tools_27.11.3~22.10.1_amd64.deb ...Unpacking ubuntu-advantage-tools (27.11.3~22.10.1) over (27.11.2~22.10.1) ...Preparing to unpack .../19-libksba8_1.6.0-3ubuntu1_amd64.deb ...Unpacking libksba8:amd64 (1.6.0-3ubuntu1) over (1.6.0-3) ...Preparing to unpack .../20-kpartx_0.8.8-1ubuntu1.22.10.1_amd64.deb ...Unpacking kpartx (0.8.8-1ubuntu1.22.10.1) over (0.8.8-1ubuntu1) ...Preparing to unpack .../21-multipath-tools_0.8.8-1ubuntu1.22.10.1_amd64.deb ...Unpacking multipath-tools (0.8.8-1ubuntu1.22.10.1) over (0.8.8-1ubuntu1) ...Setting up libksba8:amd64 (1.6.0-3ubuntu1) ...Setting up distro-info-data (0.54ubuntu0.1) ...Setting up libssl3:amd64 (3.0.5-2ubuntu2) ...Setting up libntfs-3g89 (1:2022.5.17-1ubuntu1.1) ...Setting up ntfs-3g (1:2022.5.17-1ubuntu1.1) ...Setting up tzdata (2022f-0ubuntu0.22.10.1) ...Current default time zone: 'Etc/UTC'Local time is now: Thu Nov 17 18:37:42 UTC 2022.Universal Time is now: Thu Nov 17 18:37:42 UTC 2022.Run 'dpkg-reconfigure tzdata' if you wish to change it.Setting up libdbus-1-3:amd64 (1.14.0-2ubuntu3) ...Setting up libpython3.10-minimal:amd64 (3.10.7-1ubuntu0.1) ...Setting up dbus-session-bus-common (1.14.0-2ubuntu3) ...Setting up kpartx (0.8.8-1ubuntu1.22.10.1) ...Setting up ubuntu-advantage-tools (27.11.3~22.10.1) ...Installing new version of config file /etc/apt/apt.conf.d/20apt-esm-hook.conf ...Setting up dbus-system-bus-common (1.14.0-2ubuntu3) ...Setting up openssl (3.0.5-2ubuntu2) ...Setting up dbus-bin (1.14.0-2ubuntu3) ...Setting up dbus-daemon (1.14.0-2ubuntu3) ...Setting up python3.10-minimal (3.10.7-1ubuntu0.1) ...Setting up multipath-tools (0.8.8-1ubuntu1.22.10.1) ...Could not execute systemctl: at /usr/bin/deb-systemd-invoke line 145.Setting up libpython3.10-stdlib:amd64 (3.10.7-1ubuntu0.1) ...Setting up dbus-user-session (1.14.0-2ubuntu3) ...Setting up dbus (1.14.0-2ubuntu3) ...A reboot is required to replace the running dbus-daemon.Please reboot the system when convenient.Setting up libpython3.10:amd64 (3.10.7-1ubuntu0.1) ...Setting up python3.10 (3.10.7-1ubuntu0.1) ...Processing triggers for libc-bin (2.36-0ubuntu4) ...Processing triggers for man-db (2.10.2-2) ...Processing triggers for initramfs-tools (0.140ubuntu17) ...update-initramfs: Generating /boot/initrd.img-5.19.0-23-genericScanning processes... Scanning candidates... Scanning processor microcode... Scanning linux images... Running kernel seems to be up-to-date.Failed to check for processor microcode upgrades.Restarting services... /etc/needrestart/restart.d/systemd-manager systemctl restart packagekit.service ssh.service systemd-journald.service systemd-networkd.service systemd-resolved.service systemd-timesyncd.service systemd-udevd.serviceService restarts being deferred: /etc/needrestart/restart.d/dbus.service systemctl restart systemd-logind.service systemctl restart unattended-upgrades.serviceNo containers need to be restarted.User sessions running outdated binaries: root @ user manager service: systemd[2838]No VM guests are running outdated hypervisor (qemu) binaries on this host.