Last active
November 15, 2018 13:08
-
-
Save ktstevenson/ba41b160da2426112c1e11ce1fcde1be to your computer and use it in GitHub Desktop.
Packer build configuration - hangs during shell provisioning after a reboot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"iso_checksum": "27bd866242ee058b7a5754e83d8ee8403e216b93d130d800852a96f41c34d86a", | |
"iso_checksum_type": "sha256", | |
"iso_name": "CentOS-7-x86_64-Minimal-1611", | |
"iso_url": "http://mirror.cs.vt.edu/pub/CentOS/7/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso", | |
"ssh_password": "vagrant", | |
"ssh_username": "vagrant", | |
"scripts_dir" : "scripts", | |
"version": "0.0.1" | |
}, | |
"builders": [ | |
{ | |
"boot_command": [ | |
"<wait><esc><esc>", | |
"linux ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos7.ks<enter>" | |
], | |
"boot_wait": "10s", | |
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", | |
"guest_os_type": "RedHat_64", | |
"headless": false, | |
"http_directory": "http", | |
"iso_checksum": "{{ user `iso_checksum` }}", | |
"iso_checksum_type": "{{ user `iso_checksum_type` }}", | |
"iso_url": "{{ user `iso_url` }}", | |
"shutdown_command": "sudo -S shutdown -P now", | |
"ssh_password": "{{ user `ssh_password` }}", | |
"ssh_port": 22, | |
"ssh_username": "{{ user `ssh_username` }}", | |
"ssh_timeout": "10m", | |
"type": "virtualbox-iso", | |
"vboxmanage": [ | |
[ | |
"modifyvm", | |
"{{.Name}}", | |
"--memory", | |
"2048" | |
], | |
[ | |
"modifyvm", | |
"{{.Name}}", | |
"--cpus", | |
"2" | |
] | |
], | |
"virtualbox_version_file": ".vbox_version", | |
"vm_name": "centos7-box" | |
} | |
], | |
"provisioners": [ | |
{ | |
"override": { | |
"virtualbox-iso": { | |
"execute_command": "echo 'vagrant'|sudo -S bash '{{.Path}}'" | |
} | |
}, | |
"expect_disconnect": true, | |
"scripts": [ | |
"{{user `scripts_dir`}}/update.sh", | |
"{{user `scripts_dir`}}/base.sh", | |
"{{user `scripts_dir`}}/vagrant.sh", | |
"{{user `scripts_dir`}}/virtualbox.sh", | |
"{{user `scripts_dir`}}/cleanup.sh" | |
], | |
"start_retry_timeout": "2m", | |
"type": "shell" | |
} | |
], | |
"post-processors": [ | |
{ | |
"output": "./box/{{.Provider}}/{{user `iso_name`}}-{{user `version`}}.box", | |
"type": "vagrant" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lang en_US.UTF-8 | |
keyboard us | |
rootpw --plaintext vagrant --lock | |
authconfig --enableshadow --passalgo=sha512 | |
timezone Etc/UTC --isUtc | |
install | |
cdrom | |
network --onboot yes --bootproto=dhcp --device=enp0s3 --noipv6 --activate | |
firewall --enabled --service=ssh | |
selinux --disabled | |
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" | |
text | |
skipx | |
zerombr | |
clearpart --all --initlabel | |
autopart | |
firstboot --disabled | |
user --name=vagrant --groups=wheel --password=vagrant | |
reboot | |
%packages | |
@^minimal | |
@core | |
sudo | |
%end | |
%post | |
/bin/cat << EOF > /etc/sudoers.d/wheel | |
Defaults:%wheel env_keep += "SSH_AUTH_SOCK" | |
Defaults:%wheel !requiretty | |
%wheel ALL=(ALL) NOPASSWD:ALL | |
EOF | |
/bin/chmod 0440 /etc/sudoers.d/wheel | |
/bin/echo 'UseDNS no' >> /etc/ssh/sshd_config | |
%end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2017/03/19 17:43:02 ui: virtualbox-iso: python-firewall.noarch 0:0.4.3.2-8.1.el7_3.2 | |
2017/03/19 17:43:02 ui: virtualbox-iso: python-perf.x86_64 0:3.10.0-514.10.2.el7 | |
2017/03/19 17:43:02 ui: virtualbox-iso: selinux-policy.noarch 0:3.13.1-102.el7_3.15 | |
2017/03/19 17:43:02 ui: virtualbox-iso: selinux-policy-targeted.noarch 0:3.13.1-102.el7_3.15 | |
2017/03/19 17:43:02 ui: virtualbox-iso: sudo.x86_64 0:1.8.6p7-21.el7_3 | |
2017/03/19 17:43:02 ui: virtualbox-iso: systemd.x86_64 0:219-30.el7_3.7 | |
2017/03/19 17:43:02 ui: virtualbox-iso: systemd-libs.x86_64 0:219-30.el7_3.7 | |
2017/03/19 17:43:02 ui: virtualbox-iso: systemd-sysv.x86_64 0:219-30.el7_3.7 | |
2017/03/19 17:43:02 ui: virtualbox-iso: tuned.noarch 0:2.7.1-3.el7_3.1 | |
2017/03/19 17:43:02 ui: virtualbox-iso: tzdata.noarch 0:2017a-1.el7 | |
2017/03/19 17:43:02 ui: virtualbox-iso: vim-minimal.x86_64 2:7.4.160-1.el7_3.1 | |
2017/03/19 17:43:02 ui: virtualbox-iso: wpa_supplicant.x86_64 1:2.0-21.el7_3 | |
2017/03/19 17:43:02 ui: virtualbox-iso: xfsprogs.x86_64 0:4.5.0-9.el7_3 | |
2017/03/19 17:43:02 ui: virtualbox-iso: | |
2017/03/19 17:43:02 ui: virtualbox-iso: Complete! | |
2017/03/19 17:43:02 ui: virtualbox-iso: Rebooting the machine... | |
2017/03/19 17:50:50 packer: 2017/03/19 17:50:50 Received interrupt signal (count: 1). Ignoring. | |
2017/03/19 17:50:50 packer: 2017/03/19 17:50:50 Received interrupt signal (count: 1). Ignoring. | |
2017/03/19 17:50:50 packer: 2017/03/19 17:50:50 Received interrupt signal (count: 1). Ignoring. | |
2017/03/19 17:50:50 Stopping build: virtualbox-iso |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "==> Applying updates" | |
yum -y update | |
# Reboot | |
echo "Rebooting the machine..." | |
systemctl stop network | |
shutdown -r now | |
sleep 60 |
The VM reboots as expected, but packer never reconnects to it. The log doesn't even look like packer notices the reboot. In the packer.log above, I only included the parts around the reboot. You can see yum finish up and the reboot at 17:43:02. I terminated the build via ctrl-c at 17:50:50
hello,I came into the same problem, what is your final solution about rebooting?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sakura:centos-7-1611-baseimage ktstevenson$ packer version
Packer v0.12.3
Sakura:centos-7-1611-baseimage ktstevenson$ VBoxManage --version
5.1.18r114002
macOS Sierra v10.12.3