Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wsadza/ansible-role-lxc-distrobuilder

📜 - Ansible role to LXC container provisioning.
https://github.com/wsadza/ansible-role-lxc-distrobuilder

ansible containers dockerfile-like lxc provisioning proxmox

Last synced: about 1 month ago
JSON representation

📜 - Ansible role to LXC container provisioning.

Awesome Lists containing this project

README

        

LXC - DISTROBUILDER
============
I've always wished for something like a Dockerfile, but for LXC containers. Recently, I discovered [distrobuilder](https://linuxcontainers.org/distrobuilder/docs/latest/), 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

- [x] Packages
- [x] Actions (Scripts)
- [ ] Files
- [ ] Actions - Package
- [ ] Actions - File
- [ ] Variants
- [ ] Releases

## Table of Contents
- [Requirements](#-requirements)
- [Quick start](#%EF%B8%8F-quick-start)
- [Playbook](#-playbook)
- [Makefile stages](#-make-stages)
- [Repository structure](#-repository-structure)
- [Versioning model](#-versioning-model)
- [Proxmox](#-proxmox)
- [Refs](#-refs)

## 🧰 Requirements
[(Back to top)](#table-of-contents)

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

- `Docker` - https://docs.docker.com/desktop/install/
- `Make` - https://ftp.gnu.org/gnu/make/

## ⚡️ Quick start
[(Back to top)](#table-of-contents)

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)](#table-of-contents)

#### Main Playbook

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

```yaml
---
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)](#table-of-contents)

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)](#table-of-contents)

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

## 🔖 Versioning model
[(Back to top)](#table-of-contents)

Versions have the format `.(.)?` where:

- `` Triggered manualy from default branch,
- `` Triggered automaticly after each push from default branch,
- `` Triggered automaticly after each push from fix/[0-9].[0-9].x branch.

## 💻 Proxmox
[(Back to top)](#table-of-contents)

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


image



image



image

## 📌 Refs
[(Back to top)](#table-of-contents)

- https://linuxcontainers.org/distrobuilder/docs/latest/reference/source/
- https://blog.simos.info/using-distrobuilder-to-create-container-images-for-lxc-and-lxd/
- https://github.com/lxc/lxc-ci/blob/main/images/debian.yaml