From b8ec411c58c2d7a13cd276be8e2cc70a25028456 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+Sporqist@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:57:30 +0100 Subject: [PATCH] =?UTF-8?q?Dictionary=20Merge:=20gitea=20f=C3=BCr=20host?= =?UTF-8?q?=20variablen.=20gitea=5Fdefaults=20f=C3=BCr=20defaults?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/main.yaml | 2 +- templates/environment.env.j2 | 74 ++++++++++++++++++------------------ vars/main.yaml | 7 ++++ 3 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 vars/main.yaml diff --git a/tasks/main.yaml b/tasks/main.yaml index af1eb71..3b505e4 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -44,7 +44,7 @@ - name: Create Gitea container community.docker.docker_container: name: gitea - image: "gitea/gitea:{{ gitea['version'] }}-rootless" + image: "gitea/gitea:{{ gitea_vars['version'] }}-rootless" comparisons: image: strict volumes: strict diff --git a/templates/environment.env.j2 b/templates/environment.env.j2 index 8394582..0ac887b 100644 --- a/templates/environment.env.j2 +++ b/templates/environment.env.j2 @@ -1,71 +1,71 @@ USER_UID={{ git_user.uid }} 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__server__ROOT_URL=https://{{ system.hostname }}.{{ system.domain }}/ GITEA__server__Domain={{ system.hostname }}.{{ system.domain }} GITEA__server__SSH_PORT=22 -{% if 'service' in gitea %} -{% if 'disable_registration' in gitea['service'] %} -GITEA__service__DISABLE_REGISTRATION={{ gitea.service.disable_registration }} +{% if 'service' in gitea_vars %} +{% if 'disable_registration' in gitea_vars['service'] %} +GITEA__service__DISABLE_REGISTRATION={{ gitea_vars.service.disable_registration }} {% endif %} -{% if 'require_signin_view' in gitea['service'] %} -GITEA__service__REQUIRE_SIGNIN_VIEW={{ gitea.service.require_signin_view }} +{% if 'require_signin_view' in gitea_vars['service'] %} +GITEA__service__REQUIRE_SIGNIN_VIEW={{ gitea_vars.service.require_signin_view }} {% endif %} -{% if 'register_email_confirm' in gitea['service'] %} -GITEA__service__REGISTER_EMAIL_CONFIRM={{ gitea.service.register_email_confirm }} +{% if 'register_email_confirm' in gitea_vars['service'] %} +GITEA__service__REGISTER_EMAIL_CONFIRM={{ gitea_vars.service.register_email_confirm }} {% endif %} -{% if 'enable_notify_mail' in gitea['service'] %} -GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea.service.enable_notify_mail }} +{% if 'enable_notify_mail' in gitea_vars['service'] %} +GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea_vars.service.enable_notify_mail }} {% endif %} -{% if 'default_keep_email_private' in gitea['service'] %} -GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea.service.default_keep_email_private }} +{% if 'default_keep_email_private' in gitea_vars['service'] %} +GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea_vars.service.default_keep_email_private }} {% endif %} -{% if 'default_allow_create_organization' in gitea['service'] %} -GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea.service.default_allow_create_organization }} +{% if 'default_allow_create_organization' in gitea_vars['service'] %} +GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea_vars.service.default_allow_create_organization }} {% endif %} -{% if 'default_enable_timetracking' in gitea['service'] %} -GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea.service.default_enable_timetracking }} +{% if 'default_enable_timetracking' in gitea_vars['service'] %} +GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea_vars.service.default_enable_timetracking }} {% endif %} {% endif %} {# /service #} -{% if 'mailer' in gitea %} -{% if 'enabled' in gitea['mailer'] %} -GITEA__mailer__ENABLED={{ gitea.mailer.enabled }} +{% if 'mailer' in gitea_vars %} +{% if 'enabled' in gitea_vars['mailer'] %} +GITEA__mailer__ENABLED={{ gitea_vars.mailer.enabled }} {% endif %} -{% if 'from' in gitea['mailer'] %} +{% if 'from' in gitea_vars['mailer'] %} GITEA__mailer__FROM=git@{{ system.hostname }}.{{ system.domain }} {% endif %} {% endif %} {# /mailer #} -{% if 'repository' in gitea %} -{% if 'enable_push_create_user' in gitea['repository']%} -GITEA__repository__ENABLE_PUSH_CREATE_USER={{ gitea.repository.enable_push_create_user }} +{% if 'repository' in gitea_vars %} +{% if 'enable_push_create_user' in gitea_vars['repository']%} +GITEA__repository__ENABLE_PUSH_CREATE_USER={{ gitea_vars.repository.enable_push_create_user }} {% endif %} -{% if 'enable_push_create_org' in gitea['repository']%} -GITEA__repository__ENABLE_PUSH_CREATE_ORG={{ gitea.repository.enable_push_create_org }} +{% if 'enable_push_create_org' in gitea_vars['repository']%} +GITEA__repository__ENABLE_PUSH_CREATE_ORG={{ gitea_vars.repository.enable_push_create_org }} {% endif %} -{% if 'default_push_create_private' in gitea['repository']%} -GITEA__repository__DEFAULT_PUSH_CREATE_PRIVATE={{ gitea.repository.default_push_create_private }} +{% if 'default_push_create_private' in gitea_vars['repository']%} +GITEA__repository__DEFAULT_PUSH_CREATE_PRIVATE={{ gitea_vars.repository.default_push_create_private }} {% endif %} {% endif %} {# /repository #} -{% if 'ssh' in gitea %} -{% if 'minimum_key_sizes' in gitea['ssh'] %} -{% if 'ed25519' in gitea['ssh']['minimum_key_sizes'] %} -GITEA__ssh.minimum_key_sizes__ED25519={{ gitea.ssh.minimum_key_sizes.ed25519 }} +{% if 'ssh' in gitea_vars %} +{% if 'minimum_key_sizes' in gitea_vars['ssh'] %} +{% if 'ed25519' in gitea_vars['ssh']['minimum_key_sizes'] %} +GITEA__ssh.minimum_key_sizes__ED25519={{ gitea_vars.ssh.minimum_key_sizes.ed25519 }} {% endif %} -{% if 'ecdsa' in gitea['ssh']['minimum_key_sizes'] %} -GITEA__ssh.minimum_key_sizes__ECDSA={{ gitea.ssh.minimum_key_sizes.ecdsa }} +{% if 'ecdsa' in gitea_vars['ssh']['minimum_key_sizes'] %} +GITEA__ssh.minimum_key_sizes__ECDSA={{ gitea_vars.ssh.minimum_key_sizes.ecdsa }} {% endif %} -{% if 'rsa' in gitea['ssh']['minimum_key_sizes'] %} -GITEA__ssh.minimum_key_sizes__RSA={{ gitea.ssh.minimum_key_sizes.rsa }} +{% if 'rsa' in gitea_vars['ssh']['minimum_key_sizes'] %} +GITEA__ssh.minimum_key_sizes__RSA={{ gitea_vars.ssh.minimum_key_sizes.rsa }} {% endif %} -{% if 'dsa' in gitea['ssh']['minimum_key_sizes'] %} -GITEA__ssh.minimum_key_sizes__DSA={{ gitea.ssh.minimum_key_sizes.dsa }} +{% if 'dsa' in gitea_vars['ssh']['minimum_key_sizes'] %} +GITEA__ssh.minimum_key_sizes__DSA={{ gitea_vars.ssh.minimum_key_sizes.dsa }} {% endif %} {% endif %} {% endif %} {# /ssh #} \ No newline at end of file diff --git a/vars/main.yaml b/vars/main.yaml new file mode 100644 index 0000000..e05e69e --- /dev/null +++ b/vars/main.yaml @@ -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 -%}