service: Add support for mariadb
This commit is contained in:
@@ -251,6 +251,7 @@ argument_specs:
|
||||
type: str
|
||||
choices:
|
||||
- postgres
|
||||
- mariadb
|
||||
- none
|
||||
required: false
|
||||
default: none
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
---
|
||||
- name: Incude variables for database {{ service_database_type }}
|
||||
ansible.builtin.include_vars:
|
||||
file: database/{{ service_database_type }}.yaml
|
||||
|
||||
- name: Database container for {{ service_name }}
|
||||
ansible.builtin.import_role:
|
||||
name: container
|
||||
vars:
|
||||
container_name: "{{ service_name }}-{{ service_database_type }}" # This doesn't use _service_database_name to allow container role handlers to work
|
||||
container_image: "{{ service_postgres_image }}:{{ service_postgres_tag }}"
|
||||
container_image: "{{ _service_database_image }}"
|
||||
container_mounts:
|
||||
- type: volume
|
||||
source: "{{ _service_database_name }}"
|
||||
destination: /var/lib/postgresql/data
|
||||
destination: "{{ _service_database_mount_destination }}"
|
||||
container_networks: "{{ _service_database_networks }}"
|
||||
container_ip: >-
|
||||
{{ service_container_ip | ansible.utils.ipmath(1) if _service_static_ip else '' }}
|
||||
container_secrets:
|
||||
- name: "{{ _service_database_name }}"
|
||||
target: "{{ service_database_type }}"
|
||||
container_env:
|
||||
POSTGRES_USER: "{{ service_name | replace('-', '_') }}"
|
||||
POSTGRES_PASSWORD_FILE: "/run/secrets/{{ service_database_type }}"
|
||||
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
|
||||
container_env: "{{ _service_database_env }}"
|
||||
container_auto_update: "{{ service_auto_update }}"
|
||||
|
||||
8
roles/service/vars/database/mariadb.yaml
Normal file
8
roles/service/vars/database/mariadb.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
_service_database_image: docker.io/library/mariadb:lts
|
||||
_service_database_mount_destination: /var/lib/mysql
|
||||
_service_database_env:
|
||||
MARIADB_RANDOM_ROOT_PASSWORD: "1"
|
||||
MARIADB_USER: "{{ service_name | replace('-', '_') }}"
|
||||
MARIADB_DATABASE: "{{ service_name | replace('-', '_') }}"
|
||||
MARIADB_PASSWORD_FILE: "/run/secrets/{{ service_database_type }}"
|
||||
7
roles/service/vars/database/postgres.yaml
Normal file
7
roles/service/vars/database/postgres.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
_service_database_image: "{{ service_postgres_image }}:{{ service_postgres_tag }}"
|
||||
_service_database_mount_destination: /var/lib/postgresql/data
|
||||
_service_database_env:
|
||||
POSTGRES_USER: "{{ service_name | replace('-', '_') }}"
|
||||
POSTGRES_PASSWORD_FILE: "/run/secrets/{{ service_database_type }}"
|
||||
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
|
||||
Reference in New Issue
Block a user