openneo-analytics/setup-plausible.yml

82 lines
2.1 KiB
YAML
Executable file

---
- name: Install and configure Plausible
hosts: webserver
become: yes
become_user: root
tasks:
- name: Set DPKG architecture as a variable
set_fact:
dpkg_arch: "{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}"
# From https://download.docker.com/linux/debian/gpg, then dearmored.
- name: Upload Docker's GPG key
copy:
src: files/docker.gpg
dest: /etc/apt/keyrings/docker.gpg
- name: Add Docker's apt repository
apt_repository:
repo: 'deb [arch={{ dpkg_arch }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable'
- name: Update the apt cache
apt:
update_cache: yes
- name: Install Docker
apt:
name: docker-ce
- name: Create plausible user
user:
name: plausible
groups:
- docker
home: /srv/plausible
create_home: no
comment: Plausible service user
- name: Create /srv/plausible folder
file:
path: /srv/plausible
owner: plausible
group: plausible
mode: '0700'
state: directory
- name: Copy docker-compose.yml to /srv/plausible
copy:
src: files/docker-compose.yml
dest: /srv/plausible/docker-compose.yml
notify:
- Restart plausible
- name: Copy plausible-conf.env to /srv/plausible
copy:
src: files/plausible-conf.env
dest: /srv/plausible/plausible-conf.env
notify:
- Restart plausible
- name: Create service file for plausible
copy:
src: files/plausible.service
dest: /etc/systemd/system/plausible.service
notify:
- Reload systemctl
- Restart plausible
- name: Enable the plausible service
systemd_service:
name: plausible
enabled: yes
state: started
handlers:
- name: Reload systemctl
systemd_service:
daemon_reload: true
- name: Restart plausible
systemd_service:
name: plausible
state: restarted