From 51af68d6825129e5419343366b4f309061d9bbd0 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 17 Mar 2017 17:32:53 +0100 Subject: added sample packer template to call a playbook on ... ... an existing qcow2 image. --- README.md | 6 ++++++ run-playbook-only.json | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 run-playbook-only.json diff --git a/README.md b/README.md index ede4cdc..a4a42ff 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,9 @@ Depends on *setup-dev-tools* role (see dracut-initramfs-builder/meta/main.yml). ## Usage Use the provided 'build-dracut-initramfs.yml' playbook for the ansible provisioner in your packer template. +You can use an already created qcow2 image, instead of always generating new packer images. See *run-playbook-only.json* +for a sample packer template to use an existing qcow2 image and provision them with our playbook. +The template requires the variable 'image_path' to be set, which needs to be the path of the qcow2 image. +If it was generated by packer and the manifest was created, you can simply extract the image path from that: + packer build -var-file=base.json -only=qemu -var='image_path='"$(jq -r '.builds[0].files[0].name' < manifest.json)"'' test.json + diff --git a/run-playbook-only.json b/run-playbook-only.json new file mode 100644 index 0000000..bc551a3 --- /dev/null +++ b/run-playbook-only.json @@ -0,0 +1,25 @@ +{ + "builders": [{ + "type": "qemu", + "iso_url": "{{ user `image_path` }}", + "iso_checksum_type": "none", + "output_directory": "output-{{ timestamp }}", + "vm_name": "packer-{{ build_name }}", + "disk_image": "true", + "format": "qcow2", + "headless": "{{ user `headless` }}", + "ssh_timeout": "{{ user `ssh_timeout` }}", + "ssh_username": "{{ user `ssh_username` }}", + "ssh_password": "{{ user `ssh_password` }}", + "shutdown_command": "systemctl poweroff", + "qemuargs": [ + ["-m", "{{ user `memory` }}"], + ["-smp", "{{ user `cpus` }}"] + ] + }], + "provisioners": [{ + "type": "ansible", + "playbook_file": "build-dracut-initramfs.yml", + "extra_arguments": [ "-vvv" ] + }] +} -- cgit v1.2.3-55-g7522