/
/
/
Ansible role that deployes services on my runner machine
1---
2# The Chamberlain - session and campaign orchestration.
3#
4# Part of the `dnd` compose project rather than its own, because it drives that
5# project by name and a separate project could not reach it.
6#
7# This is the only D&D service an Ansible deploy starts. The table server, the
8# agent and the post-processor all sit behind compose profiles and belong to a
9# session, which the Chamberlain owns.
10
11# chamberlain.env is written by dnd.yml alongside the other environment files,
12# because the compose file references it and every compose command in that file
13# would otherwise fail on a fresh deploy.
14
15# The campaigns and library directories have to exist before a campaign can be
16# created into them. The Chamberlain creates them itself at startup, but doing it
17# here means they land with the right ownership rather than root's -- a
18# root-owned directory on the NFS mount is a nuisance to clean up later.
19- name: Create the campaign and library directories
20 file:
21 path: "{{ dnd_media_dir }}/{{ item }}"
22 state: directory
23 owner: "{{ dnd_uid }}"
24 group: "{{ dnd_gid }}"
25 mode: '2775'
26 loop: [campaigns, library]
27
28- name: Pull the Chamberlain image
29 community.docker.docker_image:
30 name: "{{ dnd_chamberlain_image }}"
31 source: pull
32 force_source: true
33
34- name: Start the Chamberlain
35 community.docker.docker_compose_v2:
36 project_src: "{{ dnd_config_dir }}"
37 services: [dnd-chamberlain]
38 state: present
39 register: dnd_chamberlain_start
40 check_mode: no
41
42# A real bind rather than a sleep: the Chamberlain reconciles the manifests
43# against what is actually running before it serves, and on a fresh NFS mount
44# that walk can take a moment.
45- name: Wait for the Chamberlain to answer
46 uri:
47 url: "http://localhost:{{ chamberlain_http_port }}/api/state"
48 method: GET
49 status_code: 200
50 register: dnd_chamberlain_health
51 until: dnd_chamberlain_health.status == 200
52 retries: 30
53 delay: 2
54 when: dnd_chamberlain_start is changed
55 check_mode: no
56
57- name: Display the Chamberlain summary
58 debug:
59 msg: |
60 The Chamberlain (session orchestration):
61 - URL: http://{{ ansible_default_ipv4.address }}:{{ chamberlain_http_port }}
62 - Status: {{ 'Started' if dnd_chamberlain_start is changed else 'Already running' }}
63 - Drives compose project: {{ dnd_config_dir | basename }}
64 - Media root: {{ dnd_media_dir }}
65 - Email: {{ 'configured' if chamberlain_smtp_host else 'not configured (buttons hidden)' }}
66
67 It starts and stops dnd-table-runner, dnd-agent and the camera recorder
68 around a session. Those are behind compose profiles and are deliberately
69 NOT started by this deploy.
70
71 NOTE: this container mounts the Docker socket, which makes it root on the
72 host, and it has no authentication. That is the accepted position for a
73 LAN-only appliance; do not expose it beyond the LAN without adding auth.
74