Fix files and templates.
Check if the GeoIP db exists and configure accordingly. Move preparation tasks to prepare.yml. Fix destroy.yml.
This commit is contained in:
parent
7c674a8891
commit
347f54fd79
@ -24,8 +24,8 @@ plausible_version: "latest"
|
|||||||
plausible_pg_password: "change_me"
|
plausible_pg_password: "change_me"
|
||||||
|
|
||||||
# Volumes
|
# Volumes
|
||||||
plausible_base: "/mnt/plausible"
|
plausible_volume_base: "/mnt/plausible"
|
||||||
plausible_config: "{{ plausible_base }}/config"
|
plausible_volume_config: "{{ plausible_volume_base }}/config"
|
||||||
plausible_db_data: "{{ plausible_base }}/db_data"
|
plausible_volume_db: "{{ plausible_volume_base }}/db_data"
|
||||||
plausible_event_data: "{{ plausible_base }}/event_data"
|
plausible_volume_events: "{{ plausible_volume_base }}/event_data"
|
||||||
plausible_geoip_database: "{{ plausible_base }}/geoip_data"
|
plausible_volume_geoip: "{{ plausible_volume_base }}/geoip_data"
|
||||||
|
@ -1,2 +1,8 @@
|
|||||||
---
|
---
|
||||||
# handlers file for plausible
|
# handlers file for plausible
|
||||||
|
- name: Restart plausible
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: ~/plausible/
|
||||||
|
build: false
|
||||||
|
restarted: true
|
||||||
|
become: false
|
||||||
|
@ -3,20 +3,9 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
# gather_facts: false
|
# gather_facts: false
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Update apt cache.
|
- name: "Include necessary variables"
|
||||||
apt: update_cache=yes cache_valid_time=600
|
ansible.builtin.include_vars:
|
||||||
when: ansible_os_family == 'Debian'
|
file: "../../.env.yml"
|
||||||
- name: Install python requests
|
|
||||||
pip:
|
|
||||||
name:
|
|
||||||
- requests
|
|
||||||
- docker
|
|
||||||
- docker-compose
|
|
||||||
- name: Install docker
|
|
||||||
vars:
|
|
||||||
docker_service_manage: false
|
|
||||||
include_role:
|
|
||||||
name: geerlingguy.docker
|
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: laurivan.plausible
|
- role: laurivan.plausible
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
no_log: "{{ molecule_no_log }}"
|
no_log: "{{ molecule_no_log }}"
|
||||||
tasks:
|
tasks:
|
||||||
# Developer must implement.
|
# Developer must implement.
|
||||||
|
- name: Remove the docker image
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: instance
|
||||||
|
state: absent
|
||||||
|
|
||||||
# Mandatory configuration for Molecule to function.
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
@ -10,3 +10,17 @@
|
|||||||
raw: mount --move /tmp/docker_mounted.sock /var/run/docker.sock
|
raw: mount --move /tmp/docker_mounted.sock /var/run/docker.sock
|
||||||
become: true
|
become: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
- name: Update apt cache.
|
||||||
|
apt: update_cache=yes cache_valid_time=600
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
- name: Install python requests
|
||||||
|
pip:
|
||||||
|
name:
|
||||||
|
- requests
|
||||||
|
- docker
|
||||||
|
- docker-compose
|
||||||
|
- name: Install docker
|
||||||
|
vars:
|
||||||
|
docker_service_manage: false
|
||||||
|
include_role:
|
||||||
|
name: geerlingguy.docker
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
---
|
---
|
||||||
# tasks file for plausible
|
# tasks file for plausible
|
||||||
|
|
||||||
|
# Check if geoip volume exists
|
||||||
|
- name: Check if geoip volume exists
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ plausible_volume_geoip }}/GeoLite2-Country.mmdb"
|
||||||
|
register: plausible_geoip_stat
|
||||||
|
|
||||||
- name: Set up directories
|
- name: Set up directories
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ plausible_volume_media }}"
|
|
||||||
- "{{ plausible_volume_certs }}"
|
|
||||||
- "{{ plausible_volume_geoip }}"
|
|
||||||
- "{{ plausible_volume_templates }}"
|
|
||||||
- "{{ plausible_volume_config }}"
|
- "{{ plausible_volume_config }}"
|
||||||
- "{{ plausible_volume_redis }}"
|
- "{{ plausible_volume_events }}"
|
||||||
- "~/plausible"
|
- "~/plausible"
|
||||||
tags:
|
tags:
|
||||||
- configuration
|
- configuration
|
||||||
@ -28,7 +30,29 @@
|
|||||||
- "{{ plausible_volume_db }}"
|
- "{{ plausible_volume_db }}"
|
||||||
tags:
|
tags:
|
||||||
- configuration
|
- configuration
|
||||||
become: false
|
become: true
|
||||||
|
|
||||||
|
- name: Write plausible configuration (1)
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "{{ item }}.j2"
|
||||||
|
dest: "{{ plausible_volume_config }}/{{ item }}"
|
||||||
|
mode: '0640'
|
||||||
|
loop:
|
||||||
|
- "env.plausible.conf"
|
||||||
|
- "env.mail.conf"
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
|
||||||
|
- name: Write plausible configuration (2)
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: "{{ plausible_volume_config }}/{{ item }}"
|
||||||
|
mode: '0640'
|
||||||
|
loop:
|
||||||
|
- "clickhouse-config.xml"
|
||||||
|
- "clickhouse-user-config.xml"
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
|
||||||
- name: Copy plausible docker-compose template.
|
- name: Copy plausible docker-compose template.
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
@ -38,14 +62,6 @@
|
|||||||
become: false
|
become: false
|
||||||
notify: Restart plausible
|
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.
|
- name: Ensure plausible is running.
|
||||||
community.docker.docker_compose:
|
community.docker.docker_compose:
|
||||||
project_src: ~/plausible/
|
project_src: ~/plausible/
|
||||||
|
@ -3,6 +3,8 @@ services:
|
|||||||
mail:
|
mail:
|
||||||
image: bytemark/smtp
|
image: bytemark/smtp
|
||||||
restart: always
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- {{ plausible_volume_config }}/env.mail.conf
|
||||||
networks:
|
networks:
|
||||||
- plausible
|
- plausible
|
||||||
|
|
||||||
@ -10,9 +12,9 @@ services:
|
|||||||
image: postgres:12
|
image: postgres:12
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- {{ plausible_db_data }}:/var/lib/postgresql/data
|
- {{ plausible_volume_db }}:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD={{ plausible_pg_password }}
|
||||||
networks:
|
networks:
|
||||||
- plausible
|
- plausible
|
||||||
|
|
||||||
@ -20,9 +22,9 @@ services:
|
|||||||
image: clickhouse/clickhouse-server:22.6-alpine
|
image: clickhouse/clickhouse-server:22.6-alpine
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- {{ plausible_event_data }}:/var/lib/clickhouse
|
- {{ plausible_volume_events }}:/var/lib/clickhouse
|
||||||
- {{ plausible_config }}/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
|
- {{ plausible_volume_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
|
- {{ plausible_volume_config }}/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
|
||||||
ulimits:
|
ulimits:
|
||||||
nofile:
|
nofile:
|
||||||
soft: 262144
|
soft: 262144
|
||||||
@ -41,9 +43,13 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- {{ plausible_port }}:8000
|
- {{ plausible_port }}:8000
|
||||||
env_file:
|
env_file:
|
||||||
- {{ plausible_config }}/env.plausible.conf
|
- {{ plausible_volume_config }}/env.plausible.conf
|
||||||
|
{% if plausible_geoip_stat.stat.exists %}
|
||||||
volumes:
|
volumes:
|
||||||
- {{ plausible_geoip_database }}:/geoip:ro
|
- {{ plausible_volume_geoip }}/GeoLite2-Country.mmdb:/geoip:ro
|
||||||
|
{% else %}
|
||||||
|
# No GeoIP data volume
|
||||||
|
{% endif%}
|
||||||
networks:
|
networks:
|
||||||
- plausible
|
- plausible
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
{%if plausible_smtp_host %}
|
||||||
RELAY_HOST={{ plausible_smtp_host }}
|
RELAY_HOST={{ plausible_smtp_host }}
|
||||||
RELAY_PORT={{ plausible_smtp_port }}
|
RELAY_PORT={{ plausible_smtp_port }}
|
||||||
RELAY_USERNAME={{ plausible_smtp_username }}
|
RELAY_USERNAME={{ plausible_smtp_username }}
|
||||||
RELAY_PASSWORD={{ plausible_smtp_password }}
|
RELAY_PASSWORD={{ plausible_smtp_password }}
|
||||||
|
{% endif %}
|
@ -0,0 +1,17 @@
|
|||||||
|
ADMIN_USER_EMAIL={{ plausible_admin_user_email }}
|
||||||
|
ADMIN_USER_NAME={{ plausible_admin_user_name }}
|
||||||
|
ADMIN_USER_PWD={{ plausible_admin_user_pwd }}
|
||||||
|
BASE_URL={{ plausible_base_url }}
|
||||||
|
SECRET_KEY_BASE={{ plausible_secret_key_base }}
|
||||||
|
|
||||||
|
{% if plausible_geoip_stat.stat.exists %}
|
||||||
|
GEOLITE2_COUNTRY_DB={{ plausible_volume_geoip }}/GeoLite2-Country.mmdb
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# DB and events
|
||||||
|
DATABASE_URL=postgres://postgres:{{ plausible_pg_password }}@plausible_db:5432/plausible_db
|
||||||
|
CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
|
||||||
|
|
||||||
|
#SMTP
|
||||||
|
SMTP_HOST_ADDR=plausible_mail
|
||||||
|
MAILER_EMAIL={{ plausible_smtp_email }}
|
Loading…
Reference in New Issue
Block a user