I've always wished for something like a Dockerfile, but for LXC containers. Recently, I discovered distrobuilder, a tool that allows you to effortlessly create LXC containers using a YAML configuration. With this in mind, I've wrapped it into an Ansible playbook and set up GitHub Actions to provide semi-automated LXC container provisioning!
- Packages
- Actions (Scripts)
- Files
- Actions - Package
- Actions - File
- Variants
- Releases
- Requirements
- Quick start
- Playbook
- Makefile stages
- Repository structure
- Versioning model
- Proxmox
- Refs
Make sure you have installed both - latest docker and gnu make!
- Clone repository
- execute
make prepare
- execute
make exec
After successfully running the exec stage, your LXC package will appear in the /ansible directory - rootfs.tar.xz
.
#!/usr/bin/env ansible-playbook
#---
- name: playbook
hosts: localhost
roles:
- role: distrobuilder
# Additional packages
packages:
- curl
- vim-tiny
# Additional scripts
actions:
- |
#!/bin/sh
# Install docker engine
set -eux
curl -fsSL https://get.docker.com | sh
- |
#!/bin/sh
# ...
...
---
defaults:
distribution: "debian"
release_name: "bookworm"
# used during generation of archive-key
# https://ftp-master.debian.org/keys.html
release_version: "12"
architecture: "amd64"
variant: "minbase"
downloader: "debootstrap"
source_url: "https://deb.debian.org/debian/"
description: "base image"
# Default packages
packages:
- apt-utils
- ca-certificates
- dialog
- dnsutils
- ifupdown
- iproute2
- iputils-ping
- isc-dhcp-client
- locales
- net-tools
- netbase
- openssh-client
- rsync
- sysv-rc-conf
- sysvinit-core
Stages definied in makefile.
make prepare
- Executeansible-playbook
,make execute
- Executedistrobuilder
,make show
- Show running containers,make prune
- Prune project related containers,
./ansible
ansible related resources, workdir for compose-containers,./build
each step contains its own docker container,./Makefile
entrypoint.
Versions have the format <MAJOR>.<MINOR>(.<PATCH>)?
where:
<MAJOR>
Triggered manualy from default branch,<MINOR>
Triggered automaticly after each push from default branch,<PATCH>
Triggered automaticly after each push from fix/[0-9].[0-9].x branch.
Here's a brief showcase demonstrating how we can populate our built artifact into Proxmox PVE!