diff options
author | Jonathan Bauer | 2017-04-11 18:46:54 +0200 |
---|---|---|
committer | Jonathan Bauer | 2017-04-11 18:46:54 +0200 |
commit | dc2de921c387edf0c215b33109f0b6a255f753fd (patch) | |
tree | bb20b7e5ad8cba3aad721e304a0b562c9b8bfc17 /README.md | |
parent | [ubuntu] support root password via ROOTPW env (diff) | |
download | packer-templates-dc2de921c387edf0c215b33109f0b6a255f753fd.tar.gz packer-templates-dc2de921c387edf0c215b33109f0b6a255f753fd.tar.xz packer-templates-dc2de921c387edf0c215b33109f0b6a255f753fd.zip |
introduce Makefile to simplify building templates
updated ubuntu/centos templates to fixed output names,
moved manifest.json to builder's subfolder,
updated README.md to reflect the changes
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 41 |
1 files changed, 29 insertions, 12 deletions
@@ -15,24 +15,24 @@ The root password is expected to be in the ROOTPW environment variable. The installation procedure will fail without it! Basic usage: +```shell ROOTPW=<password> packer build -var-file=base.json <template> - -For the rest of the examples, the root password is expected to be exported. +``` +For the rest of the examples, ROOTPW is assumed to be set in the environment. ## Usage: Creating base images -Example: build Ubuntu 16.04.2 LTS template using qemu builder +Example - Build Ubuntu 16.04.2 LTS template using qemu builder +```shell packer build -var-file=base.json -only=qemu ubuntu-16.04-amd64.json - +``` Debug: +```shell PACKER_LOG=1 PACKER_LOG_FILE=/var/log/packer.log \ packer build -debug -only=qemu -var-file=base.json ubuntu-16.04-amd64.json - +``` A successful build process would produce a disk image under: - output-<distro>-<builder>-<timestamp>/packer-<distro> - -Example: - output-ubuntu-qemu-1490876841/packer-ubuntu-amd64 + <builder>/<template>, e.g. qemu/centos-7.3-x86_64 Additionally, the manifest post-processor creates a manifest.json file in the working directory containing various information about the generated @@ -54,9 +54,12 @@ Refer to those repos for more information. The simpliest way to initialize the submodule is by cloning this repository with '--recursive'. Build initramfs inside a previously created image: +```shell packer build -var-file=base.json \ -var='image_path='"$(jq -r '.builds[0].files[0].name' < manifest.json)"'' \ ansible-roles/run-playbook-only.json +``` +(This expects 'manifest.json' to contain only one packer artifact.) The path to the existing image is extracted using the jq tool and given as 'image_path' to the packer provisioning template run-playbook-only.json. @@ -64,15 +67,27 @@ A successful build would provide the stage3 initramfs and the VM's kernel in the ansible-roles/boot_files/ directory. Refer to systemd-init for more information on how to setup a boot environment. -The packer artifact is created as output-<timestamp>. This provisioned image +The packer artifact is created in 'output-<timestamp>'. This artifact contains all the development packages needed to build the initramfs, which -can be discarded. +can be discarded. Instead, the base image can be used as the main boot image. + +## Makefile + +A simple Makefile to build packer templates is provided for convenience. +See a list of targets with `make list`. + +Example - Build CentOS 7.3 with qemu: +```shell + make qemu/centos-7.3-x86_64 +``` ## Notes Variables set in base.json can be overriden using packer's '-var' options, e.g.: +```shell packer build -var-file=base.json -var='headless=true' <template> -(Make sure you first include base.json before overriding a variable!) +``` +Make sure you first include base.json before overriding a variable! The partitioning of the virtual disk is done via kickstart/preseed files. Currently, a simple partition scheme is used: separate boot partition, rest a the main system @@ -81,7 +96,9 @@ supported, tested were currently xfs and btrfs. If you change the filesystem to you need to adapt your boot configuration file (SLX_MOUNT_ROOT_OPTIONS). While the qemu builder produces a qcow2 image, it can be further compressed using: +```shell virt-sparsify --compress <qcow2_file> <output_qcow2_file> +``` ## TL;DR 0) git clone --recursive git://git.openslx.org/openslx-ng/packer-templates |