Merge webhook into teamspeak_fallback

This commit is contained in:
Tobias Reisinger 2024-10-13 21:02:19 +02:00
parent 8b5593e586
commit 09e886c712
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
8 changed files with 110 additions and 137 deletions

View file

@ -1,19 +0,0 @@
services:
teamspeak:
image: teamspeak
restart: always
ports:
- 9987:9987/udp
- 10011:10011
- 30033:30033
environment:
TS3SERVER_DB_PLUGIN: ts3db_sqlite3
TS3SERVER_DB_SQLCREATEPATH: create_sqlite
TS3SERVER_LICENSE: accept
volumes:
- data:/var/ts3server/
volumes:
data:
external: true
name: teamspeak_fallback_data

View file

@ -5,15 +5,12 @@
- name: Deploy {{ svc.name }}
vars:
svc: "{{ teamspeak_fallback_svc }}"
compose: "{{ teamspeak_fallback_compose }}"
env: "{{ teamspeak_fallback_env }}"
yml: "{{ teamspeak_fallback_yml }}"
block:
- name: Import tasks to create service directory
ansible.builtin.import_tasks: tasks/steps/create-service-directory.yml
- name: Copy the docker-compose file
ansible.builtin.copy:
src: docker-compose.yml
dest: "{{ (service_path, 'docker-compose.yml') | path_join }}"
mode: "0644"
- name: Import prepare tasks for common service
ansible.builtin.import_tasks: tasks/prepare-common-service.yml
- name: Template the conditional-start script
ansible.builtin.template:
@ -21,6 +18,37 @@
dest: "{{ (service_path, 'conditional-start.sh') | path_join }}"
mode: "0755"
- name: Set webhook config path
ansible.builtin.set_fact:
config_path: "{{ (service_path, 'config') | path_join }}"
- name: Create config directory
ansible.builtin.file:
path: "{{ config_path }}"
state: directory
mode: "0755"
- name: Template main config
ansible.builtin.template:
src: yml.j2
dest: "{{ (config_path, 'hooks.yml') | path_join }}"
mode: "0644"
register: cmd_result
- name: Set the docker force-recreate flag
ansible.builtin.set_fact:
docker_force_recreate: --force-recreate
when: cmd_result.changed # noqa: no-handler We need to handle the restart per service. Handlers don't support variables.
- name: Copy the teamspeak-fallback-db script
ansible.builtin.copy:
src: teamspeak-fallback-db
dest: "{{ (config_path, 'teamspeak-fallback-db') | path_join }}"
mode: "0755"
- name: Import start tasks for common service
ansible.builtin.import_tasks: tasks/start-common-service.yml
- name: Copy the system service
ansible.builtin.template:
src: teamspeak-fallback.service.j2

View file

@ -6,12 +6,12 @@ do
then
if docker compose ps --services | grep teamspeak >/dev/null; then
echo "Stopping Server"
docker compose down
docker compose down teamspeak
fi
else
if ! docker compose ps --services | grep teamspeak >/dev/null; then
echo "Starting Server"
docker compose up -d --pull=always
docker compose up -d --pull=always teamspeak
fi
fi
sleep 2

View file

@ -2,5 +2,62 @@
teamspeak_fallback_check_server: ts.sneiso.eu
teamspeak_fallback_check_port: 30033
teamspeak_fallback_webhook_token: "{{ vault_teamspeak_fallback.webhook_token }}"
teamspeak_fallback_user: 9987
teamspeak_fallback_group: 9987
teamspeak_fallback_svc:
name: teamspeak-fallback
domain: ts.serguzim.me
additional_domains:
- hook.serguzim.me
port: 9000
teamspeak_fallback_env:
TEAMSPEAK_USER: "{{ teamspeak_fallback_user }}"
TEAMSPEAK_GROUP: "{{ teamspeak_fallback_group }}"
teamspeak_fallback_yml:
- id: teamspeak-fallback-db
trigger-rule-mismatch-http-response-code: 400
execute-command: /config/teamspeak-fallback-db
pass-file-to-command:
- source: payload
name: data
envname: WEBHOOK_DATA
base64decode: true
trigger-rule:
and:
- match:
type: value
value: "{{ teamspeak_fallback_webhook_token }}"
parameter:
source: header
name: X-Webhook-Token
teamspeak_fallback_compose:
watchtower: true
image: ghcr.io/thecatlady/webhook
volumes:
- ./config:/config:ro
- data:/mnt/teamspeak_fallback_data
file:
services:
app:
command: ["-verbose", "-hooks=/config/hooks.yml"]
teamspeak:
image: teamspeak
restart: always
ports:
- 9987:9987/udp
- 10011:10011
- 30033:30033
environment:
TS3SERVER_DB_PLUGIN: ts3db_sqlite3
TS3SERVER_DB_SQLCREATEPATH: create_sqlite
TS3SERVER_LICENSE: accept
volumes:
- data:/var/ts3server/
volumes:
data:

