55 lines
2 KiB
YAML
55 lines
2 KiB
YAML
|
|
---
|
||
|
|
- name: Assert Docker is available
|
||
|
|
ansible.builtin.command: docker --version
|
||
|
|
register: gatus_docker_check
|
||
|
|
changed_when: false
|
||
|
|
failed_when: gatus_docker_check.rc != 0
|
||
|
|
|
||
|
|
- name: Create the gatus directories
|
||
|
|
ansible.builtin.file:
|
||
|
|
path: "{{ item.path }}"
|
||
|
|
state: directory
|
||
|
|
owner: "{{ item.owner }}"
|
||
|
|
group: "{{ item.group }}"
|
||
|
|
mode: "{{ item.mode }}"
|
||
|
|
loop:
|
||
|
|
- {path: "{{ gatus_dir }}", owner: root, group: root, mode: "0755"}
|
||
|
|
# Config is root-owned and world-unreadable: it holds external-endpoint
|
||
|
|
# tokens. The container mounts it read-only and reads it as gatus_uid, so
|
||
|
|
# that id needs group access - hence the group ownership below.
|
||
|
|
- {path: "{{ gatus_config_dir }}", owner: root, group: "{{ gatus_gid }}", mode: "0750"}
|
||
|
|
- {path: "{{ gatus_endpoints_dir }}", owner: root, group: "{{ gatus_gid }}", mode: "0750"}
|
||
|
|
# Data is the one path the container writes to, so it must be owned by the
|
||
|
|
# numeric id the container runs as. `read_only: true` makes everything else
|
||
|
|
# in the container immutable.
|
||
|
|
- {path: "{{ gatus_data_dir }}", owner: "{{ gatus_uid }}", group: "{{ gatus_gid }}", mode: "0750"}
|
||
|
|
|
||
|
|
- name: Write the base gatus configuration
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: config.yaml.j2
|
||
|
|
dest: "{{ gatus_config_dir }}/{{ gatus_base_config_file }}"
|
||
|
|
owner: root
|
||
|
|
group: "{{ gatus_gid }}"
|
||
|
|
mode: "0640"
|
||
|
|
notify: Restart gatus
|
||
|
|
|
||
|
|
# Without this the container crash-loops on an empty config. See the template.
|
||
|
|
- name: Write the gatus self-check endpoint
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: endpoint-self.yaml.j2
|
||
|
|
dest: "{{ gatus_endpoints_dir }}/00-self.yaml"
|
||
|
|
owner: root
|
||
|
|
group: "{{ gatus_gid }}"
|
||
|
|
mode: "0640"
|
||
|
|
when: gatus_self_check | bool
|
||
|
|
notify: Restart gatus
|
||
|
|
|
||
|
|
- name: Write the docker compose file
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: docker-compose.yml.j2
|
||
|
|
dest: "{{ gatus_dir }}/docker-compose.yml"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: "0644"
|
||
|
|
notify: Restart gatus
|