qemu: Waiting for SSH to become available... prob with CentOS 6.9

908 views
Skip to first unread message

Dan MacDonald

unread,
Nov 22, 2017, 10:37:09 AM11/22/17
to Packer
Hi Packer list

I'm new to Packer and I've not been able able to get it to produce a qemu/kvm image successfully yet. My host system is Ubuntu 17.10 amd64 (ufw firewall is disabled) running packer 1.1.1 and I am trying to create an image from CentOS 6.9 - I have tried both the minimal and full DVD CentOS ISOs.

When I run:

packer build centos6-kvm.json

CentOS boots, it installs fine then it powers the VM off and all I am left with is the message:

qemu: Waiting for SSH to become available...

SSH never does become available so I have to kill packer.

I have searched these groups for similar issues. I noticed someone else having this same same issue with qemu/KVM but that user didn't post their solution, if they ever did get it to work. I tried to deviate from the given example configs as little as possible.

Here are my current configs:

centos6-kvm.json:

{
  "builders":
  [
    {
      "type": "qemu",
      "iso_url": "/home/dan/Downloads/CentOS-6.9-x86_64-minimal.iso",
      "iso_checksum": "af4a1640c0c6f348c6c41f1ea9e192a2",
      "iso_checksum_type": "md5",
      "output_directory": "output_centos6test",
      "shutdown_command": "shutdown -P now",
      "disk_size": 5000,
      "format": "qcow2",
      "headless": false,
      "accelerator": "kvm",
      "http_directory": "/var/www/html/",
      "http_port_min": 10082,
      "http_port_max": 10089,
      "ssh_host_port_min": 2222,
      "ssh_host_port_max": 2229,
      "ssh_username": "root",
      "ssh_password": "longishpassword",
      "ssh_wait_timeout": "10000s",
      "vm_name": "c6test",
      "net_device": "virtio-net",
      "disk_interface": "virtio",
      "boot_wait": "5s",
      "boot_command": [
        "<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg<enter><wait>"
      ]
    }
  ]
}




centos6-ks.cfg:

text
skipx
install
url --url http://mirrorservice.org/sites/mirror.centos.org/6/os/x86_64/
repo --name=updates --baseurl=http://mirrorservice.org/sites/mirror.centos.org/6/updates/x86_64/
lang en_US.UTF-8
keyboard us
rootpw longishpassword
firewall --disable
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Etc/UTC
%include /tmp/kspre.cfg

services --enabled=network,sshd/sendmail

poweroff

%packages --nobase
at
acpid
cronie-noanacron
crontabs
logrotate
mailx
mlocate
openssh-clients
openssh-server
rsync
sendmail
tmpwatch
vixie-cron
which
wget
yum
-biosdevname
-postfix
-prelink
%end

%pre
bootdrive=vda

if [ -f "/dev/$bootdrive" ] ; then
  exec < /dev/tty3 > /dev/tty3
  chvt 3
  echo "ERROR: Drive device does not exist at /dev/$bootdrive!"
  sleep 5
  halt -f
fi

cat >/tmp/kspre.cfg <<CFG
zerombr
bootloader --location=mbr --driveorder=$bootdrive --append="nomodeset"
clearpart --all --initlabel
part /boot --ondrive=$bootdrive --fstype ext4 --fsoptions="relatime,nodev" --size=512
part pv.1 --ondrive=$bootdrive --size 1 --grow
volgroup vg0 pv.1
logvol / --fstype ext4 --fsoptions="noatime,nodiratime,relatime,nodev" --name=root --vgname=vg0 --size=4096
logvol swap --fstype swap --name=swap --vgname=vg0 --size 1 --grow
CFG

%end

%post

%end

Alvaro Miranda Aguilera

unread,
Nov 23, 2017, 3:47:58 AM11/23/17
to packe...@googlegroups.com
hello

the OS install need to create a user/pass that can login ideally with sudo access so you don't use root

or you can just use root / longishpassword

and then usually reboots to ensure the ssh service is up


so this:

CentOS boots, it installs fine then it powers the VM off and all I am left with is the message:

Tell us its not doing whats needed.


replace

  services --enabled=network,sshd/sendmail
  poweroff
  %packages --nobase

with

  services --enabled=network,sshd/sendmail
  reboot
  %packages --nobase




reboot (optional)
Reboot after the installation is successfully completed (no arguments). Normally, kickstart displays a message and waits for the user to press a key before rebooting.
The reboot option is equivalent to the shutdown -r command.
Specify reboot to automate installation fully when installing in cmdline mode on System z.
For other completion methods, refer to the haltpoweroff, and shutdown kickstart options.

Alvaro.


--
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/706eb33e-ec7d-4f1d-98ae-f87bbfbc451e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Dan MacDonald

unread,
Nov 23, 2017, 4:34:44 AM11/23/17
to packe...@googlegroups.com
Hi Alvaro

I knew it would be something simple! As you said, changing `poweroff`
to `reboot` in the kickstart file has got me past the `qemu: Waiting
for SSH to become available...` and has fixed image creation.

I wasn't clear to me from the Packer docs whether the kickstart should
be performing this reboot or if packer would do it (via qemu) but
seeing as the example kickstart file used `poweroff` I just presumed
that that was the correct option and that packer/qemu would fire the
VM back up.

The kickstart file that I used as an example is linked on
https://www.packer.io/docs/builders/qemu.html , the exact link being
https://gist.github.com/mitchellh/7328271/#file-centos6-ks-cfg

I would like to see that kickstart example replaced or updated with
one that uses `reboot` in place of `poweroff` and whilst we're it at
it should replace the repo/url URLs with more sensible defaults (such
as the ones I'm using) that will 'just work' for everyone.

Do I need to report this as a bug?

Thanks Alvaro!
>> email to packer-tool...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/packer-tool/706eb33e-ec7d-4f1d-98ae-f87bbfbc451e%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Alvaro
>
> --
> 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 a topic in the
> Google Groups "Packer" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/packer-tool/y12sAqRcttE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> packer-tool...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/CAHqq0exgL1TWOeoZg%3DFVfQiH4q%3DjQ2VnwLXLK%2BHazfCKLUKbrQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages