Packer seems to hang waiting for shell to be available

1,845 views
Skip to first unread message

Elhanan Maayan

unread,
Nov 27, 2016, 6:44:16 AM11/27/16
to Packer
hi..

i'm trying packer to create an ova template (instead of using vmware studio)  using this template file i've downloaded and modified.:

the first problem begins after installation of the packages, and before the provisioning scripts, packer seems to wait forever for the shell server to be available, which doesn't happen until i actually log in into on shell on vsphere console. 


{
"builders": [{
"type": "vmware-iso",
"guest_os_type": "centos-64",
"iso_url": "iso/CentOS-7-x86_64-Minimal-1511.iso",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"output_directory": "output-centos-7.2-x86_64-{{build_type}}",
"vm_name": "packer-centos-7.2-x86_64",
"disk_size": "{{user `disk_size`}}",
"headless": "{{user `headless`}}",
"http_directory": "http",
"boot_wait": "5s",
"boot_command": [
"<esc>",
"<wait>",
"linux inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/anaconda-ks.cfg biosdevname=0 net.ifnames=0",
"<enter>"
],
"ssh_timeout": "{{user `ssh_timeout`}}",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"tools_upload_flavor": "linux",
"shutdown_command": "sudo systemctl poweroff",
"remote_type": "esx5",
"remote_host": "vmstudio-host",
"remote_username": "root",
"remote_password": "Aeroscout123",
"format": "ova",
"vmx_data": {
"cpuid.coresPerSocket": "1",
"memsize": "{{user `memory`}}",
"numvcpus": "{{user `cpus`}}",
"ethernet0.networkName": "VM Network",
"ethernet0.present": "TRUE"
}
}
],
"provisioners": [{
"type": "shell",
"scripts": [
"scripts/centos-7.2/repo.sh",
"scripts/centos/virtualbox.sh",
"scripts/centos/vmware.sh",
"scripts/common/vagrant.sh",
"scripts/common/sshd.sh",
"scripts/centos-7.2/locale.sh",
"scripts/centos-7.2/cleanup.sh",
"scripts/common/minimize.sh" 
]
}
],
"variables": {
"compression_level": "6",
"cpus": "2",
"disk_size": "40000",
"headless": "false",
"iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284",
"iso_checksum_type": "sha256",
"memory": "4096",
"ssh_timeout": "60m"
}
}



Elhanan Maayan

unread,
Nov 27, 2016, 7:24:08 AM11/27/16
to Packer
keeps saying :
 starting remote command: esxcli --formatter csv network vm port list -w 5763554
 [DEBUG] Error getting SSH address: No interface on the VM has an IP address ready
 opening new ssh session
 starting remote command: esxcli --formatter csv network vm list

Rickard von Essen

unread,
Nov 27, 2016, 8:28:35 AM11/27/16
to packe...@googlegroups.com
Could you share your kickstart file.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/7a4a6199-bc2c-422c-9363-9bdd24cb619f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Elhanan Maayan

unread,
Nov 27, 2016, 9:28:33 AM11/27/16
to Packer
shared...
anaconda-ks.cfg

Alvaro Miranda Aguilera

unread,
Nov 27, 2016, 10:50:07 AM11/27/16
to packe...@googlegroups.com
you are missing the network part so the installation can run.

2 options.

1. set in the ks a line to set a fixed ip, and tell packer use that
2. update packer to use a floppy and make boot to read the ks from there.

If your network does have dhcp, then is something easier

3. make ks to setup eth0 for dhcp

in the ks, on top before %packages:
network --onboot yes --device eth0 --mtu=1500 --bootproto dhcp




--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/7a4a6199-bc2c-422c-9363-9bdd24cb619f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Elhanan Maayan

unread,
Nov 27, 2016, 11:10:41 AM11/27/16
to Packer
thanks, i'll try that, meanwhile i've been digging around, trying to find out specific minimal ks files for centos, it would seem the the --nodefaults has a bug, which is makes it being ignored, so i also changed a few other stuff 
i've included the dracut package as it seems to generate ifcfg with eth0

and disabled the manual generation of the file as well as the network interface mapping 
(i've disabled the yum command just to save time for now) 

install
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
rootpw --plaintext vagrant
user --name=vagrant --groups=vagrant --password=vagrant --plaintext
auth --useshadow --enablemd5
selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
ignoredisk --only-use=sda
reboot

bootloader --location=mbr
zerombr
clearpart --all --initlabel
autopart --type=plain


network --onboot yes --device eth0 --mtu=1500 --bootproto dhcp

%packages --nobase --ignoremissing
@core --nodefaults
-*-firmware
-iprutils
-plymouth
-avahi
%end

%post --erroronfail
#yum -y update

cat <<EOF > /etc/sudoers.d/vagrant
Defaults:vagrant !requiretty
vagrant ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/vagrant

%end
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 27, 2016, 11:40:06 AM11/27/16
to packe...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/3c99923b-0850-4fb3-970c-1e524f5f3df1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Elhanan Maayan

unread,
Nov 27, 2016, 11:59:09 AM11/27/16
to Packer
thanks, now it seems that it does manages to do re-connnect after boot, but fails later, i don't know why, cause it always shuts down and deletes the machine. i just see that shutdown as returned with a non 0 value.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 27, 2016, 12:26:13 PM11/27/16
to packe...@googlegroups.com
PACKER_LOG=1 packer build template.json

and share a gist of the logs

if its failing on one script you can add to each script:

#!/usr/bin/env bash -x
set -e


and with that you could get whats going on

i have esxi next to me if you put your project in github i can give it a go.. be sure to not put any password/secret on it

alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/9d30e834-5fc4-4b09-a88e-d124b7a00400%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Rickard von Essen

unread,
Nov 27, 2016, 12:39:02 PM11/27/16
to packe...@googlegroups.com

Also run with the --on-error=ask option for Packer build.


Elhanan Maayan

unread,
Nov 27, 2016, 12:40:37 PM11/27/16
to Packer
actualy each script allready has 

#!/bin/bash

set -e
set -x 

and i'm allready using packer_log=1 but i'll try the on error

the strange thing is that it seems to executing all the scripts , i can see the finaly one being executed:

if rpm -q --whatprovides kernel | grep -Fqv "$(uname -r)"; then
  rpm -q --whatprovides kernel | grep -Fv "$(uname -r)" | xargs sudo yum -y autoremove
fi

sudo yum --enablerepo=epel clean all
sudo yum history new
sudo truncate -c -s 0 /var/log/yum.log 



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 27, 2016, 12:57:59 PM11/27/16
to packe...@googlegroups.com

On Sun, Nov 27, 2016 at 6:40 PM, Elhanan Maayan <elh.m...@gmail.com> wrote:

if rpm -q --whatprovides kernel | grep -Fqv "$(uname -r)"; then
  rpm -q --whatprovides kernel | grep -Fv "$(uname -r)" | xargs sudo yum -y autoremove
fi

sudo yum --enablerepo=epel clean all
sudo yum history new
sudo truncate -c -s 0 /var/log/yum.log 



comment that out and see what happens

for the kernel part, there is a more elegant wayt to do the same

just check /etc/yum.conf and change the parameter for 3 kernel to 2 or 1




--
Alvaro

Elhanan Maayan

unread,
Nov 27, 2016, 1:12:16 PM11/27/16
to Packer
actually those scripts that came with the github template , so i havn't reached the being elegant part 

it seems it managed t execute them all:
2016/11/27 20:07:47 ui:     vmware-iso: Loaded plugins: fastestmirror
    vmware-iso: Loaded plugins: fastestmirror
2016/11/27 20:07:48 ui:     vmware-iso: history new
    vmware-iso: history new
2016/11/27 20:07:48 ui:     vmware-iso: + sudo truncate -c -s 0 /var/log/yum.log
    vmware-iso: + sudo truncate -c -s 0 /var/log/yum.log
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 [INFO] RPC endpoint: Communicator ended with: 0
2016/11/27 20:07:48 [INFO] RPC client: Communicator ended with: 0
2016/11/27 20:07:48 [INFO] 1318 bytes written for 'stdout'
2016/11/27 20:07:48 [INFO] RPC endpoint: Communicator ended with: 0
2016/11/27 20:07:48 [INFO] 297 bytes written for 'stderr'
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 [INFO] RPC client: Communicator ended with: 0
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 [INFO] 1318 bytes written for 'stdout'
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 [INFO] 297 bytes written for 'stderr'
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 opening new ssh session
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 starting remote command: rm -f /tmp/script_4501.sh
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 [INFO] RPC endpoint: Communicator ended with: 0
2016/11/27 20:07:48 [INFO] RPC client: Communicator ended with: 0
2016/11/27 20:07:48 [INFO] RPC endpoint: Communicator ended with: 0
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 [INFO] RPC client: Communicator ended with: 0
2016/11/27 20:07:48 ui: ==> vmware-iso: Gracefully halting virtual machine...
==> vmware-iso: Gracefully halting virtual machine...
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 Executing shutdown command: sudo systemctl poweroff
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 opening new ssh session
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 starting remote command: sudo systemctl poweroff
2016/11/27 20:07:49 packer.exe: 2016/11/27 20:07:49 Remote command exited without exit status or exit signal.
2016/11/27 20:07:49 ui: ==> vmware-iso: Step "StepShutdown" failed
==> vmware-iso: Step "StepShutdown" failed
2016/11/27 20:07:49 ui: ask: ==> vmware-iso: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?
==> vmware-iso: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?

Alvaro Miranda Aguilera

unread,
Nov 27, 2016, 1:17:08 PM11/27/16
to packe...@googlegroups.com

On Sun, Nov 27, 2016 at 7:12 PM, Elhanan Maayan <elh.m...@gmail.com> wrote:
2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 starting remote command: sudo systemctl poweroff
2016/11/27 20:07:49 packer.exe: 2016/11/27 20:07:49 Remote command exited without exit status or exit signal.
2016/11/27 20:07:49 ui: ==> vmware-iso: Step "StepShutdown" failed
==> vmware-iso: Step "StepShutdown" failed
2016/11/27 20:07:49 ui: ask: ==> vmware-iso: [c]

seems the exit code of the shutdown command is not giving a proper exit code:

2016/11/27 20:07:48 packer.exe: 2016/11/27 20:07:48 starting remote command: sudo systemctl poweroff
2016/11/27 20:07:49 packer.exe: 2016/11/27 20:07:49 Remote command exited without exit status or exit signal.
2016/11/27 20:07:49 ui: ==> vmware-iso: Step "StepShutdown" failed
==> vmware-iso: Step "StepShutdown" failed
2016/11/27 20:07:49 ui: ask: ==> vmware-iso: [c] 


Try the bento one
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/halt -h -p",



--
Alvaro

Elhanan Maayan

unread,
Nov 28, 2016, 4:46:01 AM11/28/16
to Packer
same thing, still no exit status or exit signal, is there anyway to test without actually shutting down the machine or going though the whole process? 

Elhanan Maayan

unread,
Nov 28, 2016, 4:53:21 AM11/28/16
to Packer

Elhanan Maayan

unread,
Nov 28, 2016, 6:05:13 AM11/28/16
to Packer
seems like version 12 resolved it: 

==> vmware-iso: Gracefully halting virtual machine...
2016/11/28 12:59:40 ui: ==> vmware-iso: Gracefully halting virtual machine...
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 Executing shutdown command: echo 'vagrant' | sudo -S /sbin/halt -h -p
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 opening new ssh session
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 starting remote command: echo 'vagrant' | sudo -S /sbin/halt -h -p
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 Remote command exited without exit status or exit signal.
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 Shutdown stdout:
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 Shutdown stderr:
2016/11/28 12:59:40 packer.exe: 2016/11/28 12:59:40 Waiting max 5m0s for shutdown to complete

so i finally have an ova, so next steps, is to figure out what on earth i'm doing, and how to minimize those packages.. 
then figure out how to automatically install webmin, configure it, for minimum permissions etc.. 
Reply all
Reply to author
Forward
0 new messages