add ki role

This commit is contained in:
weeman 2021-08-02 22:13:26 +02:00
parent e4d7f16679
commit b213d9104b
Signed by: weeman
GPG Key ID: 34F0524D4DA694A1
4 changed files with 103 additions and 1 deletions

View File

@ -1,2 +1,21 @@
# ki-ansible
<!--
SPDX-FileCopyrightText: 2021 WTF Kooperative eG <https://wtf-eg.de/>
SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Kompetenzinventar ⚒ Ansible Rolle
## Variablen:
| Name | Beschreibung | Beispiel |
| --- | --- | --- |
| `ki_frontend_image` | KI Frontend Image | `registry.wtf-eg.net/ki-frontend:23` |
| `ki_frontend_uri` | URI zum Frontend | `https://ki-wtf-eg.de/` |
| `ki_frontend_port` | Docker-Port für das Frontend | `13337` |
| `ki_backend_image` | KI Backend Image | `registry.wtf-eg.net/ki-backend:42` |
| `ki_backend_uri` | URI zum Backend | `https://ki-wtf-eg.de/api` |
| `ki_backend_port` | Docker-Port für das Backend | `13338` |
| `ki_db_image` | Datenbank-Image | `mariadb:10.6.3` |
| `ki_db_root_password` | KI DB Root Passwort | |
| `ki_db_password` | KI DB Anwendungspasswort | |

76
tasks/main.yml Normal file
View File

@ -0,0 +1,76 @@
# SPDX-FileCopyrightText: 2021 WTF Kooperative eG <https://wtf-eg.de/>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
- name: be sure the ki network exists
community.general.docker_network:
name: ki
- name: "be sure the {{ item }} volume exists"
docker_volume:
name: "{{ item }}"
with_items:
- ki_data
- ki_db
- name: be sure the ki config directory exists
become: true
file:
path: /etc/ki
state: directory
owner: root
group: root
mode: "0755"
- name: be sure the ki-frontend config file is in place
become: true
template:
src: frontend.js
dest: /etc/ki/frontend.js
owner: root
group: root
mode: "0655"
- name: be sure the ki_database container is running
community.general.docker_container:
name: ki_db
image: "{{ ki_db_image }}"
restart_policy: unless-stopped
env:
MYSQL_ROOT_PASSWORD: "{{ ki_db_root_password }}"
MYSQL_DATABASE: ki
MYSQL_USER: ki
MYSQL_PASSWORD: "{{ ki_db_password }}"
volumes:
- ki_db:/var/lib/mysql/
networks:
- name: ki
- name: be sure the ki_backend container is running
community.general.docker_container:
name: ki_backend
image: "{{ ki_backend_image }}"
restart_policy: unless-stopped
env:
SQLALCHEMY_DATABASE_URI: "mariadb+pymysql://ki:{{ ki_db_password }}@ki_db:3306/ki"
FLASK_ENV: "development"
KI_LOGLEVEL: "10"
KI_AUTH: "file"
CORS_ORIGINS: "{{ ki_frontend_uri }}"
ports:
- "{{ ki_backend_port }}:5000"
volumes:
- ki_data:/app/data/
networks:
- name: ki
- name: be sure the ki_frontend container is running
community.general.docker_container:
name: ki_frontend
image: "{{ ki_frontend_image }}"
restart_policy: unless-stopped
ports:
- "{{ ki_frontend_port }}:80"
volumes:
- /etc/ki/frontend.js:/usr/share/nginx/html/config.js

7
templates/frontend.js Normal file
View File

@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2021 WTF Kooperative eG <https://wtf-eg.de/>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
window.ki = {
apiUrl: '{{ ki_backend_uri }}'
}