Git Product home page Git Product logo

goffinet / packer-kvm Goto Github PK

View Code? Open in Web Editor NEW
192.0 7.0 60.0 285 KB

Create VM templates with Packer for usage with Libvirt/KVM virtualization : CentOS 7, CentOS 8/9 Stream, Alma Linux 8/9, Rocky Linux 8, Bionic (Ubuntu 1804), Focal (Ubuntu 2004), Jammy (Ubuntu 2204), Debian 11 (stable), Kali Linux, Fedora.

Home Page: https://linux.goffinet.org

License: MIT License

Shell 15.02% Dockerfile 0.27% HCL 84.71%
packer kvm kickstart qemu-kvm qemu packer-template kvm-virtualization packer-kvm fedora qcow2

packer-kvm's Introduction

packer-kvm

Create VM templates with Packer for usage with Libvirt/KVM virtualization : CentOS 7, CentOS 8 (Stream), CentOS 9 (Stream), Alma Linux 8, Alma Linux 9, Rocky Linux 8, Bionic (Ubuntu 1804), Focal (Ubuntu 2004), Jammy (Ubuntu 2204), Debian 11 (stable), Kali Linux, Fedora 35.

Only for education and learning purposes. Do not use it in production.

Packer Concepts

Packer is an open source tool for creating identical machine images for multiple platforms from a single source configuration called a template. (Introduction to Packer, What is Packer?). It uses different plugins as builders, provisioners or post-processors.

While the JSON format template is still supported, certain new features in the Packer core will only be implemented for the newer HCL2 format. Therefore, this project has been updated to HCL2.

Builders are responsible for creating machines and generating images from them for various platforms. For example, there are separate builders for EC2, VMware, VirtualBox, Qemu, etc. Packer comes with many builders by default, and can also be extended to add new builders. (Builders)

Packer can enable an http server to serve kickstart, preseed or cloud-init configuration files at boot.

Provisioners use builtin and third-party software to install and configure the machine image after booting. (Provisioners)

Post-processors run after the image is built by the builder and provisioned by the provisioner(s). (Post-Processors)

Proof of Concept to generate Linux qemu images

This is a Packer "Proof of Concept" with :

  • qemu/kvm as image builder (qcow2)
  • "shell" and "ansible-local" as provisionners
  • "shell-local" as post-processor to generate a gns3a appliance file, checksum and upload to a server

Optionnal :

  • run this inside a docker container
  • build your own container

Enjoy those images with :

  • Libvirt native tools
  • Terraform as IaC tool with a third party Libvirtd Provider plugin

The built images are intended to be published on a S3 bucket.

Pre-requisites

The run this project with success, you need a virtualization server and some softwares installed :

  • Libvirt/KVM, Packer and aws s3 cli
  • Docker (to run the build inside a container)

Use ./setup.sh for a quick setup of Libvirt/KVM, Packer and aws s3 cli but please read before the following manual instructions.

For Docker usage, install it and put your aws S3 credits in your ~/.profile.

Anyway, you can remove the post-processor in your image JSON template to avoid S3 upload attemps.

AWS S3

Configure your S3 credits :

echo "export AWS_ACCESS_KEY=<your AWS_ACCESS_KEY>" >> ~/.profile
echo "export AWS_SECRET_KEY=<your AWS_SECRET_KEY>" >> ~/.profile
source ~/.profile

Libvirt and Packer

Install Livirt/KVM on your server :

if [ -f /etc/debian_version ]; then
apt-get update && apt-get -y upgrade
apt-get -y install qemu-kvm libvirt-dev virtinst virt-viewer libguestfs-tools virt-manager uuid-runtime curl linux-source libosinfo-bin
virsh net-start default
virsh net-autostart default
elif [ -f /etc/redhat-release ]; then
yum -y install epel-release
yum -y upgrade
yum -y group install "Virtualization Host"
yum -y install virt-manager libvirt virt-install qemu-kvm xauth dejavu-lgc-sans-fonts virt-top libguestfs-tools virt-viewer virt-manager curl
ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-system-x86_64
fi

Install the Packer binary :

yum -y install wget unzip || apt update && apt -y install wget unzip
latest=$(curl -L -s https://releases.hashicorp.com/packer | grep 'packer_' | sed 's/^.*<.*\">packer_\(.*\)<\/a>/\1/' | head -1)
wget https://releases.hashicorp.com/packer/${latest}/packer_${latest}_linux_amd64.zip
unzip packer*.zip
chmod +x packer
mv packer /usr/local/bin/

Docker

Get Docker and docker-compose :

curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
if [ -f /etc/debian_version ]; then
apt-get update && apt-get -y install python3-pip
elif [ -f /etc/redhat-release ]; then
yum -y install python3-pip
fi
pip3 install docker-compose

Build with Packer

Each JSON file is a template for a distribution :

For example :

packer build centos7.pkr.hcl

Build with Docker qemu based image

goffinet/packer-qemu is a Docker image for building qemu images with packer and is available on Docker Hub.

docker run --rm \
  -e PACKER_LOG=1 \
  -e PACKER_LOG_PATH="packer-docker.log" \
  -it \
  --privileged \
  --cap-add=ALL -v /lib/modules:/lib/modules \
  -v `pwd`:/opt/ \
  -e AWS_ACCESS_KEY=$AWS_ACCESS_KEY \
  -e AWS_SECRET_KEY=$AWS_SECRET_KEY \
  -w /opt/ goffinet/packer-qemu build centos7.pkr.hcl

The script build.sh do it with the template filename as first argument.

./build.sh centos7.pkr.hcl

To build the image localy with the Dockerfile :

docker build -t packer-qemu .

Packing monitoring

Packer use VNC to launch a temporary VM, you can check this window with a VNC client like vinagre.

You can have more details from Packet with the env var configured : PACKER_LOG=1.

Cloud images for qemu/KVM/Libvirt built with Packer

I build images for qemu/KVM with this project and I publish them for use in those other IaC projects: Virt-scripts and Terraform with Libvirt/KVM provider.

You can easily download them to /var/lib/libvirt/images with this script :

curl -s -o /usr/local/bin/download-images.sh https://raw.githubusercontent.com/goffinet/virt-scripts/master/download-images.sh
chmod +x /usr/local/bin/download-images.sh
download-images.sh

How to exploit those built images

How to exploit those built images?

  • In the old way with Libvirt and some bash scripts
  • In a beter way with a tool like Terraform

This is always beter to know how Libvirt is working. Can you read fundamentals about KVM virtualization in french.

Enjoy with Libvirt

https://github.com/goffinet/virt-scripts

  1. Clone virt-scripts repo and prepare the machine
sudo apt update && apt -y install git
git clone https://github.com/goffinet/virt-scripts
cd virt-scripts
sudo ./autoprep.sh
  1. Build or download images

Put builded images in /var/lib/libvirt/images or download them :

sudo ./download-images.sh
Please provide the image name :
centos7 bionic debian11
  1. Launch two new machines
sudo ./define-guest-image.sh c1 centos7
sudo ./define-guest-image.sh u1 bionic
  1. Enjoy
sudo virsh console u1
ssh $(dig @192.168.122.1 +short u1)

Enjoy with Terraform (with libvirt)

https://github.com/goffinet/terraform-libvirt

Install Terraform 0.13 with a third party Libvirt provider plugin :

echo "security_driver = \"none\"" >> /etc/libvirt/qemu.conf
systemctl restart libvirtd
sudo yum -y install wget unzip || sudo apt update && sudo apt -y install wget unzip
wget https://releases.hashicorp.com/terraform/0.13.2/terraform_0.13.2_linux_amd64.zip
unzip terraform_0.13.2_linux_amd64.zip
chmod +x terraform
mv terraform /usr/local/bin/
wget https://github.com/dmacvicar/terraform-provider-libvirt/releases/download/v0.6.2/terraform-provider-libvirt-0.6.2+git.1585292411.8cbe9ad0.Ubuntu_18.04.amd64.tar.gz
tar xvf terraform-provider-libvirt-0.6.2+git.1585292411.8cbe9ad0.Ubuntu_18.04.amd64.tar.gz
mkdir -p ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64
cp -r terraform-provider-libvirt ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64/

Compose your libvirt infrastructure :

git clone https://github.com/goffinet/terraform-libvirt
cd terraform-libvirt/ubuntu_cloudinit
terraform plan
cd ../count
terraform plan

Customization

To customize post-processing

The scripts/push-image.sh generate somme meta-data and push the generated image to a pre-defined S3 Bucket.

To customize this process, you can change the content as it :

#!/bin/bash

name=$IMAGE_NAME
version=$IMAGE_VERSION
image="${name}${version}"
echo "artifacts/qemu/${image} post-processing ..."

Anyway, you can remove the post-processor in your image JSON template to avoid this script call.

Customize SSH keys

To generate the ssh keys for provisionning and put it in the sshkeys/ folder :

ssh-keygen -q -t rsa -N '' -C 'packer-kvm-default-key' -f sshkeys/id_rsa

To get the default ssh private key :

curl https://raw.githubusercontent.com/goffinet/packer-kvm/master/sshkeys/id_rsa

To get the default ssh public key :

curl https://raw.githubusercontent.com/goffinet/packer-kvm/master/sshkeys/id_rsa.pub

ToDo

  • unique model : for efficience, a unique template should be sufficient with a data source with these elements.
  • random secret for provisonning (https://www.packer.io/docs/templates/engine#template-variables)
  • Remove swap post-processing
  • docker-compose for automation
  • add versions of post-processing and images meta-datas

Wath are the variants in those templates?

  • the iso_urls and the iso_checksum template parameters
  • the ssh_username, ssh_password and ssh_private_key_file template parameters as well as sshkey in kickstart files.
  • the boot_command as template parameter
  • the configuration file type : kickstart, preseed or cloud-init

Initials credits

packer-kvm's People

Contributors

avnes avatar darkrain42 avatar goffinet avatar leopck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-kvm's Issues

Suggestion to use local mirror for fedora34 template

Hi

Thanks for merging the template for fedora34. I appreciate that. While I was building my own boxes with Fedora 34, I discovered that the url used in fedora34-kickstart.cfg sometimes caused RPM files not to be downloaded. I am not sure why this happened, but the workaround tuned out to be to use a more local mirror than using the mirror selector http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/fedora/linux/releases/34/Everything/x86_64/os/

So the workaround for me was to update fedora34-kickstart.cfg with:

url --url="https://mirrors.dotsrc.org/fedora-buffet/fedora/linux/releases/34/Everything/x86_64/os/"

I suggest you use a URL that is local to you.

Updating packages twice?

You have package updates configured in your kickstart templates under the post section which makes sense, but then you also use an ansible playbook to update packages again as part of provisioner's run. Why?

Unable to build image (Waiting for ssh)

I checked out the code and have tried a number of these and I am get to the same point. The container starts up fine. The ISO is downloaded and verified. The VM starts up and is connected to. The initial boot command with the provided kickstart is passed in. Then the system waits for ssh to connect. And the container just waits.

To eliminate something I did I did a clean checkout of the repo and then ran: ./build.sh centos7.pkr.hcl (the image I am trying to build in the end is a Centos base image)

Here is a sample log file:

2023/05/31 20:32:56 Running builder: 2023/05/31 20:32:56 [INFO] (telemetry) Starting builder 2023/05/31 20:32:56 packer-builder-qemu plugin: Qemu path: /usr/bin/qemu-system-x86_64, Qemu Image path: /usr/bin/qemu-img 2023/05/31 20:32:56 ui: ==> qemu.centos7: Retrieving ISO 2023/05/31 20:32:56 ui: ==> qemu.centos7: Trying http://ftp.belnet.be/mirror/ftp.centos.org/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso 2023/05/31 20:32:56 packer-builder-qemu plugin: Acquiring lock for: http://ftp.belnet.be/mirror/ftp.centos.org/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso?checksum=sha256%3A07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a (/opt/packer_cache/e476ea1d3ef3c2e3966a7081ac4239cd5ae5e8a3.iso.lock) 2023/05/31 20:32:56 ui: ==> qemu.centos7: Trying http://ftp.belnet.be/mirror/ftp.centos.org/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso?checksum=sha256%3A07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a 2023/05/31 20:32:58 ui: ==> qemu.centos7: http://ftp.belnet.be/mirror/ftp.centos.org/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso?checksum=sha256%3A07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a => /opt/packer_cache/e476ea1d3ef3c2e3966a7081ac4239cd5ae5e8a3.iso 2023/05/31 20:32:58 packer-builder-qemu plugin: Leaving retrieve loop for ISO 2023/05/31 20:32:58 packer-builder-qemu plugin: No floppy files specified. Floppy disk will not be made. 2023/05/31 20:32:58 packer-builder-qemu plugin: No CD files specified. CD disk will not be made. 2023/05/31 20:32:58 packer-builder-qemu plugin: [INFO] Creating disk with Path: artifacts/qemu/centos7/packer-centos7 and Size: 40000M 2023/05/31 20:32:58 packer-builder-qemu plugin: Executing qemu-img: []string{"create", "-f", "qcow2", "artifacts/qemu/centos7/packer-centos7", "40000M"} 2023/05/31 20:32:58 packer-builder-qemu plugin: stdout: Formatting 'artifacts/qemu/centos7/packer-centos7', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=41943040000 lazy_refcounts=off refcount_bits=16 2023/05/31 20:32:58 packer-builder-qemu plugin: stderr: 2023/05/31 20:32:58 packer-builder-qemu plugin: Found available port: 8578 on IP: 0.0.0.0 2023/05/31 20:32:58 ui: ==> qemu.centos7: Starting HTTP server on port 8578 2023/05/31 20:32:58 packer-builder-qemu plugin: Looking for available communicator (SSH, WinRM, etc) port between 2222 and 4444 2023/05/31 20:32:58 packer-builder-qemu plugin: Found available port: 2855 on IP: 127.0.0.1 2023/05/31 20:32:58 ui: ==> qemu.centos7: Found port for communicator (SSH, WinRM, etc): 2855. 2023/05/31 20:32:58 ui: ==> qemu.centos7: Looking for available port between 5900 and 6000 on 127.0.0.1 2023/05/31 20:32:58 packer-builder-qemu plugin: Looking for available port between 5900 and 6000 on 127.0.0.1 2023/05/31 20:32:58 packer-builder-qemu plugin: Found available port: 5951 on IP: 127.0.0.1 2023/05/31 20:32:58 packer-builder-qemu plugin: Found available VNC port: 5951 on IP: 127.0.0.1 2023/05/31 20:32:58 packer-builder-qemu plugin: Qemu --version output: QEMU emulator version 6.0.0 2023/05/31 20:32:58 packer-builder-qemu plugin: Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers 2023/05/31 20:32:58 packer-builder-qemu plugin: Qemu version: 6.0.0 2023/05/31 20:32:58 ui: ==> qemu.centos7: Starting VM, booting from CD-ROM 2023/05/31 20:32:58 ui: qemu.centos7: The VM will be run headless, without a GUI. If you want to qemu.centos7: view the screen of the VM, connect via VNC without a password to qemu.centos7: vnc://127.0.0.1:5951 2023/05/31 20:32:58 packer-builder-qemu plugin: Qemu Builder has no floppy files, not attaching a floppy. 2023/05/31 20:32:58 ui: ==> qemu.centos7: Overriding default Qemu arguments with qemuargs template option... 2023/05/31 20:32:58 packer-builder-qemu plugin: Executing /usr/bin/qemu-system-x86_64: []string{"-vnc", "127.0.0.1:51", "-device", "virtio-net,netdev=user.0", "-m", "2048M", "-machine", "type=pc,accel=kvm", "-netdev", "user,id=user.0,hostfwd=tcp::2855-:22", "-drive", "file=artifacts/qemu/centos7/packer-centos7,if=virtio,cache=none,discard=unmap,format=qcow2", "-drive", "file=/opt/packer_cache/e476ea1d3ef3c2e3966a7081ac4239cd5ae5e8a3.iso,media=cdrom", "-boot", "once=d", "-name", "packer-centos7", "-smp", "2"} 2023/05/31 20:32:58 packer-builder-qemu plugin: Started Qemu. Pid: 135 2023/05/31 20:33:00 ui: ==> qemu.centos7: Waiting 40s for boot... 2023/05/31 20:33:40 ui: ==> qemu.centos7: Connecting to VM via VNC (127.0.0.1:5951) 2023/05/31 20:33:40 packer-builder-qemu plugin: Connected to VNC desktop: QEMU (packer-centos7) 2023/05/31 20:33:40 ui: ==> qemu.centos7: Typing the boot command over VNC... 2023/05/31 20:33:40 packer-builder-qemu plugin: Special code '<up>' found, replacing with: 0xFF52 2023/05/31 20:33:41 packer-builder-qemu plugin: [INFO] Waiting 1s 2023/05/31 20:33:42 packer-builder-qemu plugin: Special code '<tab>' found, replacing with: 0xFF09 2023/05/31 20:33:42 packer-builder-qemu plugin: [INFO] Waiting 1s 2023/05/31 20:33:43 packer-builder-qemu plugin: Sending char ' ', code 0x20, shift false 2023/05/31 20:33:43 packer-builder-qemu plugin: Sending char 'n', code 0x6E, shift false 2023/05/31 20:33:43 packer-builder-qemu plugin: Sending char 'e', code 0x65, shift false 2023/05/31 20:33:43 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:44 packer-builder-qemu plugin: Sending char '.', code 0x2E, shift false 2023/05/31 20:33:44 packer-builder-qemu plugin: Sending char 'i', code 0x69, shift false 2023/05/31 20:33:44 packer-builder-qemu plugin: Sending char 'f', code 0x66, shift false 2023/05/31 20:33:44 packer-builder-qemu plugin: Sending char 'n', code 0x6E, shift false 2023/05/31 20:33:44 packer-builder-qemu plugin: Sending char 'a', code 0x61, shift false 2023/05/31 20:33:45 packer-builder-qemu plugin: Sending char 'm', code 0x6D, shift false 2023/05/31 20:33:45 packer-builder-qemu plugin: Sending char 'e', code 0x65, shift false 2023/05/31 20:33:45 packer-builder-qemu plugin: Sending char 's', code 0x73, shift false 2023/05/31 20:33:45 packer-builder-qemu plugin: Sending char '=', code 0x3D, shift false 2023/05/31 20:33:45 packer-builder-qemu plugin: Sending char '0', code 0x30, shift false 2023/05/31 20:33:46 packer-builder-qemu plugin: Sending char ' ', code 0x20, shift false 2023/05/31 20:33:46 packer-builder-qemu plugin: Sending char 'b', code 0x62, shift false 2023/05/31 20:33:46 packer-builder-qemu plugin: Sending char 'i', code 0x69, shift false 2023/05/31 20:33:46 packer-builder-qemu plugin: Sending char 'o', code 0x6F, shift false 2023/05/31 20:33:46 packer-builder-qemu plugin: Sending char 's', code 0x73, shift false 2023/05/31 20:33:47 packer-builder-qemu plugin: Sending char 'd', code 0x64, shift false 2023/05/31 20:33:47 packer-builder-qemu plugin: Sending char 'e', code 0x65, shift false 2023/05/31 20:33:47 packer-builder-qemu plugin: Sending char 'v', code 0x76, shift false 2023/05/31 20:33:47 packer-builder-qemu plugin: Sending char 'n', code 0x6E, shift false 2023/05/31 20:33:47 packer-builder-qemu plugin: Sending char 'a', code 0x61, shift false 2023/05/31 20:33:48 packer-builder-qemu plugin: Sending char 'm', code 0x6D, shift false 2023/05/31 20:33:48 packer-builder-qemu plugin: Sending char 'e', code 0x65, shift false 2023/05/31 20:33:48 packer-builder-qemu plugin: Sending char '=', code 0x3D, shift false 2023/05/31 20:33:48 packer-builder-qemu plugin: Sending char '0', code 0x30, shift false 2023/05/31 20:33:48 packer-builder-qemu plugin: Sending char ' ', code 0x20, shift false 2023/05/31 20:33:49 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:49 packer-builder-qemu plugin: Sending char 'e', code 0x65, shift false 2023/05/31 20:33:49 packer-builder-qemu plugin: Sending char 'x', code 0x78, shift false 2023/05/31 20:33:49 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:49 packer-builder-qemu plugin: Sending char ' ', code 0x20, shift false 2023/05/31 20:33:50 packer-builder-qemu plugin: Sending char 'k', code 0x6B, shift false 2023/05/31 20:33:50 packer-builder-qemu plugin: Sending char 's', code 0x73, shift false 2023/05/31 20:33:50 packer-builder-qemu plugin: Sending char '=', code 0x3D, shift false 2023/05/31 20:33:50 packer-builder-qemu plugin: Sending char 'h', code 0x68, shift false 2023/05/31 20:33:50 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:51 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:51 packer-builder-qemu plugin: Sending char 'p', code 0x70, shift false 2023/05/31 20:33:51 packer-builder-qemu plugin: Sending char ':', code 0x3A, shift true 2023/05/31 20:33:51 packer-builder-qemu plugin: Sending char '/', code 0x2F, shift false 2023/05/31 20:33:52 packer-builder-qemu plugin: Sending char '/', code 0x2F, shift false 2023/05/31 20:33:52 packer-builder-qemu plugin: Sending char '1', code 0x31, shift false 2023/05/31 20:33:52 packer-builder-qemu plugin: Sending char '0', code 0x30, shift false 2023/05/31 20:33:52 packer-builder-qemu plugin: Sending char '.', code 0x2E, shift false 2023/05/31 20:33:52 packer-builder-qemu plugin: Sending char '0', code 0x30, shift false 2023/05/31 20:33:53 packer-builder-qemu plugin: Sending char '.', code 0x2E, shift false 2023/05/31 20:33:53 packer-builder-qemu plugin: Sending char '2', code 0x32, shift false 2023/05/31 20:33:53 packer-builder-qemu plugin: Sending char '.', code 0x2E, shift false 2023/05/31 20:33:53 packer-builder-qemu plugin: Sending char '2', code 0x32, shift false 2023/05/31 20:33:53 packer-builder-qemu plugin: Sending char ':', code 0x3A, shift true 2023/05/31 20:33:54 packer-builder-qemu plugin: Sending char '8', code 0x38, shift false 2023/05/31 20:33:54 packer-builder-qemu plugin: Sending char '5', code 0x35, shift false 2023/05/31 20:33:54 packer-builder-qemu plugin: Sending char '7', code 0x37, shift false 2023/05/31 20:33:54 packer-builder-qemu plugin: Sending char '8', code 0x38, shift false 2023/05/31 20:33:55 packer-builder-qemu plugin: Sending char '/', code 0x2F, shift false 2023/05/31 20:33:55 packer-builder-qemu plugin: Sending char 'h', code 0x68, shift false 2023/05/31 20:33:55 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:55 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:55 packer-builder-qemu plugin: Sending char 'p', code 0x70, shift false 2023/05/31 20:33:56 packer-builder-qemu plugin: Sending char '/', code 0x2F, shift false 2023/05/31 20:33:56 packer-builder-qemu plugin: Sending char 'c', code 0x63, shift false 2023/05/31 20:33:56 packer-builder-qemu plugin: Sending char 'e', code 0x65, shift false 2023/05/31 20:33:56 packer-builder-qemu plugin: Sending char 'n', code 0x6E, shift false 2023/05/31 20:33:56 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:57 packer-builder-qemu plugin: Sending char 'o', code 0x6F, shift false 2023/05/31 20:33:57 packer-builder-qemu plugin: Sending char 's', code 0x73, shift false 2023/05/31 20:33:57 packer-builder-qemu plugin: Sending char '7', code 0x37, shift false 2023/05/31 20:33:57 packer-builder-qemu plugin: Sending char '-', code 0x2D, shift false 2023/05/31 20:33:57 packer-builder-qemu plugin: Sending char 'k', code 0x6B, shift false 2023/05/31 20:33:58 packer-builder-qemu plugin: Sending char 'i', code 0x69, shift false 2023/05/31 20:33:58 packer-builder-qemu plugin: Sending char 'c', code 0x63, shift false 2023/05/31 20:33:58 packer-builder-qemu plugin: Sending char 'k', code 0x6B, shift false 2023/05/31 20:33:58 packer-builder-qemu plugin: Sending char 's', code 0x73, shift false 2023/05/31 20:33:58 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:59 packer-builder-qemu plugin: Sending char 'a', code 0x61, shift false 2023/05/31 20:33:59 packer-builder-qemu plugin: Sending char 'r', code 0x72, shift false 2023/05/31 20:33:59 packer-builder-qemu plugin: Sending char 't', code 0x74, shift false 2023/05/31 20:33:59 packer-builder-qemu plugin: Sending char '.', code 0x2E, shift false 2023/05/31 20:33:59 packer-builder-qemu plugin: Sending char 'c', code 0x63, shift false 2023/05/31 20:34:00 packer-builder-qemu plugin: Sending char 'f', code 0x66, shift false 2023/05/31 20:34:00 packer-builder-qemu plugin: Sending char 'g', code 0x67, shift false 2023/05/31 20:34:00 packer-builder-qemu plugin: Special code '<enter>' found, replacing with: 0xFF0D 2023/05/31 20:34:00 packer-builder-qemu plugin: [INFO] Waiting 1s 2023/05/31 20:34:01 ui: qemu.centos7: Not using a NetBridge -- skipping StepWaitGuestAddress 2023/05/31 20:34:01 ui: ==> qemu.centos7: Using SSH communicator to connect: 127.0.0.1 2023/05/31 20:34:01 packer-builder-qemu plugin: [INFO] Waiting for SSH, up to timeout: 30m0s 2023/05/31 20:34:01 ui: ==> qemu.centos7: Waiting for SSH to become available... 2023/05/31 20:34:01 packer-builder-qemu plugin: [INFO] Attempting SSH connection to 127.0.0.1:2855... 2023/05/31 20:34:01 packer-builder-qemu plugin: [DEBUG] reconnecting to TCP connection for SSH 2023/05/31 20:34:01 packer-builder-qemu plugin: [DEBUG] handshaking with SSH 2023/05/31 20:34:20 packer-builder-qemu plugin: [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:58790->127.0.0.1:2855: read: connection reset by peer 2023/05/31 20:34:27 packer-builder-qemu plugin: [INFO] Attempting SSH connection to 127.0.0.1:2855... 2023/05/31 20:34:27 packer-builder-qemu plugin: [DEBUG] reconnecting to TCP connection for SSH 2023/05/31 20:34:27 packer-builder-qemu plugin: [DEBUG] handshaking with SSH 2023/05/31 20:34:27 packer-builder-qemu plugin: [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:44574->127.0.0.1:2855: read: connection reset by peer 2023/05/31 20:34:34 packer-builder-qemu plugin: [INFO] Attempting SSH connection to 127.0.0.1:2855... 2023/05/31 20:34:34 packer-builder-qemu plugin: [DEBUG] reconnecting to TCP connection for SSH 2023/05/31 20:34:34 packer-builder-qemu plugin: [DEBUG] handshaking with SSH 2023/05/31 20:34:34 packer-builder-qemu plugin: [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:45896->127.0.0.1:2855: read: connection reset by peer 2023/05/31 20:34:41 packer-builder-qemu plugin: [INFO] Attempting SSH connection to 127.0.0.1:2855... 2023/05/31 20:34:41 packer-builder-qemu plugin: [DEBUG] reconnecting to TCP connection for SSH 2023/05/31 20:34:41 packer-builder-qemu plugin: [DEBUG] handshaking with SSH 2023/05/31 20:34:41 packer-builder-qemu plugin: [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:45922->127.0.0.1:2855: read: connection reset by peer

Getting error while building KVM images for ubuntu 20.04

I am testing it locally in mac. Any clue?

bharathkumarraju@R77-NB193 packer-kvm % docker run --rm \
  -e PACKER_LOG=1 \
  -e PACKER_LOG_PATH="packer-docker.log" \
  -it \
  --privileged \
  --cap-add=ALL -v /lib/modules:/lib/modules \
  -v `pwd`:/opt/ \
  -e AWS_ACCESS_KEY=$AWS_ACCESS_KEY \
  -e AWS_SECRET_KEY=$AWS_SECRET_KEY \
  -w /opt/ goffinet/packer-qemu build focal.json
Unable to find image 'goffinet/packer-qemu:latest' locally
latest: Pulling from goffinet/packer-qemu
05e7bc50f07f: Pull complete
ac26b8210c2a: Pull complete
002b7e5b543a: Pull complete
b6df280f5928: Pull complete
ccae1a18c110: Pull complete
36729b6cb02c: Pull complete
8d0a8b8d2a73: Pull complete
d1ae1becb54d: Pull complete
Digest: sha256:dcf5068438023b29a12ae5bd2c2b4fca32c420bfbba7f1e659f33238f56325e8
Status: Downloaded newer image for goffinet/packer-qemu:latest
Warning: Warning when preparing build: "focal"

ssh_host_port_min is deprecated and is being replaced by host_port_min. Please,
update your template to use host_port_min. In future versions of Packer,
inclusion of ssh_host_port_min will error your builds.

Warning: Warning when preparing build: "focal"

ssh_host_port_max is deprecated and is being replaced by host_port_max. Please,
update your template to use host_port_max. In future versions of Packer,
inclusion of ssh_host_port_max will error your builds.


focal: output will be in this color.

==> focal: Retrieving ISO
==> focal: Trying http://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.iso
==> focal: Trying http://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.iso?checksum=sha256%3A443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93
    focal: ubuntu-20.04.1-live-server-amd64.iso 914.00 MiB / 914.00 MiB [==========================================================================================================================================================================================================================================] 100.00% 3m22s
==> focal: http://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.iso?checksum=sha256%3A443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93 => /opt/packer_cache/e30b34e4d3c536763868a42bb9d5b8f14af297b8.iso
==> focal: Starting HTTP server on port 10088
==> focal: Found port for communicator (SSH, WinRM, etc): 2224.
==> focal: Looking for available port between 5900 and 6000 on 127.0.0.1
==> focal: Starting VM, booting from CD-ROM
    focal: The VM will be run headless, without a GUI. If you want to
    focal: view the screen of the VM, connect via VNC without a password to
    focal: vnc://127.0.0.1:41
==> focal: Overriding default Qemu arguments with qemuargs template option...
==> focal: Error launching VM: Qemu failed to start. Please run with PACKER_LOG=1 to get more info.
==> focal: Deleting output directory...
Build 'focal' errored after 3 minutes 47 seconds: Build was halted.

==> Wait completed after 3 minutes 47 seconds

==> Some builds didn't complete successfully and had errors:
--> focal: Build was halted.

==> Builds finished but no artifacts were created.
bharathkumarraju@R77-NB193 packer-kvm %

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.