diff --git a/roles/docker-listmonk/handlers/main.yml b/roles/docker-listmonk/handlers/main.yml new file mode 100644 index 00000000..95f93475 --- /dev/null +++ b/roles/docker-listmonk/handlers/main.yml @@ -0,0 +1,8 @@ +--- +- name: recreate listmonk + command: + cmd: docker-compose -p listmonk up -d --force-recreate + chdir: "{{path_docker_compose_files}}listmonk/" + environment: + COMPOSE_HTTP_TIMEOUT: 600 + DOCKER_CLIENT_TIMEOUT: 600 diff --git a/roles/docker-listmonk/meta/main.yml b/roles/docker-listmonk/meta/main.yml new file mode 100644 index 00000000..f25ef891 --- /dev/null +++ b/roles/docker-listmonk/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- docker-reverse-proxy diff --git a/roles/docker-listmonk/tasks/main.yml b/roles/docker-listmonk/tasks/main.yml new file mode 100644 index 00000000..85364bf4 --- /dev/null +++ b/roles/docker-listmonk/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: recieve {{domain}} certificate + command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{domain}} + +- name: configure {{domain}}.conf + template: + src: "roles/docker-reverse-proxy/templates/domain.conf.j2" + dest: "/etc/nginx/conf.d/{{domain}}.conf" + notify: restart nginx + +- name: "create {{path_docker_compose_files}}listmonk/" + file: + path: "{{path_docker_compose_files}}listmonk/" + state: directory + mode: 0755 + +- name: add docker-compose.yml + template: + src: "docker-compose.yml.j2" + dest: "{{path_docker_compose_files}}listmonk/docker-compose.yml" + notify: recreate listmonk diff --git a/roles/docker-listmonk/templates/config.toml b/roles/docker-listmonk/templates/config.toml new file mode 100644 index 00000000..b504f907 --- /dev/null +++ b/roles/docker-listmonk/templates/config.toml @@ -0,0 +1,31 @@ +[app] +# Interface and port where the app will run its webserver. The default value +# of localhost will only listen to connections from the current machine. To +# listen on all interfaces use '0.0.0.0'. To listen on the default web address +# port, use port 80 (this will require running with elevated permissions). +address = "localhost:9000" + +# BasicAuth authentication for the admin dashboard. This will eventually +# be replaced with a better multi-user, role-based authentication system. +# IMPORTANT: Leave both values empty to disable authentication on admin +# only where an external authentication is already setup. +admin_username = "listmonk" +admin_password = "listmonk" + +# Database. +[db] +host = "localhost" +port = 5432 +user = "listmonk" +password = "listmonk" + +# Ensure that this database has been created in Postgres. +database = "listmonk" + +ssl_mode = "disable" +max_open = 25 +max_idle = 25 +max_lifetime = "300s" + +# Optional space separated Postgres DSN params. eg: "application_name=listmonk gssencmode=disable" +params = "" \ No newline at end of file diff --git a/roles/docker-listmonk/templates/docker-compose.yml.j2 b/roles/docker-listmonk/templates/docker-compose.yml.j2 new file mode 100644 index 00000000..a50c2655 --- /dev/null +++ b/roles/docker-listmonk/templates/docker-compose.yml.j2 @@ -0,0 +1,54 @@ +# NOTE: This docker-compose.yml is meant to be just an example guideline +# on how you can achieve the same. It is not intented to run out of the box +# and you must edit the below configurations to suit your needs. + +version: "3.7" + +x-app-defaults: &app-defaults + restart: unless-stopped + image: listmonk/listmonk:latest + ports: + - "9000:9000" + networks: + - listmonk + environment: + - TZ=Etc/UTC + +x-db-defaults: &db-defaults + image: postgres:13 + ports: + - "9432:5432" + networks: + - listmonk + environment: + - POSTGRES_PASSWORD=listmonk + - POSTGRES_USER=listmonk + - POSTGRES_DB=listmonk + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "pg_isready -U listmonk"] + interval: 10s + timeout: 5s + retries: 6 + +services: + db: + <<: *db-defaults + container_name: listmonk_db + volumes: + - type: volume + source: listmonk-data + target: /var/lib/postgresql/data + + app: + <<: *app-defaults + container_name: listmonk_app + depends_on: + - db + volumes: + - ./config.toml:/listmonk/config.toml +networks: + listmonk: + +volumes: + listmonk-data: \ No newline at end of file