Skip to content

Commit

Permalink
feat: new role n8n_exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
janikvonrotz committed Jan 17, 2025
1 parent 006c3d7 commit 3d6c34c
Show file tree
Hide file tree
Showing 23 changed files with 245 additions and 67 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
pull_request:
branches:
- "main"
push:
branches:
- "main"

jobs:
task-all:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run task install
run: ./task install
- name: Run task test
run: ./task test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ Have a look at the Ansible roles and check how to configure them.
| [mariadb](roles/mariadb/README.md) | Deploy MariaDB database container. |
| [matomo](roles/matomo/README.md) | Deploy Matomo container. |
| [meilisearch](roles/meilisearch/README.md) | Deploy Meilisearch container. |
| [metabase](roles/metabase/README.md) | Deploy Metabase Docker container. |
| [metricbeat](roles/metricbeat/README.md) | Deploy Metricbeat Docker container. |
| [moodle](roles/moodle/README.md) | Deploy Moodle container. |
| [mysql](roles/mysql/README.md) | Deploy MySQL database container. |
| [n8n](roles/n8n/README.md) | Deploy N8N container. |
| [n8n_exporter](roles/n8n_exporter/README.md) | Add nginx config for N8N exporter path. |
| [nextcloud](roles/nextcloud/README.md) | Deploy Nextcloud container. |
| [nextcloud_apps](roles/nextcloud_apps/README.md) | Install, update and remove Nextcloud apps. |
| [nextcloud_exporter](roles/nextcloud_exporter/README.md) | Deploy Nextcloud exporter container. |
Expand Down
119 changes: 119 additions & 0 deletions localhost/host_vars/localhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
docker_network_name: mint-system.com
ansible_become: true
ufw_enabled: false
hosts:
- ip: 127.0.0.1
name: n8n.local odoo.local metabase.local
- ip: 10.101.16.2
name: erp.brunner-innovation.swiss erp-dev.brunner-innovation.swiss gaia.mint-system.com

# https://registry.hub.docker.com/_/rabbitmq/
rabbitmq_image: rabbitmq:3.8-management
rabbitmq_hostname: mq01
rabbitmq_data_dir: "/usr/share/{{ odoo_hostname }}"
rabbitmq_ports:
- 127.0.0.1:5672:5672
- 127.0.0.1:8080:15672
rabbitmq_user: admin
rabbitmq_password: admin

# https://hub.docker.com/_/postgres
postgres_image: postgres:14
# postgres_build_image: true # default: false
postgres_hostname: postgres01
postgres_user: example
postgres_config_map:
- db: metabase-prod
- db: odoo-prod
- db: odoo-int
postgres_password: test
postgres_wal_level: logical

# https://hub.docker.com/r/getmeili/meilisearch
meilisearch_image: getmeili/meilisearch:v1.10.1
meilisearch_hostname: meili01
meilisearch_volume_name: "{{ meilisearch_hostname }}"
meilisearch_master_key: "test"
meilisearch_network_mode: host
meilisearch_task_webhook: http://host.docker.internal:8069/meilisearch/task-webhook
meilisearch_etc_hosts:
"host.docker.internal": host-gateway

# https://hub.docker.com/r/dpage/pgadmin4/
pgadmin_image: dpage/pgadmin4:7.6
pgadmin_hostname: pgadmin01
pgadmin_user: admin@example.com
pgadmin_password: example
pgadmin_servers:
- name: Postgres
host: postgres01
username: example
pgadmin_data_dir: /usr/share/{{ pgadmin_hostname }}
pgadmin_volume_name: "{{ pgadmin_hostname }}"

# https://hub.docker.com/r/n8nio/n8n/tags
n8n_image: n8nio/n8n:1.67.1
n8n_hostname: n8n01
n8n_postgresdb_host: postgres01
n8n_postgresdb_user: example
n8n_postgresdb_password: test
n8n_secure_cookie: "false"
n8n_config_map:
- name: prod
webhook_url: ""

