{"id":21397577,"url":"https://github.com/multani/packer-qemu-debian","last_synced_at":"2025-07-13T20:32:22.177Z","repository":{"id":38193085,"uuid":"161949779","full_name":"multani/packer-qemu-debian","owner":"multani","description":"A Packer configuration to build a QEMU Debian image suitable for testing \"cloud-like\" setups","archived":false,"fork":false,"pushed_at":"2023-01-30T23:27:47.000Z","size":66,"stargazers_count":18,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-11T15:10:17.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-15T22:48:23.000Z","updated_at":"2023-03-11T13:55:35.000Z","dependencies_parsed_at":"2023-02-12T07:45:19.843Z","dependency_job_id":null,"html_url":"https://github.com/multani/packer-qemu-debian","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multani%2Fpacker-qemu-debian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multani%2Fpacker-qemu-debian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multani%2Fpacker-qemu-debian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multani%2Fpacker-qemu-debian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multani","download_url":"https://codeload.github.com/multani/packer-qemu-debian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225916987,"owners_count":17544825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T14:43:37.570Z","updated_at":"2024-11-22T14:43:38.160Z","avatar_url":"https://github.com/multani.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Debian image for QEMU\n\nThis repository contains [Packer](https://www.packer.io) configuration to build\n\"cloud-like\" Debian images for QEMU.\n\n\n## How to use these images?\n\n### As an alternative Packer builder\n\nYou can reuse these images to test locally your own Packer configuration\ninstead of building images on your favorite cloud provider.\n\nYou can start with the following configuration:\n\n* it downloads the image built using this repository from Github\n* configures a new, larger QCOW disk to host the VM while Packer is building\n* runs a basic provisioner (you may want to change this!)\n\n```json\n{\n  \"min_packer_version\": \"1.3.3\",\n  \"variables\": {\n    \"qemu_output_dir\": \"qemu-images\",\n    \"qemu_output_name\": \"my-build.qcow2\",\n    \"qemu_source_checksum_url\": \"https://github.com/multani/packer-qemu-debian/releases/download/10.0.0-1/SHA256SUMS\",\n    \"qemu_source_iso\": \"https://github.com/multani/packer-qemu-debian/releases/download/10.0.0-1/debian-10.0.0-1.qcow2\",\n    \"qemu_ssh_password\": \"debian\",\n    \"qemu_ssh_username\": \"debian\"\n  },\n\n  \"builders\": [\n    {\n      \"type\": \"qemu\",\n      \"iso_url\": \"{{ user `qemu_source_iso` }}\",\n      \"iso_checksum_url\": \"{{ user `qemu_source_checksum_url` }}\",\n      \"iso_checksum_type\": \"sha256\",\n\n      \"disk_image\": true,\n      \"accelerator\": \"kvm\",\n      \"boot_wait\": \"1s\",\n      \"format\": \"qcow2\",\n      \"use_backing_file\": true,\n\n      \"disk_size\": 8000,\n\n      \"headless\": true,\n      \"shutdown_command\": \"echo '{{ user `qemu_ssh_password` }}'  | sudo -S /sbin/shutdown -hP now\",\n\n      \"ssh_host_port_max\": 2229,\n      \"ssh_host_port_min\": 2222,\n      \"ssh_password\": \"{{ user `qemu_ssh_password` }}\",\n      \"ssh_username\": \"{{ user `qemu_ssh_username` }}\",\n      \"ssh_wait_timeout\": \"1000s\",\n\n      \"output_directory\": \"{{ user `qemu_output_dir` }}\",\n      \"vm_name\": \"{{ user `qemu_output_name` }}\"\n    }\n  ],\n\n  \"provisioners\": [\n    {\n      \"type\": \"shell\",\n      \"inline\": [\n        \"echo '  *** Running my favorite provisioner'\"\n      ]\n    }\n  ]\n}\n```\n\nSave this file as `packer.json`, then you can run:\n\n```\n$ packer validate packer.json\nTemplate validated successfully.\n$ packer build -timestamp-ui packer.json\nqemu output will be in this color.\n\n2019-01-20T12:09:19+01:00: ==\u003e qemu: Retrieving ISO\n2019-01-20T12:09:20+01:00:     qemu: Found already downloaded, initial checksum matched, no download needed: https://github.com/multani/packer-qemu-debian/releases/download/10.0.0-1/debian-10.0.0-1.qcow2\n2019-01-20T12:09:20+01:00: ==\u003e qemu: Creating hard drive...\n2019-01-20T12:09:20+01:00: ==\u003e qemu: Resizing hard drive...\n2019-01-20T12:09:20+01:00: ==\u003e qemu: Found port for communicator (SSH, WinRM, etc): 2226.\n2019-01-20T12:09:20+01:00: ==\u003e qemu: Looking for available port between 5900 and 6000 on 127.0.0.1\n2019-01-20T12:09:20+01:00: ==\u003e qemu: Starting VM, booting disk image\n2019-01-20T12:09:20+01:00: ==\u003e qemu: Overriding defaults Qemu arguments with QemuArgs...\n2019-01-20T12:09:22+01:00: ==\u003e qemu: Waiting 1s for boot...\n2019-01-20T12:09:23+01:00: ==\u003e qemu: Connecting to VM via VNC (127.0.0.1:5957)\n2019-01-20T12:09:23+01:00: ==\u003e qemu: Typing the boot command over VNC...\n2019-01-20T12:09:23+01:00: ==\u003e qemu: Using ssh communicator to connect: 127.0.0.1\n2019-01-20T12:09:23+01:00: ==\u003e qemu: Waiting for SSH to become available...\n2019-01-20T12:09:29+01:00: ==\u003e qemu: Connected to SSH!\n2019-01-20T12:09:29+01:00: ==\u003e qemu: Provisioning with shell script: /tmp/packer-shell962483776\n2019-01-20T12:09:29+01:00:     qemu:   *** Running my favorite provisioner\n2019-01-20T12:09:29+01:00: ==\u003e qemu: Gracefully halting virtual machine...\n2019-01-20T12:09:31+01:00: ==\u003e qemu: Converting hard drive...\n2019-01-20T12:09:36+01:00: Build 'qemu' finished.\n\n==\u003e Builds finished. The artifacts of successful builds are:\n--\u003e qemu: VM files in directory: qemu-images\n```\n\nThis gives you a test image in which you can test your provisioning and\nconfiguration in less than 10 seconds.\n\nThis creates a pretty large image in the end, you can pass these additional\nflags to Packer to reduce the final size (at the expense of a longer build):\n\n```json\n  \"disk_compression\": true,\n  \"disk_detect_zeroes\": \"unmap\",\n  \"disk_discard\": \"unmap\",\n  \"skip_compaction\": false,\n```\n\n\n### As a virtual machine image for libvirt\n\nUsing the [Terraform provider for\nlibvirt](https://github.com/dmacvicar/terraform-provider-libvirt) you can\ncreate a new VM with libvirt in order to test your\n[cloud-init](https://cloudinit.readthedocs.io/) configuration for example:\n\n```hcl\nprovider \"libvirt\" {\n  uri = \"qemu:///system\"\n}\n\nresource \"libvirt_volume\" \"debian\" {\n  name   = \"debian.qcow2\"\n  pool   = \"default\"\n  source = \"https://github.com/multani/packer-qemu-debian/releases/download/10.0.0-1/debian-10.0.0-1.qcow2\"\n  format = \"qcow2\"\n}\n\ndata \"template_file\" \"user_data\" {\n  template = \u003c\u003cEOF\npackages:\n - pwgen\n - nginx-full\nEOF\n}\n\nresource \"libvirt_cloudinit_disk\" \"cloud_init\" {\n  name           = \"cloud-init.iso\"\n  user_data      = \"${data.template_file.user_data.rendered}\"\n}\n\nresource \"libvirt_domain\" \"test\" {\n  name   = \"test\"\n  memory = \"512\"\n  vcpu   = 1\n\n  cloudinit = \"${libvirt_cloudinit_disk.cloud_init.id}\"\n\n  network_interface {\n    network_name = \"default\"\n  }\n\n  disk {\n    volume_id = \"${libvirt_volume.debian.id}\"\n  }\n}\n```\n\nSee the [provider\ndocumentation](https://github.com/dmacvicar/terraform-provider-libvirt/tree/master/website/docs)\nfor more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultani%2Fpacker-qemu-debian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultani%2Fpacker-qemu-debian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultani%2Fpacker-qemu-debian/lists"}