Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows with ssh-communicator failed to execute shutdown command #173

Closed
luclis opened this issue May 5, 2024 · 5 comments
Closed

Windows with ssh-communicator failed to execute shutdown command #173

luclis opened this issue May 5, 2024 · 5 comments

Comments

@luclis
Copy link

luclis commented May 5, 2024

Overview of the Issue

When you use Packer with ssh communicator, he expect to see somes Unix-like machine. When you specify an shutdown command, he try an command like this : chmod +x /tmp/script_5623.sh; PACKER_BUILDER_TYPE='qemu' PACKER_BUILD_NAME='Windows' PACKER_HTTP_ADDR='10.0.0.2:0' PACKER_HTTP_IP='10.0.0.2' PACKER_HTTP_PORT='0' /tmp/script_5623.sh.
On Windows, chmod isn't find and the build failed.

Workaroud : Use a provisioner and run the shutdown command.

  provisioner "powershell" {
    script            = "../scripts/shutdown.ps1" #shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"
  }

Reproduction Steps

1/ Download Packer builder
2/ Download any prerequisites (Windows ISO ; builders ; virtio iso)
3/ Download Unattened.xml
4/ Run the build.

Plugin and Packer version

Packer v1.10.3

packer plugins installed
~/.config/packer/plugins/github.com/hashicorp/qemu/packer-plugin-qemu_v1.1.0_x5.0_linux_amd64
~.config/packer/plugins/github.com/hashicorp/virtualbox/packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64

Simplified Packer Buildfile

Gist in Reproduction steps.

Operating system and Environment details

Ubuntu 22.04 x64.

Log Fragments and crash.log files

2024/05/05 21:04:39 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 1
2024/05/05 21:04:39 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/05/05 21:04:39 [DEBUG] Opening new ssh session
2024/05/05 21:04:39 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/05/05 21:04:39 [DEBUG] starting remote command: chmod +x /tmp/script_5623.sh; PACKER_BUILDER_TYPE='qemu' PACKER_BUILD_NAME='Windows' PACKER_HTTP_ADDR='10.0.2.2:0' PACKER_HTTP_IP='10.0.2.2' PACKER_HTTP_PORT='0'  /tmp/script_5623.sh
==> qemu.Windows: 'chmod' n'est pas reconnu en tant que commande interne
==> qemu.Windows: ou externe, un programme ex�cutable ou un fichier de commandes.
2024/05/05 21:04:39 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/05/05 21:04:39 [ERROR] Remote command exited with '1': chmod +x /tmp/script_5623.sh; PACKER_BUILDER_TYPE='qemu' PACKER_BUILD_NAME='Windows' PACKER_HTTP_ADDR='10.0.2.2:0' PACKER_HTTP_IP='10.0.2.2' PACKER_HTTP_PORT='0'  /tmp/script_5623.sh
2024/05/05 21:04:39 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/05/05 21:04:39 [INFO] RPC endpoint: 
[...]
2024/05/05 21:04:39 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/05/05 21:04:39 Deleting floppy disk: /tmp/packer1614611994
==> qemu.Windows: Deleting output directory...
2024/05/05 21:04:39 [INFO] (telemetry) ending qemu.Windows2
Build 'qemu.Windows' errored after 12 minutes 56 seconds: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]
@luclis luclis added the bug label May 5, 2024
@lbajolet-hashicorp
Copy link
Contributor

Hi @luclis,

That's weird, the powershell provisioner doesn't chmod anything whatsoever, I'm curious on how you're running into this. If possible would you mind sharing more about your template?
If you're able to make a minimal example/repo that we can reproduce the problem with, that'd be ideal so we can validate this is indeed a Packer/plugin bug, and if it's not we may be able to steer you towards a resolution.

Thanks!

@luclis
Copy link
Author

luclis commented May 15, 2024

Hi @lbajolet-hashicorp,
Yep, I can send you more info. Did you see the gist I included ? The're all I have in my template.
If I remember clearly, it was the shutdown command who failed with the chmod error. I rebuilding them and confirm it as soon as I can.

@lbajolet-hashicorp
Copy link
Contributor

Hi @luclis,

I hadn't seen the links to the gists for both the build and the unattend.xml indeed, my bad 😅

I'll check locally if I can replicate the issue, thanks for the update!

@luclis
Copy link
Author

luclis commented May 15, 2024

Hi Lucas,

I rebuild it this morning and can't reproduce the issue 🤔
I'll dig in my templates log and see what I've done.

@luclis
Copy link
Author

luclis commented Jun 4, 2024

Clossing as "can't reproduce", I'll reopen it if I find what I've done. Thanks

@luclis luclis closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants