mirror of
https://github.com/elasticdog/packer-arch.git
synced 2026-07-18 00:45:20 +00:00
Add a workaround for the shutdown race condition
http://comments.gmane.org/gmane.linux.arch.general/48739 Basically systemd kills the networking before it kills ssh sessions, and Packer will try and wait for a 0 exit code after the shutdown command to confirm that it worked. Things happen too quickly with systemd, and so Packer complains when gracefully halting the machine that: "Build 'vmware' errored: Shutdown command has non-zero exit status." This workaround just adds a standard systemd timer to the poweroff command so it has a one second delay, which is long enough for the 0 exit code to return and signal a successful graceful halt.
This commit is contained in:
parent
b2b923a36b
commit
6f747f9425
3 changed files with 9 additions and 1 deletions
|
|
@ -14,7 +14,7 @@
|
|||
"disk_size": 20480,
|
||||
"ssh_username": "root",
|
||||
"ssh_password": "vagrant",
|
||||
"shutdown_command": "systemctl poweroff"
|
||||
"shutdown_command": "systemctl start poweroff.timer"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ cat <<-EOF > "${TARGET_DIR}${CONFIG_SCRIPT}"
|
|||
/usr/bin/curl --output /home/vagrant/.ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
|
||||
/usr/bin/chown vagrant:users /home/vagrant/.ssh/authorized_keys
|
||||
/usr/bin/chmod 0600 /home/vagrant/.ssh/authorized_keys
|
||||
# workaround for shutdown race condition: http://comments.gmane.org/gmane.linux.arch.general/48739
|
||||
/usr/bin/curl --output /etc/systemd/system/poweroff.timer https://raw.github.com/elasticdog/packer-arch/master/poweroff.timer
|
||||
|
||||
# clean up
|
||||
/usr/bin/pacman -Rcns --noconfirm gptfdisk
|
||||
|
|
|
|||
6
poweroff.timer
Normal file
6
poweroff.timer
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[Unit]
|
||||
Description=Delayed poweroff
|
||||
|
||||
[Timer]
|
||||
OnActiveSec=1
|
||||
Unit=poweroff.target
|
||||
Loading…
Add table
Add a link
Reference in a new issue