# https://hub.docker.com/_/nginx/
nginx_image: nginx:1.26.2-alpine
nginx_hostname: nginx01
nginx_http_options: |
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
nginx_proxies:
- src_hostname: metabase.local
dest_hostname: metabase01-prod
dest_port: 3000
- src_hostname: n8n.local
dest_hostname: n8n01-prod
dest_port: 5678
- src_hostname: odoo.local
dest_hostname: odoo01-prod
dest_port: 8069
locations:
- path: /websocket
dest_hostname: odoo01-prod
dest_port: 8072
options: |
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
include /etc/nginx/conf.d/proxy-params.conf;
# https://hub.docker.com/_/odoo/
odoo_revision: "18.0.20250106"
odoo_image: mintsystem/odoo:18.0.20250106
odoo_build_image: true
odoo_build_dockerfile: |
USER root
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
RUN curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y unixodbc msodbcsql18
USER odoo
RUN uv pip install prometheus-client python-jose pyodbc pymssql
odoo_hostname: odoo01
odoo_description: Odoo18
odoo_master_password: odoo
odoo_postgres_user: example
odoo_postgres_password: test
odoo_config_map:
- name: prod
- name: int
odoo_postgres_hostname: "{{ postgres_hostname }}"

# https://hub.docker.com/r/metabase/metabase
metabase_image: metabase/metabase:v0.51.12.1
metabase_hostname: metabase01
metabase_db_host: postgres01
metabase_db_user: test
metabase_db_pass: test
5 changes: 5 additions & 0 deletions localhost/hosts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
hosts:
localhost:
ansible_host: localhost
ansible_connection: local
4 changes: 3 additions & 1 deletion plays/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@
- role: n8n
tags: n8n
- role: mailpit
tags: mailpit
tags: mailpit
- role: metabase
tags: metabase
4 changes: 3 additions & 1 deletion plays/localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
- role: nginx
tags: nginx
- role: crowdsec
tags: crowdsec
tags: crowdsec
- role: metabase
tags: metabase
2 changes: 2 additions & 0 deletions plays/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
tags: postgres_exporter
- role: bigbluebutton_exporter
tags: bigbluebutton_exporter
- role: n8n_exporter
tags: n8n_exporter
- role: loki
tags: loki
- role: acme_sh
Expand Down
24 changes: 9 additions & 15 deletions roles/metabase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@ Deploy Metabase container.
Configure the role.

```yml
# https://hub.docker.com/r/metabaseio/metabase
metabase_image: metabaseio/metabase:1.67.1
# https://hub.docker.com/r/metabase/metabase
metabase_image: metabase/metabase:v0.51.12.1
metabase_build_image: true # default: false
metabase_hostname: metabase01
metabase_description: Workflow Automation # default: N8N
metabase_description: Business Intelligence # default: Metabase
metabase_state: stopped # default: started
metabase_volume_name: metabase_data01 # default: "{{ metabase_hostname }}"
metabase_config_map:
metabase_config_map: # default: [ name: prod ]
- name: prod
webhook_url: https://metabase.example.com/
- name: int
webhook_url: https://metabase-int.example.com/
metabase_timezone: Europe/Paris # default: Europe/Zurich
metabase_db_type: # default: postgresdb
metabase_postgresdb_host: postgres01
metabase_postgresdb_port: # default: "5432"
metabase_postgresdb_database: workflow # default: metabase
metabase_postgresdb_schema: metabase # default: public
metabase_postgresdb_user: workflow # default: metabase
metabase_postgresdb_password: # default: "{{ vault_metabase_postgresdb_password }}"
metabase_secure_cookie: "false" # default: "true"
metabase_db_host: postgres01
metabase_db_port: 2345 # default: "5432"
metabase_db_dbname: bi # default: metabase
metabase_db_user: bi # default: metabase
metabase_db_pass: # default: "{{ vault_metabase_db_pass }}"
```
And include it in your playbook.
Expand Down
21 changes: 6 additions & 15 deletions roles/metabase/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
---
metabase_build_image: false
metabase_config_map:
- name: prod
webhook_url: ""
metabase_description: metabase
metabase_config_map: [name: prod]
metabase_description: Metabase
metabase_state: started
metabase_volume_name: "{{ metabase_hostname }}"
metabase_timezone: Europe/Zurich
metabase_db_type: postgresdb
metabase_postgresdb_port: "5432"
metabase_postgresdb_database: metabase
metabase_postgresdb_schema: public
metabase_db_type: postgres
metabase_db_port: "5432"
metabase_db_dbname: metabase
metabase_postgresdb_user: metabase
metabase_postgresdb_password: "{{ vault_metabase_postgresdb_password }}"
metabase_secure_cookie: "true"
metabase_exporter_requires_package: "python3-passlib"
metabase_exporter_proxy_basic_auth_username: metabase-exporter
metabase_exporter_proxy_basic_auth_password: "{{ vault_metabase_exporter_proxy_basic_auth_password }}"
metabase_exporter_nginx_data_dir: "{{ nginx_data_dir }}/proxies"
metabase_postgresdb_pass: "{{ vault_metabase_postgresdb_pass }}"
25 changes: 6 additions & 19 deletions roles/metabase/tasks/metabase.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
- name: Create {{ role_name }} volume
community.docker.docker_volume:
name: "{{ metabase_volume_name }}-{{ item.name }}"
loop: "{{ metabase_config_map }}"

- name: Start {{ role_name }} container {{ metabase_hostname }}
community.docker.docker_container:
name: "{{ metabase_hostname }}-{{ item.name }}"
Expand All @@ -14,21 +9,13 @@
recreate: false
state: "{{ metabase_state }}"
env:
DB_TYPE: "{{ metabase_db_type }}"
DB_POSTGRESDB_DATABASE: "{{ metabase_postgresdb_database }}-{{ item.name }}"
DB_POSTGRESDB_HOST: "{{ metabase_postgresdb_host }}"
DB_POSTGRESDB_PORT: "{{ metabase_postgresdb_port }}"
DB_POSTGRESDB_USER: "{{ metabase_postgresdb_user }}"
DB_POSTGRESDB_SCHEMA: "{{ metabase_postgresdb_schema }}"
DB_POSTGRESDB_PASSWORD: "{{ metabase_postgresdb_password }}"
GENERIC_TIMEZONE: "{{ metabase_timezone }}"
MB_DB_TYPE: "{{ metabase_db_type }}"
MB_DB_DBNAME: "{{ metabase_db_dbname }}-{{ item.name }}"
MB_DB_PORT: "{{ metabase_db_port }}"
MB_DB_USER: "{{ metabase_db_user }}"
MB_DB_PASS: "{{ metabase_db_pass }}"
MB_DB_HOST: "{{ metabase_db_host }}"
TZ: "{{ metabase_timezone }}"
N8N_SECURE_COOKIE: "{{ metabase_secure_cookie }}"
N8N_METRICS: "true"
WEBHOOK_URL: "{{ item.webhook_url }}"
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "true"
volumes:
- "{{ metabase_volume_name }}-{{ item.name }}:/home/node/"
networks:
- name: "{{ docker_network_name }}"
log_driver: "{{ docker_log_driver }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/metabase/templates/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM {{ metabase_build_image }}
FROM {{ metabase_build_image }}
2 changes: 1 addition & 1 deletion roles/n8n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ n8n_hostname: n8n01
n8n_description: Workflow Automation # default: N8N
n8n_state: stopped # default: started
n8n_volume_name: n8n_data01 # default: "{{ n8n_hostname }}"
n8n_config_map:
n8n_config_map: # default: [ name: prod ]
- name: prod
webhook_url: https://n8n.example.com/
- name: int
Expand Down
4 changes: 0 additions & 4 deletions roles/n8n/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ n8n_postgresdb_schema: public
n8n_postgresdb_user: n8n
n8n_postgresdb_password: "{{ vault_n8n_postgresdb_password }}"
n8n_secure_cookie: "true"
n8n_exporter_requires_package: "python3-passlib"
n8n_exporter_proxy_basic_auth_username: n8n-exporter
n8n_exporter_proxy_basic_auth_password: "{{ vault_n8n_exporter_proxy_basic_auth_password }}"
n8n_exporter_nginx_data_dir: "{{ nginx_data_dir }}/proxies"
7 changes: 0 additions & 7 deletions roles/n8n/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@
when: n8n_image is defined
tags:
- n8n

