diff --git a/templates/docker-compose.yaml.j2 b/templates/docker-compose.yaml.j2 index 084f5f9..817165c 100644 --- a/templates/docker-compose.yaml.j2 +++ b/templates/docker-compose.yaml.j2 @@ -24,12 +24,6 @@ services: - "22:2222" user: "{{ git_user.uid }}:{{ git_user.group }}" env_file: ./environment.env - environment: - - GITEA__database__DB_TYPE=mysql - - GITEA__database__HOST=db:3306 - - GITEA__database__NAME=gitea - - GITEA__database__USER=gitea - - "GITEA__database__PASSWD={{ vault[inventory_hostname]['gitea']['db_secret'] }}" networks: - gitea depends_on: @@ -39,8 +33,8 @@ services: image: mysql:8 restart: always environment: - - MYSQL_DATABASE=gitea - - MYSQL_USER=gitea + - "MYSQL_DATABASE={{ gitea_vars.database.name }}" + - "MYSQL_USER={{ gitea_vars.database.user }}" - "MYSQL_PASSWORD={{ vault[inventory_hostname]['gitea']['database']['passwd'] }}" - "MYSQL_ROOT_PASSWORD={{ vault[inventory_hostname]['gitea']['database']['root_passwd'] }}" networks: diff --git a/templates/environment.env.j2 b/templates/environment.env.j2 index 903c7e5..f4c8543 100644 --- a/templates/environment.env.j2 +++ b/templates/environment.env.j2 @@ -13,6 +13,66 @@ GITEA__server__Domain={{ system.hostname }}.{{ system.domain }} GITEA__server__SSH_PORT=22 +{% if 'database' in gitea_vars %} +{% if 'db_type' in gitea_vars['database'] %} +GITEA__database__DB_TYPE={{ gitea_vars.database.db_type }} +{% endif %} +{% if 'host' in gitea_vars['database'] %} +GITEA__database__HOST={{ gitea_vars.database.host }} +{% endif %} +{% if 'name' in gitea_vars['database'] %} +GITEA__database__NAME={{ gitea_vars.database.name }} +{% endif %} +{% if 'user' in gitea_vars['database'] %} +GITEA__database__USER={{ gitea_vars.database.user }} +{% endif %} +{% if 'passwd' in vault[inventory_hostname]['gitea']['database'] %} +GITEA__database__PASSWD={{ vault[inventory_hostname]['gitea']['database']['passwd'] }} +{% endif %} +{% if 'schema' in gitea_vars['database'] %} +GITEA__database__SCHEMA={{ gitea_vars.database.schema }} +{% endif %} +{% if 'ssl_mode' in gitea_vars['database'] %} +GITEA__database__SSL_MODE={{ gitea_vars.database.ssl_mode }} +{% endif %} +{% if 'sqlite_timeout' in gitea_vars['database'] %} +GITEA__database__SQLITE_TIMEOUT={{ gitea_vars.database.sqlite_timeout }} +{% endif %} +{% if 'sqlite_journal_mode' in gitea_vars['database'] %} +GITEA__database__SQLITE_JOURNAL_MODE={{ gitea_vars.database.sqlite_journal_mode }} +{% endif %} +{% if 'iterate_buffer_size' in gitea_vars['database'] %} +GITEA__database__ITERATE_BUFFER_SIZE={{ gitea_vars.database.iterate_buffer_size }} +{% endif %} +{% if 'charset' in gitea_vars['database'] %} +GITEA__database__CHARSET={{ gitea_vars.database.charset }} +{% endif %} +{% if 'path' in gitea_vars['database'] %} +GITEA__database__PATH={{ gitea_vars.database.path }} +{% endif %} +{% if 'log_sql' in gitea_vars['database'] %} +GITEA__database__ABC={{ gitea_vars.database.abc }} +{% endif %} +{% if 'db_retries' in gitea_vars['database'] %} +GITEA__database__DB_RETRIES={{ gitea_vars.database.db_retries }} +{% endif %} +{% if 'db_retry_backoff' in gitea_vars['database'] %} +GITEA__database__DB_RETRY_BACKOFF={{ gitea_vars.database.db_retry_backoff }} +{% endif %} +{% if 'max_open_conns' in gitea_vars['database'] %} +GITEA__database__MAX_OPEN_CONNS={{ gitea_vars.database.max_open_conns }} +{% endif %} +{% if 'max_idle_conns' in gitea_vars['database'] %} +GITEA__database__MAX_IDLE_CONNS={{ gitea_vars.database.max_idle_conns }} +{% endif %} +{% if 'conn_max_lifetime' in gitea_vars['database'] %} +GITEA__database__CONN_MAX_LIFETIME={{ gitea_vars.database.conn_max_lifetime }} +{% endif %} +{% if 'auto_migration' in gitea_vars['database'] %} +GITEA__database__AUTO_MIGRATION={{ gitea_vars.database.auto_migration }} +{% endif %} +{% endif %} {# /database #} + {% if 'service' in gitea_vars %} {% if 'disable_registration' in gitea_vars['service'] %} GITEA__service__DISABLE_REGISTRATION={{ gitea_vars.service.disable_registration }}