(Images as code)
Image creation harness for Qemu based virtual environments.
Cloud-init will handle the following (and is therefore, not managed here):
- DNS
- IP assignment
- Hostname
- Password
- Authorized keys
- Timezone
- NTP
- Additional users
-
Ensure you have the required base dependencies:
-
(optional) Create
./vehost.pkr.hcl
:Create a valid
null
source with a valid SSH communicator configuration and the labelvehost
.This can be any remote machine that you would like to transfer the image to, although the purpose is for a virtual machine host.
See docs for information on the Packer SSH communicator.
source "null" "vehost" { ssh_host = "127.0.0.1" ssh_username = "foo" ssh_password = "bar" # if you want to use SSH keys, use `ssh_private_key_file` instead }
-
Use
make <all|BUILD_NAME>
to build, it injects a newly generated ssh key into the build process via the variablesssh_public_key
andssh_private_key_file_path
, therefore you may skip this and specify your own key using the same variables.make <all|BUILD_NAME>
If you would like to skip automatically trying to upload to a virtual environment after image creation, set
VE_UPLOAD=0
to yourmake
command or set it as an environment variable.make VE_UPLOAD=0 <all|BUILD_NAME>
- Ensure the image is built and present at
out/<target>/packer-base
- Upload the image with
make
.IMG-AC
will go through every build name present in themakefile
and try to upload to yourvehost
source.make upload
make -B .venv
*.auto.pkrvars.hcl
may overridelocal_vm_settings
orproxmox_settings
variables with your own values.vehost.pkr.hcl
required configuration for post-build tasks, you must specify a valid SSH connection to the VE platform specified inconfig/config.mak
. You may leave blank if you don't care about post-build tasks (usebuild_only=1
in yourmake
).config/
config.mak
required configuration,build_only
,platform_ve
,ansible_groups
.ansible/
requirements.yaml
optional ansible-galaxy requirements file ran before provisioning.site.yaml
shared playbook for all images, target the images differently with the groups you specify inconfig.mak
.
- Packer will automatically cache downloaded images on your machine
- Make will not rebuild images if they are unnecessary
- Make will only update your python virtual environment if it is out of date