- name: Include {{ role_name }} nginx config tasks
ansible.builtin.include_tasks: "{{ role_name }}_exporter_nginx_config.yml"
when: n8n_image is defined
tags:
- n8n_exporter
- n8n_exporter_nginx_config
33 changes: 33 additions & 0 deletions roles/n8n_exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# N8N Exporter role

Add nginx config for N8N exporter path.

## Usage

Configure the role.

```yml
# https://hub.docker.com/r/n8nio/n8n
n8n_exporter_proxy_basic_auth_username: # default: n8n-exporter
n8n_exporter_proxy_basic_auth_password: # default: "{{ vault_n8n_exporter_proxy_basic_auth_password }}"
n8n_exporter_nginx_data_dir: /usr/share/nginx/proxies # default: "{{ nginx_data_dir }}/proxies"
```
Ensure the nginx proxy includes the n8n-exporter config:
```yml
nginx_proxies:
- src_hostname: server.example.com
ssl: true
exporter: n8n
options: |
include /etc/nginx/conf.d/proxies/n8n-exporter.nginx;
```
Include the role in your playbook.
```yml
- hosts: n8n
roles:
- role: n8n_exporter
```
4 changes: 4 additions & 0 deletions roles/n8n_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
n8n_exporter_requires_package: "python3-passlib"
n8n_exporter_nginx_data_dir: "{{ nginx_data_dir }}/proxies"
n8n_exporter_proxy_basic_auth_password: "{{ vault_n8n_exporter_proxy_basic_auth_password }}"
6 changes: 6 additions & 0 deletions roles/n8n_exporter/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Include {{ role_name }} tasks
ansible.builtin.include_tasks: "{{ role_name }}.yml"
when: n8n_hostname is defined
tags:
- n8n_exporter
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion roles/nginx/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ nginx_ports:
- 80:80
- 443:443
nginx_description: Nginx
nginx_data_dir: /usr/share/{{ nginx_hostname }}
nginx_data_dir: "/usr/share/{{ nginx_hostname }}"
nginx_cache_enabled: true
2 changes: 1 addition & 1 deletion roles/odoo_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ odoo_exporter_proxy_basic_auth_username: odoo-exporter
odoo_exporter_proxy_basic_auth_password: # default: "{{ vault_odoo_exporter_proxy_basic_auth_password }}"
```
Ensure the nginx proxy includes the node-exporter config:
Ensure the nginx proxy includes the odoo-exporter config:
```yml
nginx_proxies:
Expand Down
2 changes: 1 addition & 1 deletion roles/postgres/files/docker-postgres-create
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ if [[ "$DATABASES" =~ "$DATABASE" ]]; then
fi

echo "Create Postgres database $DATABASE ..."
docker exec -i $CONTAINER /bin/bash -c "psql postgresql://\$POSTGRES_USER:\$POSTGRES_PASSWORD@\$HOSTNAME/postgres -c \"CREATE DATABASE $DATABASE;\""
docker exec -i $CONTAINER /bin/bash -c "psql postgresql://\$POSTGRES_USER:\$POSTGRES_PASSWORD@\$HOSTNAME/postgres -c 'CREATE DATABASE \"$DATABASE\";'"
echo "Database $DATABASE has been created."
Loading

0 comments on commit 3d6c34c

Please sign in to comment.