View file

@ -1,44 +0,0 @@
---
- name: Set common facts
ansible.builtin.import_tasks: tasks/set-default-facts.yml
- name: Deploy {{ svc.name }}
vars:
svc: "{{ webhook_svc }}"
compose: "{{ webhook_compose }}"
env: "{{ webhook_env }}"
yml: "{{ webhook_yml }}"
block:
- name: Import prepare tasks for common service
ansible.builtin.import_tasks: tasks/prepare-common-service.yml
- name: Set webhook config path
ansible.builtin.set_fact:
config_path: "{{ (service_path, 'config') | path_join }}"
- name: Create config directory
ansible.builtin.file:
path: "{{ config_path }}"
state: directory
mode: "0755"
- name: Template main config
ansible.builtin.template:
src: yml.j2
dest: "{{ (config_path, 'hooks.yml') | path_join }}"
mode: "0644"
register: cmd_result
- name: Set the docker force-recreate flag
ansible.builtin.set_fact:
docker_force_recreate: --force-recreate
when: cmd_result.changed # noqa: no-handler We need to handle the restart per service. Handlers don't support variables.
- name: Copy the teamspeak-fallback-db script
ansible.builtin.copy:
src: teamspeak-fallback-db
dest: "{{ (config_path, 'teamspeak-fallback-db') | path_join }}"
mode: "0755"
- name: Import start tasks for common service
ansible.builtin.import_tasks: tasks/start-common-service.yml

View file

@ -1,45 +0,0 @@
---
webhook_teamspeak_fallback_db_token: "{{ vault_webhook.teamspeak_fallback_db_token }}"
webhook_teamspeak_user: 9987
webhook_teamspeak_group: 9987
webhook_svc:
name: webhook
domain: hook.serguzim.me
port: 9000
webhook_env:
TEAMSPEAK_USER: "{{ webhook_teamspeak_user }}"
TEAMSPEAK_GROUP: "{{ webhook_teamspeak_group }}"
webhook_yml:
- id: teamspeak-fallback-db
trigger-rule-mismatch-http-response-code: 400
execute-command: /config/teamspeak-fallback-db
pass-file-to-command:
- source: payload
name: data
envname: WEBHOOK_DATA
base64decode: true
trigger-rule:
and:
- match:
type: value
value: "{{ webhook_teamspeak_fallback_db_token }}"
parameter:
source: header
name: X-Webhook-Token
webhook_compose:
watchtower: true
image: ghcr.io/thecatlady/webhook
volumes:
- ./config:/config:ro
- teamspeak_fallback_data:/mnt/teamspeak_fallback_data
file:
services:
app:
command: ["-verbose", "-hooks=/config/hooks.yml"]
volumes:
teamspeak_fallback_data:
name: teamspeak_fallback_data

View file

@ -440,14 +440,25 @@ services = {
"teamspeak_fallback" = {
name = "teamspeak_fallback"
host = "node003"
dns = [{
dns = [
{
domain = "serguzim.me"
target = "ts"
}]
},
{
domain = "serguzim.me"
target = "hook"
name = "teamspeak_fallback-hook"
alias = "teamspeak_fallback"
}
]
backup = [{
name = "teamspeak_fallback_data"
type = "docker"
}]
monitoring = {
group = "7-support"
}
auth = false
database = false
s3 = false
@ -514,21 +525,6 @@ services = {
s3 = false
},
"webhook" = {
name = "webhook"
host = "node003"
dns = [{
domain = "serguzim.me"
target = "hook"
}]
monitoring = {
group = "7-support"
}
auth = false
database = false
s3 = false
},
"wiki_js" = {
name = "wiki_js"
host = "node003"