Skip to content

utilizable/ansible-role-lxc-distrobuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LXC - DISTROBUILDER

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!

🔨 TODO

  • Packages
  • Actions (Scripts)
  • Files
  • Actions - Package
  • Actions - File
  • Variants
  • Releases

Table of Contents

🧰 Requirements

(Back to top)

Make sure you have installed both - latest docker and gnu make!

⚡️ Quick start

(Back to top)

  1. Clone repository
  2. execute make prepare
  3. execute make exec

After successfully running the exec stage, your LXC package will appear in the /ansible directory - rootfs.tar.xz.

📔 Playbook

(Back to top)

Main Playbook

#!/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

---
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

📒 Make stages

(Back to top)

Stages definied in makefile.

  • make prepare - Execute ansible-playbook,
  • make execute - Execute distrobuilder,
  • make show - Show running containers,
  • make prune - Prune project related containers,

🗄 Repository structure

(Back to top)

  • ./ansible ansible related resources, workdir for compose-containers,
  • ./build each step contains its own docker container,
  • ./Makefile entrypoint.

🔖 Versioning model

(Back to top)

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.

💻 Proxmox

(Back to top)

Here's a brief showcase demonstrating how we can populate our built artifact into Proxmox PVE!

image

image

image

📌 Refs

(Back to top)