Build is stop when using loginctl in shell script provisioner

Hi Packer Community,

I’m working on packer to build custom AMI for AWS EC2 instances.

I use the shell provisioner to exec multiple scripts from the inline attribute like in the following example :

provisioner "shell" {
    # allow the server to disconnect from Packer without throwing an error. A disconnect might happen if you restart the SSH server or reboot the host
    expect_disconnect = true
    environment_vars = [
    inline = [
      "sudo /tmp/",
      "sudo /tmp/"

My first script end with a command loginctl terminate-user ubuntu, and packer stop the provisioning without executing

Do you have an idea to solve this ?


To resolve the issue of Packer stopping the provisioning process after the loginctl terminate-user command, try appending an ampersand (&) survivor io mod apk download to the command in your shell script provisioner. This allows it to run in the background, allowing the remaining scripts to execute uninterrupted.