Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3bc9eab
chore(compose): remove compose stacks
hazzuk Jun 22, 2026
0336bd7
feat(justfile): add recipe to symlink custom stacks
hazzuk Jun 23, 2026
d597a56
refactor(compose): create oidc defaults dictionary
hazzuk Jun 23, 2026
ecc3f98
refactor(compose): create role defaults sub-dir
hazzuk Jun 23, 2026
c4ac087
refactor(compose): switch to a stack_groups list
hazzuk Jun 24, 2026
d3121e8
refactor(compose): rename expanded stacks variable
hazzuk Jun 24, 2026
2253fa8
refactor(compose): reword setup task names
hazzuk Jun 24, 2026
03c15de
feat(compose): add stack group asserts
hazzuk Jun 24, 2026
07fae53
feat(compose): improve asserts logging clarity
hazzuk Jun 24, 2026
d3d6eb1
refactor(compose): use new variables for lookups
hazzuk Jun 24, 2026
f2b1ff3
refactor(compose): move lookups to expanded_stacks
hazzuk Jun 24, 2026
5f612db
refactor(compose): specify loop var for main tasks
hazzuk Jun 24, 2026
49b7616
chore: organise gitignore file
hazzuk Jun 24, 2026
b44204a
chore: configure gitignore for custom stacks
hazzuk Jun 24, 2026
51c69ce
refactor(compose): set secrets after expanding stacks
hazzuk Jun 28, 2026
5e68afa
refactor(compose): streamline loop var implementation
hazzuk Jun 28, 2026
ac744c4
feat(compose): merge host_vars & defaults stack dicts
hazzuk Jun 28, 2026
fd4c457
refactor(compose): use normal jinja delimiter
hazzuk Jun 28, 2026
7281da1
revert: "refactor(compose): create oidc defaults dictionary"
hazzuk Jun 28, 2026
39d5326
refactor(compose): reorganise defaults file
hazzuk Jun 28, 2026
00f2332
fix(compose): use new stack_secrets variable
hazzuk Jun 29, 2026
c2d9ad9
refactor(compose): define filetree lookups as loops
hazzuk Jun 29, 2026
47f1af1
fix(justfile): prevent .gitkeep file deletion
hazzuk Jun 30, 2026
bceebb6
feat(ansible): set micro editor options
hazzuk Jun 30, 2026
370ac65
feat(justfile): add custom repos recipes
hazzuk Jun 30, 2026
f966975
feat(justfile): annotate recipes with group names
hazzuk Jun 30, 2026
953bee7
feat(justfile): handle all symlinks as directories
hazzuk Jul 1, 2026
e36c21a
feat(justfile): recreate symlinks running compose
hazzuk Jul 13, 2026
532d79e
refactor(justfile): combine symlink recipes
hazzuk Jul 30, 2026
a5488be
feat(justfile): check adding empty karo-custom repos
hazzuk Jul 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# ansible

/.ansible
/.dev
/inventory

# custom stacks

/custom

/roles/karo-compose/defaults/main/*
!/roles/karo-compose/defaults/main/main.yml

/roles/karo-compose/templates/*
!/roles/karo-compose/templates/.gitkeep

# misc

/.dev
/cspell.json
2 changes: 1 addition & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inventory = inventory/hosts.ini
interpreter_python = /usr/bin/python3
vault_password_file = /run/user/1000/karo/ansible/vault_pass
local_tmp = /run/user/1000/karo/ansible/tmp
editor = micro -backup false
editor = micro -backup false -scrollbar true -statusline false

[privilege_escalation]
become_ask_pass = false
Expand Down
82 changes: 81 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
help:
@{{ just_executable() }} --list --unsorted --list-prefix " - " --justfile "{{ justfile() }}"

# (Internal use) Reusable confirmation statement
[confirm("proceed? (y/N)")]
_confirm:
@echo


# preseed

# Host preseed.cfg
[group('Debian install')]
@preseed platform='server':
# check user input for platform
[ "{{platform}}" = "server" ] || [ "{{platform}}" = "desktop" ] || { echo "platform must be 'server' or 'desktop'" >&2; exit 1; }
Expand All @@ -38,13 +44,15 @@ _host-preseed platform:
# server

# Setup a system
[group('System setup')]
@install hostname='': _check-password
ansible-playbook run.yml --tags install --limit "{{hostname}}"


# compose

# Deploy/remove stacks
[group('System setup')]
[arg("stack", long, short="s")]
compose action hostname='' stack='all': _check-password
#!/bin/bash
Expand All @@ -56,6 +64,8 @@ compose action hostname='' stack='all': _check-password
else
echo "action must be 'up' or 'down'" >&2; exit 1;
fi
# manage symlinks
just _custom-symlinks
# run user action
ANSIBLE_DISPLAY_SKIPPED_HOSTS=false ansible-playbook run.yml \
--extra-vars "karo_compose_justfile_stack={{stack}}" \
Expand All @@ -69,6 +79,7 @@ compose action hostname='' stack='all': _check-password
password := "/run/user/1000/karo/ansible/vault_pass"

# Manage a vault
[group('Ansible vault')]
vault hostname:
#!/bin/bash
# check password file exists
Expand All @@ -91,15 +102,84 @@ _check-password:
@[ -e "{{password}}" ] || micro -backup false -mkparents true "{{password}}"

# Set password
[group('Ansible vault')]
password:
@micro -backup false -mkparents true "{{password}}"


# wireguard

# Generate key pair
wireguard:
_wireguard:
@priv="$(wg genkey)"; \
pub="$(wg pubkey <<<"$priv")"; \
printf 'Private key: %s\n' "$priv"; \
printf 'Public key: %s\n' "$pub"


# custom

# Manage custom repos
[group('Custom repos')]
custom action username:
#!/usr/bin/env bash
set -euo pipefail
case "{{action}}" in
add)
echo "adding karo-custom {{username}}"
just _custom-add {{username}}
;;
remove)
echo "removing karo-custom {{username}}"
just _custom-remove {{username}}
;;
*)
echo "action must be 'add' or 'remove'" >&2; exit 1;
;;
esac

repo_name := "karo-custom"

# (Internal use) Add new karo-custom repo
_custom-add username:
#!/usr/bin/env bash
set -euo pipefail
# clone karo-custom git repo
git clone git@github.com:{{username}}/{{repo_name}}.git custom/{{username}}
# check karo-custom repo dir not empty
if [ -z "$(find custom/{{username}}/karo-compose -mindepth 1 -maxdepth 1)" ]; then
exit 0
else
# manage symlinks
just _custom-symlinks
# list stack groups for username
echo "new karo-compose stack groups:"
ls -1 roles/karo-compose/templates | grep {{username}} | awk '{print "- " $0}'
fi

# (Internal use) Remove existing karo-custom repo
@_custom-remove username:
# check username dir exists
test -d "custom/{{username}}"
# confirm removal
just _confirm
# remove custom dir
rm -rf "custom/{{username}}"
# manage symlinks
just _custom-symlinks

# (Internal use) Manage symbolic links for custom files
_custom-symlinks:
#!/usr/bin/env bash
set -euo pipefail
# clear existing symlinks
find roles/karo-compose/defaults/main/ -mindepth 1 -maxdepth 1 ! -name "main.yml" -delete
find roles/karo-compose/templates/ -mindepth 1 -maxdepth 1 ! -name ".gitkeep" -delete
# check custom dir not empty
if [ -z "$(find custom -mindepth 1 -maxdepth 1)" ]; then
exit 0
else
# symlink custom files
ln -sr custom/*/karo-compose/defaults/main/*/ roles/karo-compose/defaults/main/
ln -sr custom/*/karo-compose/templates/*/ roles/karo-compose/templates/
fi
Loading