Adding automatisch
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
---
|
||||
automatisch_data_dir: "{{ sovereign_base_dir }}/automatisch"
|
||||
automatisch_domain: "automate.{{ base_domain }}"
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: restart automatisch
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ automatisch_data_dir }}"
|
||||
state: present
|
||||
recreate: always
|
||||
when: not (molecule_test_mode | default(false))
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../../../molecule/shared/vars.yml
|
||||
roles:
|
||||
- role: automatisch
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
requirements-file: requirements.yml
|
||||
driver:
|
||||
name: default
|
||||
platforms:
|
||||
- name: localhost
|
||||
groups:
|
||||
- sovereign
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
ANSIBLE_ROLES_PATH: "${MOLECULE_PROJECT_DIRECTORY}/.."
|
||||
inventory:
|
||||
host_vars:
|
||||
localhost:
|
||||
ansible_connection: local
|
||||
verifier:
|
||||
name: ansible
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
- name: Verify automatisch role
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
automatisch_data_dir: /tmp/sovereign_test/automatisch
|
||||
automatisch_domain: automate.test.example.com
|
||||
automatisch_version: latest
|
||||
automatisch_encryption_key: test_automatisch_encryption_key
|
||||
automatisch_webhook_secret_key: test_automatisch_webhook_secret
|
||||
automatisch_app_secret_key: test_automatisch_app_secret
|
||||
automatisch_db_password: test_automatisch_db
|
||||
|
||||
tasks:
|
||||
- name: Check automatisch data directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/sovereign_test/automatisch"
|
||||
register: data_dir_stat
|
||||
|
||||
- name: Assert automatisch data directory is present
|
||||
ansible.builtin.assert:
|
||||
that: data_dir_stat.stat.isdir
|
||||
fail_msg: "Data directory /tmp/sovereign_test/automatisch was not created"
|
||||
|
||||
- name: Check docker-compose.yml exists
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/sovereign_test/automatisch/docker-compose.yml"
|
||||
register: compose_stat
|
||||
|
||||
- name: Assert docker-compose.yml was rendered
|
||||
ansible.builtin.assert:
|
||||
that: compose_stat.stat.exists
|
||||
fail_msg: "docker-compose.yml was not rendered for automatisch"
|
||||
|
||||
- name: Read docker-compose.yml
|
||||
ansible.builtin.slurp:
|
||||
src: "/tmp/sovereign_test/automatisch/docker-compose.yml"
|
||||
register: compose_raw
|
||||
|
||||
- name: Set compose content fact
|
||||
ansible.builtin.set_fact:
|
||||
compose: "{{ compose_raw.content | b64decode }}"
|
||||
|
||||
- name: Assert automatisch image is present
|
||||
ansible.builtin.assert:
|
||||
that: "'automatischio/automatisch' in compose"
|
||||
fail_msg: "automatischio/automatisch image not found in docker-compose.yml"
|
||||
|
||||
- name: Assert automatisch domain traefik rule is present
|
||||
ansible.builtin.assert:
|
||||
that: "'Host(`automate.test.example.com`)' in compose"
|
||||
fail_msg: "Traefik rule for automate.test.example.com not found in docker-compose.yml"
|
||||
|
||||
- name: Assert Authentik forward auth middleware is present
|
||||
ansible.builtin.assert:
|
||||
that: "'outpost.goauthentik.io/auth/traefik' in compose"
|
||||
fail_msg: "Authentik forward auth address not found in docker-compose.yml"
|
||||
|
||||
- name: Assert encryption key is present in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'test_automatisch_encryption_key' in compose"
|
||||
fail_msg: "automatisch_encryption_key not found in docker-compose.yml"
|
||||
|
||||
- name: Assert GELF logging address is present
|
||||
ansible.builtin.assert:
|
||||
that: "'udp://127.0.0.1:12201' in compose"
|
||||
fail_msg: "GELF logging address udp://127.0.0.1:12201 not found in docker-compose.yml"
|
||||
|
||||
- name: Assert sovereign network is external
|
||||
ansible.builtin.assert:
|
||||
that: "'external: true' in compose"
|
||||
fail_msg: "external: true not found in docker-compose.yml networks section"
|
||||
|
||||
- name: Assert worker service is present
|
||||
ansible.builtin.assert:
|
||||
that: "'automatisch-worker' in compose"
|
||||
fail_msg: "automatisch-worker service not found in docker-compose.yml"
|
||||
|
||||
- name: Assert Redis service is present
|
||||
ansible.builtin.assert:
|
||||
that: "'automatisch-redis' in compose"
|
||||
fail_msg: "automatisch-redis service not found in docker-compose.yml"
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: Create Automatisch directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ automatisch_data_dir }}"
|
||||
- "{{ automatisch_data_dir }}/storage"
|
||||
|
||||
- name: Deploy Automatisch docker-compose
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
dest: "{{ automatisch_data_dir }}/docker-compose.yml"
|
||||
mode: '0644'
|
||||
notify: restart automatisch
|
||||
|
||||
- name: Start Automatisch
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ automatisch_data_dir }}"
|
||||
state: present
|
||||
when: not (molecule_test_mode | default(false))
|
||||
@@ -0,0 +1,120 @@
|
||||
services:
|
||||
automatisch-db:
|
||||
image: postgres:16-alpine
|
||||
container_name: automatisch-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: automatisch
|
||||
POSTGRES_USER: automatisch
|
||||
POSTGRES_PASSWORD: "{{ automatisch_db_password }}"
|
||||
volumes:
|
||||
- {{ automatisch_data_dir }}/db:/var/lib/postgresql/data
|
||||
networks:
|
||||
- internal
|
||||
logging:
|
||||
driver: gelf
|
||||
options:
|
||||
gelf-address: "udp://{{ graylog_host }}:{{ graylog_gelf_port }}"
|
||||
tag: "automatisch-db"
|
||||
|
||||
automatisch-redis:
|
||||
image: redis:7-alpine
|
||||
container_name: automatisch-redis
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- internal
|
||||
logging:
|
||||
driver: gelf
|
||||
options:
|
||||
gelf-address: "udp://{{ graylog_host }}:{{ graylog_gelf_port }}"
|
||||
tag: "automatisch-redis"
|
||||
|
||||
automatisch:
|
||||
image: automatischio/automatisch:{{ automatisch_version }}
|
||||
container_name: automatisch
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- automatisch-db
|
||||
- automatisch-redis
|
||||
environment:
|
||||
HOST: "{{ automatisch_domain }}"
|
||||
PROTOCOL: https
|
||||
PORT: "3000"
|
||||
APP_ENV: production
|
||||
POSTGRES_HOST: automatisch-db
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: automatisch
|
||||
POSTGRES_USERNAME: automatisch
|
||||
POSTGRES_PASSWORD: "{{ automatisch_db_password }}"
|
||||
REDIS_HOST: automatisch-redis
|
||||
REDIS_PORT: "6379"
|
||||
ENCRYPTION_KEY: "{{ automatisch_encryption_key }}"
|
||||
WEBHOOK_SECRET_KEY: "{{ automatisch_webhook_secret_key }}"
|
||||
APP_SECRET_KEY: "{{ automatisch_app_secret_key }}"
|
||||
SMTP_HOST: "{{ smtp_host }}"
|
||||
SMTP_PORT: "{{ smtp_port }}"
|
||||
SMTP_USER: "{{ smtp_user }}"
|
||||
SMTP_PASSWORD: "{{ smtp_password }}"
|
||||
FROM_EMAIL: "{{ smtp_from }}"
|
||||
TELEMETRY_ENABLED: "false"
|
||||
volumes:
|
||||
- {{ automatisch_data_dir }}/storage:/automatisch/packages/backend/storage
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.automatisch.rule=Host(`{{ automatisch_domain }}`)"
|
||||
- "traefik.http.routers.automatisch.tls=true"
|
||||
- "traefik.http.routers.automatisch.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.automatisch.middlewares=automatisch-auth@docker"
|
||||
- "traefik.http.services.automatisch.loadbalancer.server.port=3000"
|
||||
# Authentik forward auth — protects the entire app with Authentik SSO.
|
||||
# Pre-requisite: create a Proxy Provider (Forward Auth, single application)
|
||||
# in Authentik pointing to https://{{ automatisch_domain }}, then add it
|
||||
# to the embedded outpost.
|
||||
- "traefik.http.middlewares.automatisch-auth.forwardauth.address=https://{{ authentik_domain }}/outpost.goauthentik.io/auth/traefik"
|
||||
- "traefik.http.middlewares.automatisch-auth.forwardauth.trustForwardHeader=true"
|
||||
- "traefik.http.middlewares.automatisch-auth.forwardauth.authResponseHeaders=X-authentik-username,X-authentik-groups,X-authentik-email,X-authentik-name,X-authentik-uid,X-authentik-jwt,X-authentik-meta-jwks,X-authentik-meta-outpost,X-authentik-meta-provider,X-authentik-meta-app,X-authentik-meta-version"
|
||||
networks:
|
||||
- internal
|
||||
- {{ sovereign_network_name }}
|
||||
logging:
|
||||
driver: gelf
|
||||
options:
|
||||
gelf-address: "udp://{{ graylog_host }}:{{ graylog_gelf_port }}"
|
||||
tag: "automatisch"
|
||||
|
||||
automatisch-worker:
|
||||
image: automatischio/automatisch:{{ automatisch_version }}
|
||||
container_name: automatisch-worker
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- automatisch
|
||||
environment:
|
||||
WORKER: "true"
|
||||
HOST: "{{ automatisch_domain }}"
|
||||
PROTOCOL: https
|
||||
APP_ENV: production
|
||||
POSTGRES_HOST: automatisch-db
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: automatisch
|
||||
POSTGRES_USERNAME: automatisch
|
||||
POSTGRES_PASSWORD: "{{ automatisch_db_password }}"
|
||||
REDIS_HOST: automatisch-redis
|
||||
REDIS_PORT: "6379"
|
||||
ENCRYPTION_KEY: "{{ automatisch_encryption_key }}"
|
||||
WEBHOOK_SECRET_KEY: "{{ automatisch_webhook_secret_key }}"
|
||||
APP_SECRET_KEY: "{{ automatisch_app_secret_key }}"
|
||||
TELEMETRY_ENABLED: "false"
|
||||
volumes:
|
||||
- {{ automatisch_data_dir }}/storage:/automatisch/packages/backend/storage
|
||||
networks:
|
||||
- internal
|
||||
logging:
|
||||
driver: gelf
|
||||
options:
|
||||
gelf-address: "udp://{{ graylog_host }}:{{ graylog_gelf_port }}"
|
||||
tag: "automatisch-worker"
|
||||
|
||||
networks:
|
||||
internal:
|
||||
{{ sovereign_network_name }}:
|
||||
external: true
|
||||
Reference in New Issue
Block a user