Author SHA1 Message Date
kasun 3069d62fb3 docs: defer image pinning when adopting stacks
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 36s
2026-12-04 04:22:02 +01:00
claude-bot Bot 72485d6037 Merge pull request 'Feature: Render stack secrets from OpenBao and adopt Gitea' (#21) from feature/render-stack-env-from-openbao into main
Checks / Secret Scan (push) Successful in 5s
Deploy Stacks / Deploy Stacks (push) Successful in 6s
Checks / Lint (push) Successful in 33s
2026-12-04 04:21:47 +01:00
kasun 69a1c0a9fb docs: keep imported secret values as they are
Checks / Secret Scan (pull_request) Successful in 6s
Checks / Lint (pull_request) Successful in 46s
2026-12-04 04:20:25 +01:00
kasun 6e2dd06b9e feature(stacks): adopt gitea with secrets from OpenBao
Checks / Secret Scan (pull_request) Successful in 8s
Checks / Lint (pull_request) Successful in 1m15s
Gitea runs the deploy pipeline, so it gets its own playbook that is run by
hand and never from a workflow.
2026-12-04 04:09:41 +01:00
kasun 5309aa0cdd docs: document handling secrets with OpenBao 2026-12-04 04:09:39 +01:00
kasun 27240cef17 feature(roles): render stack env files from OpenBao
Stacks with an env.j2 get their .env from OpenBao, so secrets stay out of the
repo. The address and AppRole credentials are read from files on the ansible
LXC, which keeps hostnames out of the public repo.
2026-12-04 04:09:38 +01:00
claude-bot Bot 90324a0501 Merge pull request 'Feature: Deploy stacks automatically on merge' (#17) from feature/deploy-stacks-on-merge into main
Checks / Secret Scan (push) Successful in 5s
Deploy Stacks / Deploy Stacks (push) Successful in 4s
Checks / Lint (push) Successful in 24s
2026-11-27 21:44:55 +01:00
kasun 4852971991 docs: note that merging a stack change deploys it
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 21s
2026-11-27 21:43:06 +01:00
kasun 4d8c3cc0b4 feature(ci): deploy stacks on push to main 2026-11-27 21:43:02 +01:00
claude-bot Bot 431702ff74 Merge pull request 'Bug: Create the stack directory on first deploy' (#16) from bug/create-missing-stack-directory into main
Checks / Secret Scan (push) Successful in 6s
Checks / Lint (push) Successful in 33s
2026-11-27 21:30:30 +01:00
kasun 67addcbe1b bug(roles): create stack directory before copying compose file
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 21s
The first deployment of a new stack failed because the copy task does not
create the missing destination directory.
2026-11-27 21:29:02 +01:00
claude-bot Bot e654ae3bec Merge pull request 'Feature: Deploy it-tools through Ansible' (#15) from feature/adopt-it-tools-stack into main
Checks / Secret Scan (push) Successful in 5s
Checks / Lint (push) Successful in 22s
2026-11-27 21:10:25 +01:00
kasun 1b25ff1450 docs: drop the dry run requirement for adopting a stack
Checks / Secret Scan (pull_request) Successful in 6s
Checks / Lint (pull_request) Successful in 20s
2026-11-27 21:08:21 +01:00
kasun a23ba7bee8 feature(ci): add manual deploy stacks workflow 2026-11-27 21:08:17 +01:00
kasun 1b05e959e3 feature(stacks): adopt it-tools stack
The image stays on latest with its Watchtower label until there is an
image pinning strategy.
2026-11-27 21:08:13 +01:00
kasun 0289a216ba feature(roles): add docker_stack role 2026-11-27 21:08:10 +01:00
kasun 660765d1c6 chore: pin community.docker and install it in CI
ansible-core ships only ansible.builtin, so ansible-lint cannot resolve
community.docker modules without the collection.
2026-11-27 21:08:07 +01:00
claude-bot Bot 3b5d3b7b17 Merge pull request 'Chore: Add /merge skill with an enforced review gate' (#13) from chore/add-merge-skill into main
Checks / Secret Scan (push) Successful in 6s
Checks / Lint (push) Successful in 9s
2026-11-27 04:01:56 +01:00
kasun 1e02dd5930 chore(claude): close remaining gaps in the merge gate
Checks / Secret Scan (pull_request) Successful in 8s
Checks / Lint (pull_request) Successful in 9s
Gitea's issue comments endpoint ignores paging, so the hook now reads all
comments in one call; the paged loop refused every merge. Any command that
calls gitea.sh and mentions a merge must now be the strict form as a whole,
while commands that only name gitea.sh as a file (git add, git diff) pass.
The body may only pin the head commit, and curl calls have time limits so
the hook can't time out into a non-blocking error.
2026-11-27 03:57:18 +01:00
kasun f45fb7421a chore(claude): make the merge gate fail closed
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 10s
The first review found ways around the hook: unexpected errors exited with
non-blocking codes, unusual spellings of the merge path skipped it, and an
older pass outlived a newer fail. The ask rule for merges is back as a second
layer, so merging outside /merge is enforced, not just instructed.
2026-11-27 03:39:19 +01:00
kasun 737a3a29ec chore(claude): add merge skill with review gate
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 12s
/merge takes changes from commit to merged PR in one run. A PreToolUse hook
refuses any merge without a passing review comment for the PR's current head
commit, so the review can't be skipped or go stale after new commits.
2026-11-27 03:27:38 +01:00
claude-bot Bot 2c3d58d678 Merge pull request 'Feature: Add Ansible foundation and connectivity check' (#2) from feature/add-ansible-foundation into main
Checks / Secret Scan (push) Successful in 5s
Checks / Lint (push) Successful in 9s
2026-11-26 01:33:31 +01:00
kasun 2d24f767e1 feature: add ansible foundation and connectivity check
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 9s
First read-only run on the dedicated ansible runner proves the inventory, SSH access and Docker on the docker host before any stack is adopted.
2026-11-25 20:20:37 +01:00
kasun 6d404e2b21 chore(claude): add repo conventions and agent guardrails 2026-11-23 21:55:51 +01:00
29 changed files with 997 additions and 1 deletions

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Stop hook: makes Claude fix lint errors before it can finish a reply.
#
# When YAML files have uncommitted changes, run yamllint and ansible-lint from
# .venv. On failure, exit 2 sends the errors back to Claude. It never contacts a
# host. If .venv doesn't exist it does nothing, and CI still runs both linters.
input=$(cat)
# Set when Claude is already continuing because of this hook; stopping here
# prevents an endless loop if it can't fix the error.
[[ "$(jq -r '.stop_hook_active // false' <<<"$input")" == "true" ]] && exit 0
cd "$CLAUDE_PROJECT_DIR" || exit 0
[[ -x .venv/bin/yamllint && -x .venv/bin/ansible-lint ]] || exit 0
# -uall lists files inside new folders, not just the folder.
git status --porcelain -uall | grep -qE '\.ya?ml$|\.j2$|\.ansible-lint$' || exit 0
failed=0
for check in ".venv/bin/yamllint --strict ." ".venv/bin/ansible-lint"; do
if ! out=$($check 2>&1); then
echo "'$check' failed, fix before finishing:" >&2
tail -n 30 <<<"$out" >&2
failed=1
fi
done
[[ $failed -eq 1 ]] && exit 2
exit 0
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# PreToolUse hook for Bash: forces a permission prompt before any command that
# can reach or change a live host. The ask rules in .claude/settings.json match
# the command text as Claude usually writes it; this catches the same commands
# when they are wrapped (sh -c '...', env VAR=x ..., absolute paths).
set -euo pipefail
input=$(cat)
cmd=$(jq -r '.tool_input.command // empty' <<<"$input")
[ -z "$cmd" ] && exit 0
[[ $cmd =~ ^ansible[[:space:]]+--version[[:space:]]*$ ]] && exit 0
# A tool name must start a word. "/" is allowed before it to catch absolute
# paths, "-" is not, so the folder name homelab-ansible doesn't match.
start='(^|[^[:alnum:]_.-])'
end="([[:space:]\"')]|\$)"
ansible_re="${start}(ansible-playbook|ansible-pull|ansible-console|ansible-vault|ansible)[[:space:]]"
remote_re="${start}(ssh|scp|sftp|rsync)[[:space:]]"
proxmox_re="${start}(pct|qm|pvesh|pvesm|vzdump)[[:space:]]"
docker_re="${start}docker([[:space:]]+compose)?[[:space:]]+([^|;&]*[[:space:]])?(up|down|start|stop|restart|kill|rm|rmi|run|exec|pull|push|create|build|prune|cp|update|rename|pause|unpause|volume|network|system)$end"
what=""
if [[ $cmd =~ $ansible_re ]]; then
what="${BASH_REMATCH[2]}"
elif [[ $cmd =~ $remote_re ]]; then
what="${BASH_REMATCH[2]} to a host"
elif [[ $cmd =~ $proxmox_re ]]; then
what="${BASH_REMATCH[2]} on Proxmox"
elif [[ $cmd =~ $docker_re ]]; then
what="docker ${BASH_REMATCH[4]}"
fi
[ -z "$what" ] && exit 0
reason="Live infrastructure: '$what'. Approve only if you want Claude to run this instead of running it yourself."
jq -n --arg reason "$reason" '{
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "ask",
permissionDecisionReason: $reason
}
}'
+104
View File
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# PreToolUse hook for Bash: refuses a PR merge unless the PR's newest review
# comment is a pass for its current head commit.
#
# Why: the /merge skill tells Claude to review before merging. This hook makes
# skipping the review, or merging after new commits made a review stale, fail
# instead of relying on the instruction alone.
#
# A merge must be exactly one command of the form
# .claude/scripts/gitea.sh POST /repos/OWNER/REPO/pulls/N/merge @/abs/file.json
# where the file is exactly {"Do":"merge","head_commit_id":"<head sha>"}.
# Any other command that calls gitea.sh and mentions "merg" (outside @file
# names) is refused, as are gitea.sh write calls with a path that isn't plain.
# Commands that only name gitea.sh as a file (git add, git diff) pass.
#
# Limits: this catches mistakes and shortcuts, not a deliberate workaround such
# as a script that merges on its own. The ask rule for merges in
# .claude/settings.json and the required checks on the server are the other
# layers. It also can't check that the review behind a marker was done properly.
#
# Fails closed: exit 2 blocks the tool call, and any unexpected error ends in
# exit 2 too, because Claude Code treats other exit codes as non-blocking.
set -uo pipefail
deny() {
echo "Merge refused: $1" >&2
exit 2
}
trap 'rc=$?; if [[ $rc -ne 0 && $rc -ne 2 ]]; then echo "Merge refused: guard-merge.sh failed (exit $rc)" >&2; exit 2; fi' EXIT
input=$(cat)
# Most commands mention neither a merge nor gitea.sh; let them through before parsing.
grep -qiE 'merg|gitea\.sh' <<<"$input" || exit 0
cmd=$(jq -r '.tool_input.command // empty' <<<"$input") || deny "could not read the hook input"
[[ -z $cmd ]] && exit 0
shopt -s nocasematch
# Merges go through gitea.sh only.
if [[ $cmd =~ (curl|wget|http) && $cmd =~ /api/v1 && $cmd =~ merg ]]; then
deny "merge PRs through .claude/scripts/gitea.sh, not curl or wget"
fi
# Only commands that call gitea.sh matter. A call is gitea.sh at the start of a
# command (after ; & | ( a backtick, quote or newline) or after a launcher such
# as xargs or bash. As a plain argument (git add -- .claude/scripts/gitea.sh)
# it is just a file name.
flat=${cmd//$'\n'/;}
launcher='(xargs|env|sh|bash|zsh|exec|command|nohup|time|timeout|sudo|nice|eval)'
call_re="(^|[;&|(\`\"'\$])[[:space:]]*[^[:space:];&|]*gitea\.sh|(^|[[:space:];&|(])${launcher}([[:space:]]+[^[:space:];&|]+)*[[:space:]]+[^[:space:];&|]*gitea\.sh"
[[ $flat =~ $call_re ]] || exit 0
# File names may contain "merge" (e.g. a PR body file); everything else may not,
# unless the whole command is the strict merge form checked below.
without_files=$(sed -E 's/@[^[:space:]]+//g' <<<"$cmd")
if ! [[ $without_files =~ merg ]]; then
# Not a merge. Write calls still need a plain path, so nothing can hide in it.
write_re="gitea\.sh[\"']?[[:space:]]+[\"']?(POST|PUT|PATCH|DELETE)[\"']?[[:space:]]+[\"']?([^[:space:]\"']*)"
if [[ $cmd =~ $write_re ]]; then
path="${BASH_REMATCH[2]}"
safe_path='^/[A-Za-z0-9_/?=&-]+$'
if ! [[ $path =~ $safe_path ]] || [[ $path == *//* ]]; then
deny "gitea.sh write call with a path that isn't plain ($path)"
fi
fi
exit 0
fi
shopt -u nocasematch
strict_re='^(\.claude/scripts/|/[^[:space:]]*/\.claude/scripts/)gitea\.sh POST (/repos/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)/pulls/([0-9]+)/merge @(/[^[:space:];&|<>`$]+)$'
[[ $cmd =~ $strict_re ]] \
|| deny "a merge must be the single command '.claude/scripts/gitea.sh POST /repos/OWNER/REPO/pulls/N/merge @/absolute/body.json'"
repo="${BASH_REMATCH[2]}"
pr="${BASH_REMATCH[3]}"
body_file="${BASH_REMATCH[4]}"
jq -e 'type == "object" and keys == ["Do", "head_commit_id"] and .Do == "merge"' "$body_file" >/dev/null 2>&1 \
|| deny "the merge body must be exactly {\"Do\":\"merge\",\"head_commit_id\":\"<sha>\"}"
gitea="${CLAUDE_PROJECT_DIR:?}/.claude/scripts/gitea.sh"
pr_json=$("$gitea" GET "$repo/pulls/$pr" 2>/dev/null) || deny "could not read PR #$pr"
sha=$(jq -r '.head.sha // empty' <<<"$pr_json" 2>/dev/null) || deny "could not parse PR #$pr"
[[ $sha =~ ^[0-9a-f]{40}$ ]] || deny "could not read the head commit of PR #$pr"
pinned=$(jq -r '.head_commit_id' "$body_file")
[[ $pinned == "$sha" ]] || deny "head_commit_id ($pinned) is not the PR's head commit ($sha)"
# This endpoint returns all comments of the issue and ignores page/limit.
comments=$("$gitea" GET "$repo/issues/$pr/comments" 2>/dev/null) || deny "could not read the comments of PR #$pr"
jq -e 'type == "array"' <<<"$comments" >/dev/null 2>&1 || deny "could not parse the comments of PR #$pr"
reviews='[.[] | select(.user.login == "claude-bot" and (.body | startswith("<!-- claude-review: ")))]'
# An edited review would keep its old position, so edits aren't accepted at all.
jq -e "$reviews | all(.updated_at == .created_at)" <<<"$comments" >/dev/null \
|| deny "a review comment on PR #$pr was edited; post a new review instead"
latest=$(jq -r "$reviews | sort_by(.created_at, .id) | last | .body // \"\"
| (split(\"\n\")[0] // \"\") | sub(\"[[:space:]]+\$\"; \"\")" <<<"$comments") \
|| deny "could not read the review markers of PR #$pr"
[[ $latest == "<!-- claude-review: pass $sha -->" ]] \
|| deny "the newest review of PR #$pr is not a pass for head commit $sha (found: ${latest:-none}). Run the review step of /merge first."
exit 0
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env bash
# Gitea API helper so Claude Code can work with pull requests.
#
# Why: the remote is a self-hosted Gitea, so the GitHub CLI `gh` doesn't work.
# This script calls the Gitea API instead, as the claude-bot account, so PRs
# show up as the bot's work and it only has the rights you gave it.
#
# Scope: PRs (list, open, check CI status, comment, merge), and issues when the
# user asks. Technically it can call any endpoint; CLAUDE.md limits its use.
# In .claude/settings.json, GET and POST (e.g. opening a PR) run without a
# prompt. Merging a PR (POST .../merge), PATCH, PUT and DELETE always ask first,
# and .claude/hooks/guard-merge.sh refuses a merge without a passing review.
#
# Usage: gitea.sh METHOD PATH [BODY]
# METHOD GET | POST | PATCH | PUT | DELETE
# PATH path below /api/v1, e.g. /repos/kasun/homelab-ansible/pulls?state=open
# BODY JSON string, or @file to send a file
#
# Read-only CI wait: gitea.sh WAIT /repos/OWNER/REPO/commits/SHA/status
# Polls until checks finish. Exit 0: passed or no CI ran. 1: a check failed.
# 2: bad usage. 3: timed out after 15 minutes.
#
# Config (outside the repo, never committed):
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/url e.g. http://gitea.example:3000
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/token chmod 600
# Token: Site Administration → Identity & Access → User Accounts → claude-bot → generate
# (write:repository, write:issue). claude-bot is a collaborator with Write on the repo.
#
# Adapted from the deverenz repo (.claude/scripts/gitea.sh).
set -euo pipefail
method=${1:?usage: gitea.sh METHOD PATH [BODY]}
path=${2:?usage: gitea.sh METHOD PATH [BODY]}
body=${3:-}
if [[ "$method" == "WAIT" ]]; then
[[ "$path" =~ ^/repos/[^/]+/[^/]+/commits/[0-9a-f]{40}/status$ ]] \
|| { echo "WAIT only accepts /repos/OWNER/REPO/commits/SHA/status" >&2; exit 2; }
for ((i = 1; i <= 45; i++)); do
status=$("$0" GET "$path") || status='{}'
total=$(jq '.statuses // [] | length' <<<"$status")
running=$(jq '[.statuses // [] | .[] | select(.status == "pending" or .status == "running")] | length' <<<"$status")
# Give checks time to register. Path-filtered workflows may never start any.
if (( total == 0 && i >= 7 )); then
echo "no CI ran"
exit 0
fi
if (( total > 0 && running == 0 && i >= 4 )); then
jq -r '.statuses[] | "\(.context): \(.status) \(.target_url)"' <<<"$status"
jq -e '[.statuses[].status] | any(. == "failure" or . == "error") | not' <<<"$status" >/dev/null || exit 1
exit 0
fi
sleep 20
done
echo "timed out waiting for CI" >&2
exit 3
fi
case "$method" in
GET | POST | PATCH | PUT | DELETE) ;;
*) echo "unsupported method: $method" >&2; exit 2 ;;
esac
config=${XDG_CONFIG_HOME:-$HOME/.config}/homelab-agent
for f in url token; do
[[ -s "$config/$f" ]] || { echo "missing $config/$f" >&2; exit 2; }
done
url=$(<"$config/url")
token=$(<"$config/token")
# Time limits keep callers such as guard-merge.sh within their hook timeout.
args=(-sS --fail-with-body --connect-timeout 5 --max-time 20 -X "$method" -H "Accept: application/json")
# The token header is read from stdin so it never shows up in the process list.
args+=(-H @-)
if [[ -n "$body" ]]; then
[[ "$body" == "@-" ]] && { echo "BODY from stdin is not supported, use @file" >&2; exit 2; }
args+=(-H "Content-Type: application/json" --data-binary "$body")
fi
out=$(curl "${args[@]}" "${url%/}/api/v1${path}" <<<"Authorization: token $token") \
|| { echo "$out" >&2; exit 1; }
if command -v jq >/dev/null && [[ -n "$out" ]]; then
jq . <<<"$out" 2>/dev/null || echo "$out"
else
echo "$out"
fi
+119
View File
@@ -0,0 +1,119 @@
{
"permissions": {
"defaultMode": "plan",
"disableAutoMode": "disable",
"allow": [
"Bash(.venv/bin/yamllint *)",
"Bash(.venv/bin/ansible-lint *)",
"Bash(.venv/bin/ansible-lint)",
"Bash(ansible --version)",
"Bash(ansible-doc *)",
"Bash(git log *)",
"Bash(git status *)",
"Bash(git diff *)",
"Bash(git show *)",
"Bash(git grep *)",
"Bash(git blame *)",
"Bash(git ls-files *)",
"Bash(git ls-tree *)",
"Bash(git rev-parse *)",
"Bash(git describe *)",
"Bash(git shortlog *)",
"Bash(git merge-base *)",
"Bash(git reflog show *)",
"Bash(git stash list *)",
"Bash(git branch --list *)",
"Bash(git branch -a *)",
"Bash(git branch -v *)",
"Bash(git tag --list *)",
"Bash(git remote -v)",
"Bash(git fetch *)",
"Bash(git add *)",
"Bash(git switch *)",
"Bash(git commit *)",
"Bash(git push *)",
"Bash(ls *)",
"Bash(pwd)",
"Bash(wc *)",
"Bash(which *)",
"Bash(jq *)",
"Bash(.claude/scripts/gitea.sh GET *)",
"Bash(.claude/scripts/gitea.sh WAIT *)",
"Bash(.claude/scripts/gitea.sh POST *)",
"WebFetch(domain:docs.ansible.com)",
"WebFetch(domain:docs.docker.com)",
"WebFetch(domain:docs.gitea.com)",
"WebFetch(domain:github.com)",
"WebFetch(domain:raw.githubusercontent.com)"
],
"ask": [
"Bash(ansible *)",
"Bash(ansible-playbook *)",
"Bash(ansible-pull *)",
"Bash(ansible-console *)",
"Bash(ansible-vault *)",
"Bash(ssh *)",
"Bash(scp *)",
"Bash(sftp *)",
"Bash(rsync *)",
"Bash(docker *)",
"Bash(pct *)",
"Bash(qm *)",
"Bash(curl *)",
"Bash(.claude/scripts/gitea.sh POST */merge*)",
"Bash(.claude/scripts/gitea.sh PATCH *)",
"Bash(.claude/scripts/gitea.sh PUT *)",
"Bash(.claude/scripts/gitea.sh DELETE *)"
],
"deny": [
"Bash(env)",
"Bash(printenv *)",
"Bash(ansible-vault view *)",
"Bash(ansible-vault decrypt *)",
"Bash(*/etc/homelab-ansible*)",
"Bash(*homelab-agent/token*)",
"Read(**/.env)",
"Read(**/.env.*)",
"Read(**/vault.yml)",
"Read(**/vault.yaml)",
"Read(**/.vault_pass*)",
"Read(//etc/homelab-ansible/**)",
"Edit(//etc/homelab-ansible/**)",
"Read(~/.config/homelab-agent/token)",
"Edit(~/.config/homelab-agent/**)"
]
},
"attribution": {
"commit": "",
"pr": ""
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/guard-live-infra.sh"
},
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/guard-merge.sh",
"timeout": 90
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check-on-stop.sh",
"timeout": 300
}
]
}
]
}
}
+111
View File
@@ -0,0 +1,111 @@
---
name: merge
description: Commit the working tree changes that fit the branch, push, open a Gitea PR, wait for CI, review the PR with /code-review, and merge it, without stopping for confirmation.
argument-hint: [optional note on intent, or paths to limit the merge to]
disable-model-invocation: true
---
Take the working tree changes through commit, push, PR, review and merge in one run. If `$ARGUMENTS` names paths, include only those. If it describes intent, use it for the commit messages and PR.
Typing `/merge` is the user's explicit instruction to commit, push, open a PR and merge these changes. It satisfies the "commit" and PR rules in `CLAUDE.md` for this run. Do not ask for confirmation, and do not pause to show drafts. Stop only for a condition under "Stop conditions".
## Rules
- Follow `CONVENTIONS.md` for branch names, commit messages and PR titles. The allowed commit scopes are in `.githooks/commit-msg`.
- Add no AI attribution to commits, PRs or comments.
- Never use `--no-verify`, force push, or commit directly to `main`.
- Never run `ansible`, `ansible-playbook` (not even `--check`), SSH or Docker commands. This skill changes git and Gitea only.
- Use `.claude/scripts/gitea.sh` for Gitea calls, because `gh` does not work here. `$REPO` below means `/repos/kasun/homelab-ansible`, and must be written out in full in each command.
- Never stage `vault.yml`, `.vault_pass*`, `.env` files, private keys, credentials, `.claude/settings.local.json` or `.venv/`. Leave them out, carry on, and mention them in the report.
- Write commit messages, JSON bodies and the review comment to files in the scratchpad directory with the Write tool.
- Run each command on its own, in the exact forms below, from the repo root. `cd` prefixes, pipes, loops and redirects cause permission prompts.
## Stop conditions
Stop and report only if:
- HEAD is detached, or a merge or rebase is in progress.
- There are no changes and no unpushed commits.
- yamllint or ansible-lint fails.
- A file that looks like a secret is the only change.
- A commit hook, push or API call fails after one corrected retry of a message-format error.
- CI fails, or the PR is not mergeable.
- The review leaves an important finding open (step 7).
- The merge hook denies the merge.
Leave the branch and PR in place when stopping after they exist, and say what is needed to continue.
## 1. Inspect
1. Run `git status`, `git diff --staged`, `git diff`, and `git log --oneline -5`. Read any untracked files that would be included.
2. Run `git fetch origin main`.
3. On a non-`main` branch, run `.claude/scripts/gitea.sh GET $REPO/pulls?state=open`. If this branch has an open PR, reuse it only for changes that serve its purpose. If all remaining changes are unrelated to it, take that PR through steps 6 to 8 first, which returns you to `main`, then continue with the remaining changes as new work.
## 2. Group into commits
Split by reason for the change, and decide without asking. Each commit should make sense and be revertable alone.
- First decide the PR's purpose from `$ARGUMENTS`, the conversation, the branch name, or else the largest change.
- On the first `/merge`, leave out any change that does not serve that purpose. Keep it uncommitted and untouched, do not ask, and list it in the report.
- On a repeat `/merge`, meaning an earlier run this session left changes out or its PR is still open, handle all remaining changes in this run. Give each separate purpose its own branch and PR, and take them one at a time through steps 3 to 8, so each is merged and you are back on `main` before the next starts. If `$ARGUMENTS` names paths, handle only those.
- Use one commit when the remaining changes serve one purpose, and several when they are distinct steps toward it.
- Group whole files. If one file mixes purposes, put it in the commit for its main change.
- Scope: `ci` for `.gitea/workflows/`, `claude` for `.claude/`, otherwise the top-level folder if it is an allowed scope. Omit the scope for repo-wide changes.
- Add a body only when the diff shows a reason that is not obvious. Never invent a reason.
## 3. Verify
Run `.venv/bin/yamllint --strict .` and `.venv/bin/ansible-lint`. Both must pass. Dry runs against hosts belong in CI, not here.
## 4. Commit and push
1. If on `main`, run `git switch -c <type>/<short-kebab-description>`. This carries the changes across.
2. For each commit, run `git add -- <paths>`, then `git commit -F <message file> -- <paths>`. Naming the paths commits only those files, whatever else is staged.
3. Run `git status` to confirm only intentionally excluded files remain.
4. Run `git push -u origin <branch>`.
## 5. Open the PR
Unless one exists, run `.claude/scripts/gitea.sh POST $REPO/pulls @<json file>` with `title`, `body`, `head` and `base: "main"`. The body says what changed and why.
## 6. Wait for CI
Get the SHA with `git rev-parse HEAD`, then run `.claude/scripts/gitea.sh WAIT $REPO/commits/<sha>/status` as a background command. Do not write a polling loop, because that causes a permission prompt.
- Exit 0: checks passed, or it printed `no CI ran` because workflows are path-filtered. Continue.
- Exit 1: stop, and report the failing check and its `target_url`.
- Exit 3: CI timed out. Stop and report it.
Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergeable` is true and `head.sha` equals the SHA from `git rev-parse HEAD`.
## 7. Review
1. Invoke the `code-review` skill with `medium origin/main...HEAD`. Wait for its findings, also if it runs in the background.
2. Check each finding against the code and the PR's purpose. Classify it as **important** (a real bug or broken `CLAUDE.md` rule this PR adds), **pre-existing**, or **nit**, and drop findings that don't hold up.
3. Write the review comment to a file. First line, exactly one of:
- `<!-- claude-review: pass <sha> -->` when no important finding is left
- `<!-- claude-review: fail <sha> -->` otherwise
Then a `## Review` heading, the effort level, and one line per finding: `path:line`, what is wrong, its class. Write `No findings.` if there are none.
4. Run `.claude/scripts/gitea.sh POST $REPO/issues/<number>/comments @<json file>` with `{"body": "<comment>"}`.
5. On `fail`, stop and report the important findings. Do not fix them in this run; the user decides.
Never edit a review comment; post a new one. The merge hook refuses PRs with edited review comments.
Never write a `pass` marker for a SHA you did not review, or when an important finding is open. The merge hook only checks that the marker exists, so the honesty of the marker is on you.
## 8. Merge
1. Run `.claude/scripts/gitea.sh POST $REPO/pulls/<number>/merge @<absolute path of json file>` with exactly `{"Do":"merge","head_commit_id":"<sha>"}` and no other fields, so only the commit CI and the review checked can merge. Run it exactly in this form, alone. The `guard-merge.sh` hook refuses any other form, and refuses the call unless the newest review comment is a `pass` for this SHA. This call asks the user for permission: that prompt is the one intended pause of the run. If the user declines, stop.
2. Run `git fetch origin main:main`, then `git switch main`.
## 9. Report
Keep it short:
- PR link and commits.
- The review result, with any pre-existing findings or nits worth a follow-up.
- What the merge triggers, from `on.push` in `.gitea/workflows/`. Say whether the PR touched a `deploy-stacks.yaml` path, and so deployed.
- Anything left uncommitted.
Do not delete the branch, dispatch a workflow, or change a live system.
+18
View File
@@ -0,0 +1,18 @@
name: Check Connectivity
on:
workflow_dispatch:
jobs:
check-connectivity:
name: Check Connectivity
runs-on: ansible
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Show Ansible Version
run: ansible-playbook --version
- name: Run Connectivity Playbook
run: ansible-playbook playbooks/check-connectivity.yml
+3
View File
@@ -48,6 +48,9 @@ jobs:
- name: Install Lint Tools - name: Install Lint Tools
run: pip install -r requirements-dev.txt run: pip install -r requirements-dev.txt
- name: Install Ansible Collections
run: ansible-galaxy collection install -r collections/requirements.yml
- name: Run yamllint - name: Run yamllint
run: yamllint --strict . run: yamllint --strict .
+28
View File
@@ -0,0 +1,28 @@
name: Deploy Stacks
on:
workflow_dispatch:
push:
branches:
- main
paths:
- stacks/**
- roles/docker_stack/**
- playbooks/docker_stacks.yml
- inventory/**
- collections/requirements.yml
- .gitea/workflows/deploy-stacks.yaml
jobs:
deploy-stacks:
name: Deploy Stacks
runs-on: ansible
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ansible Collections
run: ansible-galaxy collection install -r collections/requirements.yml
- name: Run Stacks Playbook
run: ansible-playbook playbooks/docker_stacks.yml --diff
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Git commit-msg hook: rejects commit messages that don't follow CONVENTIONS.md.
#
# Checks:
# - first line is `<type>(<scope>): <summary>` with a known type, an optional
# known scope, and no period at the end
# - no AI attribution lines
#
# Activate once per clone: git config core.hooksPath .githooks
msg_file="$1"
first_line=$(grep -v '^#' "$msg_file" | head -n1)
# Let git's own merge/revert/fixup messages through.
[[ "$first_line" =~ ^(Merge|Revert|fixup!|squash!) ]] && exit 0
types='feature|bug|enhancement|chore|docs'
scopes='ci|claude|inventory|playbooks|roles|scripts|stacks'
pattern="^($types)(\(($scopes)\))?: .*[^.]$"
if ! [[ "$first_line" =~ $pattern ]]; then
echo "commit-msg: '$first_line'" >&2
echo " expected '<type>(<scope>): <summary>' with no trailing period (see CONVENTIONS.md)" >&2
echo " types: ${types//|/ }" >&2
echo " scopes: ${scopes//|/ } (optional)" >&2
exit 1
fi
if grep -qiE '^(Co-Authored-By:.*(claude|anthropic)|.*Generated with \[?Claude)' "$msg_file"; then
echo "commit-msg: no AI attribution lines (see CLAUDE.md)" >&2
exit 1
fi
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Git pre-commit hook: blocks a commit if its staged changes contain a secret.
#
# Activate once per clone: git config core.hooksPath .githooks
if ! command -v betterleaks >/dev/null 2>&1; then
echo "pre-commit: betterleaks is not installed, so staged changes can't be scanned" >&2
exit 1
fi
exec betterleaks git --pre-commit --staged --redact --no-banner --no-color .
+51
View File
@@ -0,0 +1,51 @@
# CLAUDE.md
Ansible automation for a Proxmox homelab. It deploys Docker stacks and single scripts into containers and LXCs, from git, through Gitea Actions.
## Hosts
- `ansible`: unprivileged LXC that runs Ansible and has SSH key access to `docker`.
- `docker`: unprivileged LXC running Gitea, its Actions runner, Postgres and the apps. Compose files live in `/home/pi/docker/<service>/docker-compose.yml`.
## Layout (planned)
`inventory/{hosts.yml,group_vars/}`, `roles/{docker_stack,script,lxc_base}`, `stacks/<service>/{docker-compose.yml,env.j2}`, `scripts/`, `playbooks/`, `.gitea/workflows/`.
## Deployment flow
Branch → PR (lint, secret scan, later `--check --diff`) → merge to protected `main` → dedicated runner on the `ansible` LXC (`runs-on: ansible`) → playbook over SSH → restart only changed stacks → health check. Roll back with `git revert`.
## Rules for stacks
- Keep the `/home/pi/docker/<service>/` paths, because Compose derives the project name from the folder.
- Ansible manages config, never data. No ownership changes under `DOCKER_DATA_ROOT` (mapped UIDs).
- When adopting a stack: remove its Watchtower label. Pinning images is a later task I'll do myself; don't flag unpinned or `:latest` images.
- Gitea, its runner and Postgres never auto-deploy. I trigger them from the `ansible` LXC.
## Secrets
- The real vault file and password live in `/etc/homelab-ansible/` on the `ansible` LXC, never in git. Commit only `vault.example.yml`.
- This repo is meant to become public. Don't commit secrets, internal IPs or hostnames beyond the inventory aliases.
## Live infrastructure
- Don't change live systems (hosts, containers, Proxmox, Gitea settings) on your own initiative, even for small or reversible changes. Give me the exact steps and let me decide who runs them.
- That includes `ansible`, `ansible-playbook` (even with `--check`), SSH and Docker commands against a host.
- Code edits in the repo are fine without asking.
- Never recreate a VM or LXC to apply a change.
## Git conventions
Branch names, commit messages and PR titles follow @CONVENTIONS.md. The git hooks need `git config core.hooksPath .githooks` once per clone.
Only commit when I explicitly say "commit" for that change. A yes to a question that also mentioned committing is not enough; when unsure, ask.
The remote is a self-hosted Gitea, so `gh` doesn't work. For PRs and their CI status use `.claude/scripts/gitea.sh` (acts as `claude-bot`), e.g. `.claude/scripts/gitea.sh GET '/repos/kasun/homelab-ansible/pulls?state=open'`. Use it for PRs, and for issues when I ask. Reading from Gitea is free.
Open and merge PRs through `/merge`: typing it is my OK to commit, open a PR and merge for that run. Outside `/merge`, ask first. Every merge call asks for permission (also inside `/merge`), and `.claude/hooks/guard-merge.sh` refuses it unless the PR's newest review comment is a pass for its head commit. Merging deploys: a push to `main` that touches the paths in `.gitea/workflows/deploy-stacks.yaml` runs the stacks playbook, so allowing the merge prompt is also my OK to deploy.
## Verifying changes
Install the lint tools once with `python3 -m venv .venv` and `.venv/bin/pip install -r requirements-dev.txt`. After editing, run `.venv/bin/yamllint --strict .` and `.venv/bin/ansible-lint`, and show the output.
Don't silence a check to make it pass (`# noqa`, lint skip lists, `git commit --no-verify`) without a stated reason and my OK.
+51
View File
@@ -0,0 +1,51 @@
# Git Conventions
## Branch Naming
```
<type>/<short-kebab-case-description>
```
- All lowercase, hyphens only
- Keep the description short (3–5 words)
- No ticket tracker is used, so branch names don't carry an ID
| Type | Use for |
|---|---|
| `feature/` | New functionality (e.g. a new role, a newly adopted stack) |
| `bug/` | Bug fixes |
| `enhancement/` | Improvements or refactors to existing functionality, no new capability |
| `chore/` | Dependency bumps, tooling, CI/CD, cleanup |
| `docs/` | Documentation only |
**Examples:** `feature/adopt-uptime-kuma-stack`, `bug/fix-stack-health-check`, `chore/pin-ansible-lint`
---
## Commit Messages
```
<type>(<scope>): <imperative, present-tense summary>
<optional body: explain WHY, not WHAT>
```
- **Type**: same list as the branch types above
- **Scope**: optional. The allowed values are defined in `.githooks/commit-msg`, which enforces them
- **Summary**: imperative mood ("add", not "added" or "adds"), no period at the end
- **Body**: only when the reasoning isn't obvious from the diff
---
## Pull Request Titles
Gitea's merge commit reuses the PR title as its summary, so the title should stand on its own in `git log`. Describe the outcome:
```
<Type>: <what changes for the homelab>
```
**Examples:**
- `Feature: Deploy Uptime Kuma through Ansible`
- `Bug: Fix health check for stacks without a published port`
- `Chore: Add secret scan and lint checks`
+97 -1
View File
@@ -1,3 +1,99 @@
# homelab-ansible # homelab-ansible
Ansible automation for my Proxmox homelab. Deploys Docker stacks, scripts and LXC configuration through Gitea Actions. Ansible automation for my Proxmox homelab. Deploys Docker stacks, scripts and LXC configuration through Gitea Actions.
## Secrets
Stack secrets live in [OpenBao](https://openbao.org/), never in this repository. When a stack needs secrets, the deploy reads them from OpenBao on the Ansible controller and writes them to the stack's `.env` file on the Docker host. The Docker host never talks to OpenBao.
### How it works
- Secrets are stored in a KV version 2 engine, one secret per stack, at `<mount>/docker/<stack>`. Each key in the secret becomes one variable in the stack's `.env`.
- Ansible logs in with an AppRole whose policy can only read under `docker/`.
- The OpenBao address and the AppRole's role ID and secret ID are kept in files on the controller, in the folder that `homelab_secrets_dir` points to. They are never committed.
- If `stacks/<stack>/env.j2` exists, the `docker_stack` role reads the secret, renders the template to `.env` with mode `600`, and starts the stack. These tasks use `no_log` and `diff: false`, so values never appear in job logs.
### One-time setup
**In OpenBao**
1. Enable a KV version 2 secrets engine, or use an existing one. Set `homelab_bao_kv_mount` to its path.
2. Create a read-only ACL policy for the Docker deploys:
```hcl
path "<mount>/data/docker/*" { capabilities = ["read"] }
path "<mount>/metadata/docker/*" { capabilities = ["read", "list"] }
```
3. Enable the AppRole auth method, then create a role with that policy and a short token lifetime:
```
write auth/approle/role/<role> token_policies=<policy> token_ttl=15m token_max_ttl=30m
read auth/approle/role/<role>/role-id
write -f auth/approle/role/<role>/secret-id
```
These commands work in the UI's built-in console (the `>_` icon), or with the `bao` CLI if you prefix them with `bao`.
**On the Ansible controller**
1. Create the secrets folder, readable only by the user that runs the CI runner:
```bash
sudo install -d -m 750 -o root -g <runner-user> <secrets-dir>
```
2. Create three files in it, each owned by the runner user with mode `600`:
- `bao-url`: the OpenBao address
- `bao-role-id`: the role ID
- `bao-secret-id`: the secret ID
Put only the value in each file.
3. Install the Python library `hvac` into the Python environment Ansible runs from. The `community.hashi_vault` collection needs it, and the collection itself is installed from `collections/requirements.yml` on every deploy.
The OpenBao CLI is not needed on the controller. Ansible uses the HTTP API through `hvac`.
### Adding secrets to a stack
1. In OpenBao, create a secret at `docker/<stack>` in the KV engine. To import an existing `.env`, convert it to JSON and paste it into the UI's JSON editor:
```bash
jq -Rn '[inputs | select(test("^[A-Za-z_][A-Za-z0-9_]*=")) | capture("^(?<key>[^=]+)=(?<value>.*)$")] | from_entries' .env
```
The role writes values back unquoted, as `KEY=value`, so Compose reads them the same way it reads the original file. Import values exactly as they appear. When you set a new value, avoid `$`, `#`, quotes and spaces: Compose would interpret them.
2. Add `stacks/<stack>/env.j2` with one line per variable:
```
DB_PASSWORD={{ docker_stack_secrets.DB_PASSWORD }}
```
List every key explicitly. If a key is missing in OpenBao, the deploy fails instead of writing an empty value.
3. Deploy the stack. Compose reads `.env` from the stack folder automatically.
### Changing a secret
Save a new version of the secret in OpenBao, then deploy the stack again. Ansible rewrites `.env`, and Compose recreates the containers whose environment changed.
### Adding another consumer
Give each system that reads secrets its own prefix (for example `k8s/` next to `docker/`), its own policy and its own login. Never use a policy that covers several prefixes, so that one compromised consumer can't read another's secrets.
### Troubleshooting
| Symptom | Cause |
|---|---|
| Login fails | Wrong role ID or secret ID, or extra characters in the files |
| `permission denied` when reading | The policy path doesn't match the secret's path, or the token has expired |
| Reading returns no data | No secret exists at that path |
| A deleted secret is still listed | The UI's Delete is a soft delete in KV version 2. Run `delete <mount>/metadata/<path>` in the console to remove it with all its versions |
To test access from the controller without Ansible:
```bash
TOKEN=$(curl -s "$BAO_ADDR/v1/auth/approle/login" \
-d "{\"role_id\":\"$ROLE_ID\",\"secret_id\":\"$SECRET_ID\"}" | jq -r .auth.client_token)
curl -s -H "X-Vault-Token: $TOKEN" "$BAO_ADDR/v1/<mount>/data/docker/<stack>" | jq '.data.data | keys'
```
It should print the secret's key names, never the values.
+9
View File
@@ -0,0 +1,9 @@
[defaults]
inventory = inventory/hosts.yml
roles_path = roles
host_key_checking = True
interpreter_python = auto_silent
retry_files_enabled = False
[ssh_connection]
pipelining = True
+6
View File
@@ -0,0 +1,6 @@
---
collections:
- name: community.docker
version: "5.4.1"
- name: community.hashi_vault
version: "7.1.0"
+9
View File
@@ -0,0 +1,9 @@
---
# Files on the ansible LXC that hold deploy credentials. They are never committed.
homelab_secrets_dir: /etc/homelab-ansible
# OpenBao address and AppRole login, read on the ansible LXC when a stack needs secrets.
homelab_bao_url: "{{ lookup('ansible.builtin.file', homelab_secrets_dir + '/bao-url') }}"
homelab_bao_role_id: "{{ lookup('ansible.builtin.file', homelab_secrets_dir + '/bao-role-id') }}"
homelab_bao_secret_id: "{{ lookup('ansible.builtin.file', homelab_secrets_dir + '/bao-secret-id') }}"
homelab_bao_kv_mount: secret
+3
View File
@@ -0,0 +1,3 @@
---
# Compose derives each project name from its folder, so these paths must not change.
homelab_stacks_root: /home/pi/docker
+11
View File
@@ -0,0 +1,11 @@
---
# On the ansible LXC, ~/.ssh/config maps "docker" to its real address, user and key.
all:
children:
control:
hosts:
ansible:
ansible_connection: local
docker_hosts:
hosts:
docker:
+35
View File
@@ -0,0 +1,35 @@
---
# Read-only: proves Ansible can reach each host. It changes nothing.
- name: Check that every host responds
hosts: all
gather_facts: false
tasks:
- name: Ping host
ansible.builtin.ping:
- name: Check the Docker host
hosts: docker_hosts
gather_facts: false
tasks:
- name: Read Docker Compose version
ansible.builtin.command: docker compose version
register: check_connectivity_compose
changed_when: false
check_mode: false
- name: Show Docker Compose version
ansible.builtin.debug:
msg: "{{ check_connectivity_compose.stdout }}"
- name: Read stacks root
ansible.builtin.stat:
path: "{{ homelab_stacks_root }}"
register: check_connectivity_stacks_root
- name: Require stacks root
ansible.builtin.assert:
that:
- check_connectivity_stacks_root.stat.isdir is defined
- check_connectivity_stacks_root.stat.isdir
fail_msg: "{{ homelab_stacks_root }} is missing or is not a directory"
quiet: true
+10
View File
@@ -0,0 +1,10 @@
---
- name: Deploy stacks
hosts: docker_hosts
gather_facts: false
tasks:
- name: Deploy it-tools
ansible.builtin.include_role:
name: docker_stack
vars:
docker_stack_name: it-tools
+12
View File
@@ -0,0 +1,12 @@
---
# Run by hand from the ansible LXC only. Gitea runs the deploy pipeline, so no
# workflow may call this playbook: a broken deploy would take down the pipeline itself.
- name: Deploy Gitea
hosts: docker_hosts
gather_facts: false
tasks:
- name: Deploy gitea
ansible.builtin.include_role:
name: docker_stack
vars:
docker_stack_name: gitea
+1
View File
@@ -1,2 +1,3 @@
ansible-core==2.22.0
ansible-lint==26.11.0 ansible-lint==26.11.0
yamllint==1.38.0 yamllint==1.38.0
+7
View File
@@ -0,0 +1,7 @@
---
docker_stack_root: "{{ homelab_stacks_root }}"
docker_stack_name: ""
docker_stack_src: "{{ playbook_dir }}/../stacks/{{ docker_stack_name }}"
# Stacks with an env.j2 get their .env rendered from this OpenBao KV path.
docker_stack_env_template: "{{ docker_stack_src }}/env.j2"
docker_stack_secret_path: "docker/{{ docker_stack_name }}"
+46
View File
@@ -0,0 +1,46 @@
---
- name: Require a stack name
ansible.builtin.assert:
that:
- docker_stack_name | length > 0
fail_msg: "docker_stack_name must be set"
quiet: true
- name: Create stack directory for {{ docker_stack_name }}
ansible.builtin.file:
path: "{{ docker_stack_root }}/{{ docker_stack_name }}"
state: directory
mode: "0755"
- name: Copy compose file for {{ docker_stack_name }}
ansible.builtin.copy:
src: "{{ docker_stack_src }}/docker-compose.yml"
dest: "{{ docker_stack_root }}/{{ docker_stack_name }}/docker-compose.yml"
mode: "0644"
# no_log and diff: false keep secret values out of the job log, which also runs with --diff.
- name: Read secrets for {{ docker_stack_name }}
ansible.builtin.set_fact:
docker_stack_secrets: >-
{{ lookup('community.hashi_vault.vault_kv2_get', docker_stack_secret_path,
engine_mount_point=homelab_bao_kv_mount,
url=homelab_bao_url,
auth_method='approle',
role_id=homelab_bao_role_id,
secret_id=homelab_bao_secret_id).secret }}
when: docker_stack_env_template is file
no_log: true
- name: Write env file for {{ docker_stack_name }}
ansible.builtin.template:
src: "{{ docker_stack_env_template }}"
dest: "{{ docker_stack_root }}/{{ docker_stack_name }}/.env"
mode: "0600"
when: docker_stack_env_template is file
diff: false
no_log: true
- name: Start {{ docker_stack_name }}
community.docker.docker_compose_v2:
project_src: "{{ docker_stack_root }}/{{ docker_stack_name }}"
state: present
+42
View File
@@ -0,0 +1,42 @@
services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=${NON_ROOT_USER_UID}
- USER_GID=${NON_ROOT_USER_UID}
- GITEA__database__DB_TYPE=${DB_TYPE}
- GITEA__database__HOST=${DB_HOST}
- GITEA__database__NAME=${DB_NAME}
- GITEA__database__USER=${DB_USER}
- GITEA__database__PASSWD=${DB_PASSWD}
- GITEA__server__ROOT_URL=${GITEA__server__ROOT_URL}
restart: always
networks:
- pg_network
volumes:
- ${DOCKER_DATA_ROOT}/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
gitea-runner:
image: gitea/runner:latest
container_name: gitea-runner
restart: always
depends_on:
- server
networks:
- pg_network
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${DOCKER_DATA_ROOT}/gitea-runner:/data
environment:
- GITEA_INSTANCE_URL=${GITEA__server__ROOT_URL}
- GITEA_RUNNER_REGISTRATION_TOKEN=${RUNNER_TOKEN}
- GITEA_RUNNER_NAME=proxmox-lab-runner
- GITEA__server__ROOT_URL=${GITEA__server__ROOT_URL}
networks:
pg_network:
external: true
+10
View File
@@ -0,0 +1,10 @@
# Rendered by Ansible from OpenBao secret/docker/gitea. Do not edit on the host.
NON_ROOT_USER_UID={{ docker_stack_secrets.NON_ROOT_USER_UID }}
DB_TYPE={{ docker_stack_secrets.DB_TYPE }}
DB_HOST={{ docker_stack_secrets.DB_HOST }}
DB_NAME={{ docker_stack_secrets.DB_NAME }}
DB_USER={{ docker_stack_secrets.DB_USER }}
DB_PASSWD={{ docker_stack_secrets.DB_PASSWD }}
GITEA__server__ROOT_URL={{ docker_stack_secrets.GITEA__server__ROOT_URL }}
DOCKER_DATA_ROOT={{ docker_stack_secrets.DOCKER_DATA_ROOT }}
RUNNER_TOKEN={{ docker_stack_secrets.RUNNER_TOKEN }}
+12
View File
@@ -0,0 +1,12 @@
services:
it-tools:
image: corentinth/it-tools:latest
ports:
- 8085:80
restart: unless-stopped
container_name: it-tools
labels:
- "com.centurylinklabs.watchtower.enable=true"
environment:
- PUID=1000
- PGID=1000
+4
View File
@@ -0,0 +1,4 @@
---
# Template only. The real file is /etc/homelab-ansible/vault.yml on the ansible LXC,
# encrypted with ansible-vault and never committed.
vault_example_secret: CHANGE_ME