Dictionary Merge: gitea für host variablen. gitea_defaults für defaults

This commit is contained in:
Marius Alwan Meyer 2022-11-11 17:57:30 +01:00
parent a4687a63b3
commit b8ec411c58
3 changed files with 45 additions and 38 deletions

View File

@ -44,7 +44,7 @@
- name: Create Gitea container - name: Create Gitea container
community.docker.docker_container: community.docker.docker_container:
name: gitea name: gitea
image: "gitea/gitea:{{ gitea['version'] }}-rootless" image: "gitea/gitea:{{ gitea_vars['version'] }}-rootless"
comparisons: comparisons:
image: strict image: strict
volumes: strict volumes: strict

View File

@ -1,71 +1,71 @@
USER_UID={{ git_user.uid }} USER_UID={{ git_user.uid }}
USER_GID={{ git_user.group }} USER_GID={{ git_user.group }}
GITEA__APP_NAME={{ gitea.app_name }} GITEA__APP_NAME={{ gitea_vars.app_name }}
GITEA__RUN_USER={{ git_user.name }} GITEA__RUN_USER={{ git_user.name }}
GITEA__server__ROOT_URL=https://{{ system.hostname }}.{{ system.domain }}/ GITEA__server__ROOT_URL=https://{{ system.hostname }}.{{ system.domain }}/
GITEA__server__Domain={{ system.hostname }}.{{ system.domain }} GITEA__server__Domain={{ system.hostname }}.{{ system.domain }}
GITEA__server__SSH_PORT=22 GITEA__server__SSH_PORT=22
{% if 'service' in gitea %} {% if 'service' in gitea_vars %}
{% if 'disable_registration' in gitea['service'] %} {% if 'disable_registration' in gitea_vars['service'] %}
GITEA__service__DISABLE_REGISTRATION={{ gitea.service.disable_registration }} GITEA__service__DISABLE_REGISTRATION={{ gitea_vars.service.disable_registration }}
{% endif %} {% endif %}
{% if 'require_signin_view' in gitea['service'] %} {% if 'require_signin_view' in gitea_vars['service'] %}
GITEA__service__REQUIRE_SIGNIN_VIEW={{ gitea.service.require_signin_view }} GITEA__service__REQUIRE_SIGNIN_VIEW={{ gitea_vars.service.require_signin_view }}
{% endif %} {% endif %}
{% if 'register_email_confirm' in gitea['service'] %} {% if 'register_email_confirm' in gitea_vars['service'] %}
GITEA__service__REGISTER_EMAIL_CONFIRM={{ gitea.service.register_email_confirm }} GITEA__service__REGISTER_EMAIL_CONFIRM={{ gitea_vars.service.register_email_confirm }}
{% endif %} {% endif %}
{% if 'enable_notify_mail' in gitea['service'] %} {% if 'enable_notify_mail' in gitea_vars['service'] %}
GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea.service.enable_notify_mail }} GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea_vars.service.enable_notify_mail }}
{% endif %} {% endif %}
{% if 'default_keep_email_private' in gitea['service'] %} {% if 'default_keep_email_private' in gitea_vars['service'] %}
GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea.service.default_keep_email_private }} GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea_vars.service.default_keep_email_private }}
{% endif %} {% endif %}
{% if 'default_allow_create_organization' in gitea['service'] %} {% if 'default_allow_create_organization' in gitea_vars['service'] %}
GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea.service.default_allow_create_organization }} GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea_vars.service.default_allow_create_organization }}
{% endif %} {% endif %}
{% if 'default_enable_timetracking' in gitea['service'] %} {% if 'default_enable_timetracking' in gitea_vars['service'] %}
GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea.service.default_enable_timetracking }} GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea_vars.service.default_enable_timetracking }}
{% endif %} {% endif %}
{% endif %} {# /service #} {% endif %} {# /service #}
{% if 'mailer' in gitea %} {% if 'mailer' in gitea_vars %}
{% if 'enabled' in gitea['mailer'] %} {% if 'enabled' in gitea_vars['mailer'] %}
GITEA__mailer__ENABLED={{ gitea.mailer.enabled }} GITEA__mailer__ENABLED={{ gitea_vars.mailer.enabled }}
{% endif %} {% endif %}
{% if 'from' in gitea['mailer'] %} {% if 'from' in gitea_vars['mailer'] %}
GITEA__mailer__FROM=git@{{ system.hostname }}.{{ system.domain }} GITEA__mailer__FROM=git@{{ system.hostname }}.{{ system.domain }}
{% endif %} {% endif %}
{% endif %} {# /mailer #} {% endif %} {# /mailer #}
{% if 'repository' in gitea %} {% if 'repository' in gitea_vars %}
{% if 'enable_push_create_user' in gitea['repository']%} {% if 'enable_push_create_user' in gitea_vars['repository']%}
GITEA__repository__ENABLE_PUSH_CREATE_USER={{ gitea.repository.enable_push_create_user }} GITEA__repository__ENABLE_PUSH_CREATE_USER={{ gitea_vars.repository.enable_push_create_user }}
{% endif %} {% endif %}
{% if 'enable_push_create_org' in gitea['repository']%} {% if 'enable_push_create_org' in gitea_vars['repository']%}
GITEA__repository__ENABLE_PUSH_CREATE_ORG={{ gitea.repository.enable_push_create_org }} GITEA__repository__ENABLE_PUSH_CREATE_ORG={{ gitea_vars.repository.enable_push_create_org }}
{% endif %} {% endif %}
{% if 'default_push_create_private' in gitea['repository']%} {% if 'default_push_create_private' in gitea_vars['repository']%}
GITEA__repository__DEFAULT_PUSH_CREATE_PRIVATE={{ gitea.repository.default_push_create_private }} GITEA__repository__DEFAULT_PUSH_CREATE_PRIVATE={{ gitea_vars.repository.default_push_create_private }}
{% endif %} {% endif %}
{% endif %} {# /repository #} {% endif %} {# /repository #}
{% if 'ssh' in gitea %} {% if 'ssh' in gitea_vars %}
{% if 'minimum_key_sizes' in gitea['ssh'] %} {% if 'minimum_key_sizes' in gitea_vars['ssh'] %}
{% if 'ed25519' in gitea['ssh']['minimum_key_sizes'] %} {% if 'ed25519' in gitea_vars['ssh']['minimum_key_sizes'] %}
GITEA__ssh.minimum_key_sizes__ED25519={{ gitea.ssh.minimum_key_sizes.ed25519 }} GITEA__ssh.minimum_key_sizes__ED25519={{ gitea_vars.ssh.minimum_key_sizes.ed25519 }}
{% endif %} {% endif %}
{% if 'ecdsa' in gitea['ssh']['minimum_key_sizes'] %} {% if 'ecdsa' in gitea_vars['ssh']['minimum_key_sizes'] %}
GITEA__ssh.minimum_key_sizes__ECDSA={{ gitea.ssh.minimum_key_sizes.ecdsa }} GITEA__ssh.minimum_key_sizes__ECDSA={{ gitea_vars.ssh.minimum_key_sizes.ecdsa }}
{% endif %} {% endif %}
{% if 'rsa' in gitea['ssh']['minimum_key_sizes'] %} {% if 'rsa' in gitea_vars['ssh']['minimum_key_sizes'] %}
GITEA__ssh.minimum_key_sizes__RSA={{ gitea.ssh.minimum_key_sizes.rsa }} GITEA__ssh.minimum_key_sizes__RSA={{ gitea_vars.ssh.minimum_key_sizes.rsa }}
{% endif %} {% endif %}
{% if 'dsa' in gitea['ssh']['minimum_key_sizes'] %} {% if 'dsa' in gitea_vars['ssh']['minimum_key_sizes'] %}
GITEA__ssh.minimum_key_sizes__DSA={{ gitea.ssh.minimum_key_sizes.dsa }} GITEA__ssh.minimum_key_sizes__DSA={{ gitea_vars.ssh.minimum_key_sizes.dsa }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {# /ssh #} {% endif %} {# /ssh #}

7
vars/main.yaml Normal file
View File

@ -0,0 +1,7 @@
gitea_defaults:
gitea_vars: |
{%- if gitea is defined and gitea is iterable -%}
{{ gitea_defaults | combine (gitea, recursive=True) }}
{%- else -%}
{{ gitea }}
{%- endif -%}