feat: Ansible role and playbook for setting up a CI node

This commit is contained in:
Lars Wirzenius
2026-05-26 12:05:23 +03:00
parent f9a41d916e
commit 141886f43e
9 changed files with 216 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
install-ci
+18
View File
@@ -0,0 +1,18 @@
# This is a minimal example Ansible playbook to set up a Debian host as a
# Radicle CI node. It uses the ansible/roles/radicle-ci-node role.
#
# The role installs a Radicle node, the CI broker, the Ambient CI engine,
# and a basic configuration. This playbook additionally seeds a Radicle
# repository to trigger a CI run.
- hosts: install-ci
remote_user: debian
become: yes
roles:
- role: radicle-ci-node
tasks:
- shell: |
sudo -i -u ci rad seed rad:z28U8KUBvVSMQc13NydX3LBDsdEdQ
vars:
ansible_python_interpreter: /usr/bin/python3
@@ -0,0 +1,5 @@
:80 {
root * /srv/http/
file_server browse
}
@@ -0,0 +1,10 @@
executor: /usr/bin/ambient-execute-plan
projects: ~/ambient-projects.yaml
artifacts_max_size: 1G
cache_max_size: 50G
uefi: true
qemu:
cpus: 1
memory: 1G
lint: false
@@ -0,0 +1,15 @@
description: |
<p>This is a Radicle CI node.
db: /home/ci/ci.db
report_dir: /srv/http
concurrent_adapters: 1
adapters:
ambient:
command: /bin/radicle-ci-ambient
env:
RADICLE_CI_AMBIENT: /home/ci/radicle-ci-ambient.yaml
triggers:
- adapter: ambient
filters:
- !HasFile ".radicle/ambient.yaml"
@@ -0,0 +1,5 @@
image: /home/ci/ambient.qcow2
logdir: /srv/http/ambient-log
log: /home/ci/radicle-ci-ambient.log
base_url: "http://{{ inventory_hostname }}/ambient-log"
@@ -0,0 +1,16 @@
[Unit]
After=radicle-node.service
Description=Radicle CI broker
[Service]
Type=simple
Environment=RAD_HOME=/home/ci/.radicle
ExecStart=/bin/cib --log-level info --config /home/ci/ci.yaml process-events
KillMode=control-group
Restart=always
RestartSec=1
User=ci
Group=ci
[Install]
WantedBy=default.target
@@ -0,0 +1,16 @@
[Unit]
Description=Radicle Node
After=network-online.target
Requires=network-online.target
[Service]
User=ci
Group=ci
ExecStart=/usr/bin/radicle-node --listen 0.0.0.0:8776 --force
Environment=RAD_HOME=/home/ci/.radicle RUST_BACKTRACE=1 RUST_LOG=debug
KillMode=process
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,130 @@
- name: "is radicle-archive-keyring package installed already?"
shell: |
dpkg -l radicle-archive-keyring | grep '^ii '
register: radicle_archive_keyring
ignore_errors: true
- name: "install tools to install radicle-archive-keyring package"
when: radicle_archive_keyring.rc != 0
apt:
update_cache: true
name:
- curl
- gpg
state: present
- name: "download radicle-arcive-keying and install it"
when: radicle_archive_keyring.rc != 0
shell: |
set -x
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
cd "$tmp"
curl -O -sL https://radicle.xyz/apt/radicle-archive-keyring.deb
dpkg -i radicle-archive-keyring.deb
- name: "add Radicle APT repository to APT sources lists"
apt_repository:
repo: deb [signed-by=/usr/share/radicle/radicle-archive-keyring.asc] https://radicle.xyz/apt release main
- name: "install software for Radicle CI"
apt:
name:
- radicle
- radicle-ci-broker
- radicle-ci-ambient
- ambient-ci
- caddy
- xz-utils
- psmisc
- name: "create user 'ci'"
user:
name: ci
comment: Radicle CI
shell: /bin/bash
groups:
- kvm
- name: "create ~ci/.config/ambient"
file:
state: directory
path: /home/ci/.config/ambient
owner: ci
group: ci
- name: "configure Ambient"
copy:
src: ambient-config.yaml
dest: /home/ci/.config/ambient/config.yaml
- name: "configure caddy"
copy:
src: Caddyfile
dest: /etc/caddy/Caddyfile
- name: "create directory CI broker reports and Ambient run logs on the web"
file:
state: directory
path: /srv/http
owner: ci
group: ci
- name: "configure CI broker"
copy:
src: ci.yaml
dest: /home/ci/ci.yaml
- name: "configure Ambient adapter"
copy:
src: radicle-ci-ambient.yaml
dest: /home/ci/radicle-ci-ambient.yaml
- name: "download a virtual machine image for Ambient"
uri:
url: https://files.liw.fi/ambient/ambient.qcow2.xz
creates: /home/ci/ambient.qcow2.xz
dest: /home/ci/ambient.qcow2.xz
owner: ci
group: ci
- name: "uncompress Ambient VM image, if there's a new one"
shell: |
x=/home/ci/ambient.qcow2
if [ ! "$x" ] || [ "$x.xz" -nt "$x" ]; then
unxz --keep --force "$x.xz"
fi
- name: "set up Radicle node"
shell: |
sudo -i -u ci rad auth --alias "ci-{{ inventory_hostname }}" --stdin </dev/null
- name: "create systemd service for Radicle node"
copy:
src: radicle-node.service
dest: /etc/systemd/system/radicle-node.service
- name: "create systemd service for CI broker"
copy:
src: radicle-ci-broker.service
dest: /etc/systemd/system/radicle-ci-broker.service
- name: "reload systemd daemon"
systemd:
daemon_reload: true
- name: "restart Caddy"
systemd:
name: caddy
state: restarted
- name: "restart Radicle node"
systemd:
name: radicle-node
state: restarted
- name: "restart CI broker"
systemd:
name: radicle-ci-broker
state: restarted