Skip to content

Instantly share code, notes, and snippets.

@necrolyte2
Created April 7, 2017 14:13
Show Gist options
  • Save necrolyte2/6d1909724cc5af35e8e4d5aebdba3ac8 to your computer and use it in GitHub Desktop.
Save necrolyte2/6d1909724cc5af35e8e4d5aebdba3ac8 to your computer and use it in GitHub Desktop.
Packer ssh_timeout issue
qemu output will be in this color.
==> qemu: Downloading or copying ISO
 qemu: Downloading or copying: https://binrepo.target.com/artifactory/cpe-image-build-virtmetal/openstack/tgt-cpe-base-os/tgt-cpe-base-os-v1.0.1.qcow2
==> qemu: Copying hard drive...
==> qemu: Resizing hard drive...
==> qemu: Found port for communicator (SSH, WinRM, etc): 2226.
==> qemu: Looking for available port between 5900 and 6000 on 127.0.0.1
==> qemu: Starting VM, booting disk image
 qemu: WARNING: The version of qemu on your host doesn't support display mode.
qemu: The display parameter will be ignored.
==> qemu: Overriding defaults Qemu arguments with QemuArgs...
==> qemu: Waiting 5s for boot...
==> qemu: Connecting to VM via VNC
==> qemu: Typing the boot command over VNC...
==> qemu: Waiting for SSH to become available...
==> qemu: Connected to SSH!
==> qemu: Provisioning with shell script: /tmp/packer-shell613111759
 qemu: ChallengeResponseAuthentication yes
 qemu: UsePAM yes
 qemu: Protocol 2
 qemu: LogLevel INFO
 qemu: X11Forwarding no
 qemu: MaxAuthTries 3
 qemu: IgnoreRhosts yes
 qemu: PermitEmptyPasswords no
 qemu: PermitUserEnvironment no
 qemu: ClientAliveInterval 300
 qemu: ClientAliveCountMax 0
 qemu: Banner /etc/issue
 qemu: SyslogFacility AUTHPRIV
 qemu: PasswordAuthentication yes
 qemu: GssapiAuthentication yes
 qemu: GssapiCleanUpCredentials yes
 qemu: PrintMotd yes
 qemu: Subsystem sftp /usr/libexec/openssh/sftp-server
 qemu: Acceptenv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL LANGUAGE XMODIFIERS
 qemu: MACs hmac-ripemd160,hmac-sha2-256,hmac-sha2-512
 qemu: PermitRootLogin no
 qemu: Ciphers aes128-ctr,aes192-ctr,aes256-ctr
 qemu: DenyUsers bin
 qemu: DenyUsers daemon
 qemu: DenyUsers adm
 qemu: DenyUsers lp
 qemu: DenyUsers mail
 qemu: DenyUsers uucp
 qemu: DenyUsers operator
 qemu: DenyUsers games
 qemu: DenyUsers gopher
 qemu: DenyUsers ftp
 qemu: DenyUsers nobody
 qemu: DenyUsers vcsa
 qemu: DenyUsers rpc
 qemu: DenyUsers saslauth
 qemu: DenyUsers postfix
 qemu: DenyUsers rpcuser
 qemu: DenyUsers nfsnobody
 qemu: DenyUsers sshdChallengeResponseAuthentication yes
 qemu: UsePAM yes
 qemu: Protocol 2
 qemu: LogLevel INFO
 qemu: X11Forwarding no
 qemu: MaxAuthTries 3
 qemu: IgnoreRhosts yes
 qemu: PermitEmptyPasswords no
 qemu: PermitUserEnvironment no
 qemu: ClientAliveInterval 3600
 qemu: ClientAliveCountMax 0
 qemu: Banner /etc/issue
 qemu: SyslogFacility AUTHPRIV
 qemu: PasswordAuthentication yes
 qemu: GssapiAuthentication yes
 qemu: GssapiCleanUpCredentials yes
 qemu: PrintMotd yes
 qemu: Subsystem sftp /usr/libexec/openssh/sftp-server
 qemu: Acceptenv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL LANGUAGE XMODIFIERS
 qemu: MACs hmac-ripemd160,hmac-sha2-256,hmac-sha2-512
 qemu: PermitRootLogin no
 qemu: Ciphers aes128-ctr,aes192-ctr,aes256-ctr
 qemu: DenyUsers bin
 qemu: DenyUsers daemon
 qemu: DenyUsers adm
 qemu: DenyUsers lp
 qemu: DenyUsers mail
 qemu: DenyUsers uucp
 qemu: DenyUsers operator
 qemu: DenyUsers games
 qemu: DenyUsers gopher
 qemu: DenyUsers ftp
 qemu: DenyUsers nobody
 qemu: DenyUsers vcsa
 qemu: DenyUsers rpc
 qemu: DenyUsers saslauth
 qemu: DenyUsers postfix
 qemu: DenyUsers rpcuser
 qemu: DenyUsers nfsnobody
 qemu: DenyUsers sshd
==> qemu: Provisioning with shell script: sleep.sh
 qemu: + sleep_time_minutes=10
 qemu: + echo 'Sleeping for 10 minutes'
 qemu: Sleeping for 10 minutes
 qemu: + sleep 600
==> qemu: Provisioning with shell script: test.sh
 qemu: + echo 'Doing some stuff'
 qemu: Doing some stuff
 qemu: + sleep 5
 qemu: + echo 'Done doing stuff'
 qemu: Done doing stuff
==> qemu: Gracefully halting virtual machine...
==> qemu: Converting hard drive...
Build 'qemu' finished.
==> Builds finished. The artifacts of successful builds are:
--> qemu: VM files in directory: output_worker
#!/bin/bash
set -eux
sleep_time_minutes=10
echo "Sleeping for $sleep_time_minutes minutes"
sleep $(($sleep_time_minutes * 60))
echo "Done sleeping"
{
"variables": {
},
"builders": [{
"type": "qemu",
"machine_type": "rhel6.6.0",
"qemu_binary": "/usr/libexec/qemu-kvm",
"iso_url": "somebaseimage.qcow2",
"iso_checksum": "md5sum",
"iso_checksum_type": "md5",
"output_directory": "output_worker",
"shutdown_command": "sudo /sbin/shutdown -P now",
"disk_size": 122880,
"format": "qcow2",
"headless": false,
"accelerator": "kvm",
"ssh_host_port_min": 2222,
"ssh_host_port_max": 2229,
"ssh_username": "centos",
"ssh_password": "password",
"ssh_port": 22,
"ssh_wait_timeout": "20m",
"vm_name": "cpe-metal-k8s-worker",
"net_device": "virtio-net",
"disk_interface": "virtio",
"disk_image": "true",
"boot_wait": "5s",
"boot_command":[],
"qemuargs": [
[ "-m", "1024M"],
[ "-cdrom", "seed.iso" ]
]
}],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo cat /etc/ssh/sshd_config",
"sudo sed -i 's/ClientAliveInterval.*/ClientAliveInterval 3600/' /etc/ssh/sshd_config",
"sudo cat /etc/ssh/sshd_config"
]
},
{
"type": "shell",
"start_retry_timeout": "20m",
"environment_vars": [
],
"expect_disconnect": true,
"execute_command": "echo 'cloud-user' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"sleep.sh",
"test.sh"
]
}
]
}
#!/bin/bash
set -eux
echo "Doing some stuff"
sleep 5
echo "Done doing stuff"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment