From abc458260c7cee85618757156878c2fad575cb08 Mon Sep 17 00:00:00 2001 From: chrisfu Date: Sun, 21 Jun 2026 15:11:08 -0700 Subject: [PATCH] ansible: lock in docker_build_host role for the arm64 build lane (gandalf) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provisions the docker engine on [build_hosts] (gandalf) for the native arm64 daily knoe-db image build → registry.knoe.dev, run via a remote buildx builder. gandalf is also a k3s_agent, so the role holds iptables FORWARD=ACCEPT to protect k3s pod networking (docker's containerd coexists with k3s's on separate sockets). Verified idempotent: --check against gandalf = ok=5, changed=0. Co-Authored-By: Claude Opus 4.8 --- infrastructure/inventory/hosts.ini | 5 +++ .../playbooks/docker_build_host.yml | 10 ++++++ .../roles/docker_build_host/tasks/main.yml | 35 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 infrastructure/playbooks/docker_build_host.yml create mode 100644 infrastructure/roles/docker_build_host/tasks/main.yml diff --git a/infrastructure/inventory/hosts.ini b/infrastructure/inventory/hosts.ini index 69d7177..4b71c07 100644 --- a/infrastructure/inventory/hosts.ini +++ b/infrastructure/inventory/hosts.ini @@ -24,6 +24,11 @@ gandalf.prole.org k3s_servers k3s_agents +# arm64 docker build host(s) for the native daily knoe-db image lane (→ registry.knoe.dev). +# gandalf is also a k3s_agent; the docker_build_host role keeps FORWARD=ACCEPT so k3s is safe. +[build_hosts] +gandalf.prole.org + [linux_hosts] pi.prole.org raspberry.prole.org diff --git a/infrastructure/playbooks/docker_build_host.yml b/infrastructure/playbooks/docker_build_host.yml new file mode 100644 index 0000000..44d6902 --- /dev/null +++ b/infrastructure/playbooks/docker_build_host.yml @@ -0,0 +1,10 @@ +--- +# Provision docker on the arm64 build host(s) — the native arm64 daily-image lane. +# ansible-playbook infrastructure/playbooks/docker_build_host.yml +# Targets the [build_hosts] inventory group (gandalf). Idempotent: re-running re-asserts +# docker + the FORWARD-policy guard, so the build host survives re-imaging. +- name: Provision docker on arm64 build hosts + hosts: build_hosts + become: true + roles: + - docker_build_host diff --git a/infrastructure/roles/docker_build_host/tasks/main.yml b/infrastructure/roles/docker_build_host/tasks/main.yml new file mode 100644 index 0000000..cab9bd0 --- /dev/null +++ b/infrastructure/roles/docker_build_host/tasks/main.yml @@ -0,0 +1,35 @@ +--- +# docker_build_host — provision the docker engine on an arm64 build host (e.g. gandalf) +# for the native arm64 daily knoe-db image build (push → registry.knoe.dev). Builds run +# in a remote buildx builder (buildkit container) on this host; the dev workstation only +# orchestrates over ssh. +# +# These hosts double as k3s agents, so docker's own containerd coexists with k3s's +# embedded containerd (separate sockets: /run/containerd vs /run/k3s/containerd). The one +# real hazard is docker flipping the iptables FORWARD policy to DROP, which would sever +# k3s pod networking — so we hold it at ACCEPT. We deliberately let docker manage its own +# NAT/iptables otherwise, because the buildkit container needs outbound for registry pulls. + +- name: Install docker engine (docker.io) + ansible.builtin.apt: + name: docker.io + state: present + update_cache: true + +- name: Add the ansible user to the docker group (so buildx can drive docker over ssh) + ansible.builtin.user: + name: "{{ ansible_user | default('ansible') }}" + groups: docker + append: true + +- name: Ensure docker is enabled and running + ansible.builtin.service: + name: docker + enabled: true + state: started + +- name: Hold the iptables FORWARD policy at ACCEPT (protect k3s pod networking from docker) + ansible.builtin.iptables: + chain: FORWARD + policy: ACCEPT + when: "'k3s_agents' in group_names or 'k3s_servers' in group_names"