diff --git a/defaults/main.yml b/defaults/main.yml
index 51546e2..580cc72 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,10 +1,6 @@
---
# defaults file for plausible
-# Docker user
-plausible_uid: docker
-plausible_gid: docker
-
# Email
plausible_smtp_host:
plausible_smtp_port: 587
@@ -32,4 +28,4 @@ plausible_base: "/mnt/plausible"
plausible_config: "{{ plausible_base }}/config"
plausible_db_data: "{{ plausible_base }}/db_data"
plausible_event_data: "{{ plausible_base }}/event_data"
-plausible_geoip_database: "{{ plausible_base }}/geoip_data"
\ No newline at end of file
+plausible_geoip_database: "{{ plausible_base }}/geoip_data"
diff --git a/files/clickhouse-config.xml.j2 b/files/clickhouse-config.xml.j2
new file mode 100644
index 0000000..3ea62a3
--- /dev/null
+++ b/files/clickhouse-config.xml.j2
@@ -0,0 +1,14 @@
+
+
+ warning
+ true
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/files/clickhouse-user-config.xml.j2 b/files/clickhouse-user-config.xml.j2
new file mode 100644
index 0000000..d618f54
--- /dev/null
+++ b/files/clickhouse-user-config.xml.j2
@@ -0,0 +1,8 @@
+
+
+
+ 0
+ 0
+
+
+
\ No newline at end of file
diff --git a/tasks/main.yml b/tasks/main.yml
index d429218..5e162ec 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,2 +1,54 @@
---
# tasks file for plausible
+
+- name: Set up directories
+ ansible.builtin.file:
+ state: directory
+ path: "{{ item }}"
+ mode: 0755
+ with_items:
+ - "{{ plausible_volume_media }}"
+ - "{{ plausible_volume_certs }}"
+ - "{{ plausible_volume_geoip }}"
+ - "{{ plausible_volume_templates }}"
+ - "{{ plausible_volume_config }}"
+ - "{{ plausible_volume_redis }}"
+ - "~/plausible"
+ tags:
+ - configuration
+ become: false
+
+- name: Set up the database directory.
+ ansible.builtin.file:
+ state: directory
+ path: "{{ item }}"
+ mode: 0755
+ owner: 70
+ with_items:
+ - "{{ plausible_volume_db }}"
+ tags:
+ - configuration
+ become: false
+
+- name: Copy plausible docker-compose template.
+ ansible.builtin.template:
+ src: templates/docker-compose.yml.j2
+ dest: ~/plausible/docker-compose.yml
+ mode: '0640'
+ become: false
+ notify: Restart plausible
+
+- name: Copy plausible configuration.
+ ansible.builtin.template:
+ src: templates/env.plausible.conf.j2
+ dest: "{{ plausible_volume_config }}/env.plausible.conf"
+ mode: '0640'
+ become: false
+ notify: Restart plausible
+
+- name: Ensure plausible is running.
+ community.docker.docker_compose:
+ project_src: ~/plausible/
+ build: false
+ become: false
+
diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2
index e69de29..ede9870 100644
--- a/templates/docker-compose.yml.j2
+++ b/templates/docker-compose.yml.j2
@@ -0,0 +1,51 @@
+version: "3.3"
+services:
+ mail:
+ image: bytemark/smtp
+ restart: always
+ networks:
+ - plausible
+
+ plausible_db:
+ image: postgres:12
+ restart: always
+ volumes:
+ - {{ plausible_db_data }}:/var/lib/postgresql/data
+ environment:
+ - POSTGRES_PASSWORD=postgres
+ networks:
+ - plausible
+
+ plausible_events_db:
+ image: clickhouse/clickhouse-server:22.6-alpine
+ restart: always
+ volumes:
+ - {{ plausible_event_data }}:/var/lib/clickhouse
+ - {{ plausible_config }}/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
+ - {{ plausible_config }}/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
+ ulimits:
+ nofile:
+ soft: 262144
+ hard: 262144
+ networks:
+ - plausible
+
+ plausible:
+ image: plausible/analytics:latest
+ restart: always
+ command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
+ depends_on:
+ - plausible_db
+ - plausible_events_db
+ - mail
+ ports:
+ - {{ plausible_port }}:8000
+ env_file:
+ - {{ plausible_config }}/env.plausible.conf
+ volumes:
+ - {{ plausible_geoip_database }}:/geoip:ro
+ networks:
+ - plausible
+
+networks:
+ plausible: {}
\ No newline at end of file
diff --git a/templates/env.mail.conf.j2 b/templates/env.mail.conf.j2
new file mode 100644
index 0000000..a9d9109
--- /dev/null
+++ b/templates/env.mail.conf.j2
@@ -0,0 +1,4 @@
+RELAY_HOST={{ plausible_smtp_host }}
+RELAY_PORT={{ plausible_smtp_port }}
+RELAY_USERNAME={{ plausible_smtp_username }}
+RELAY_PASSWORD={{ plausible_smtp_password }}
\ No newline at end of file