From a4687a63b37b9cf4150e4ed44891b9330f30aa63 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+Sporqist@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:52:53 +0100 Subject: [PATCH] Environment via Template Datei setzen --- tasks/main.yaml | 28 ++++---------- templates/environment.env.j2 | 71 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 templates/environment.env.j2 diff --git a/tasks/main.yaml b/tasks/main.yaml index 77e353f..af1eb71 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -34,6 +34,13 @@ enabled: yes state: started +- name: Upload Environment File + ansible.builtin.template: + src: environment.env.j2 + dest: "{{ git_user.home }}/gitea/environment.env" + owner: "{{ git_user.name }}" + mode: '600' + - name: Create Gitea container community.docker.docker_container: name: gitea @@ -52,23 +59,4 @@ - "3000:3000" - "22:2222" user: "{{ git_user.uid }}:{{ git_user.group }}" - env: - USER_UID: "{{ git_user.uid }}" - USER_GID: "{{ git_user.group }}" - GITEA__APP_NAME: "{{ gitea.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" - GITEA__service__DISABLE_REGISTRATION: "{{ gitea.service.disable_registration }}" - GITEA__service__REQUIRE_SIGNIN_VIEW: "{{ gitea.service.require_signin_view }}" - GITEA__service__REGISTER_EMAIL_CONFIRM: "{{ gitea.service.register_email_confirm }}" - GITEA__service__ENABLE_NOTIFY_MAIL: "{{ gitea.service.enable_notify_mail }}" - GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE: "{{ gitea.service.default_keep_email_private }}" - GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION: "{{ gitea.service.default_allow_create_organization }}" - GITEA__service__DEFAULT_ENABLE_TIMETRACKING: "{{ gitea.service.default_enable_timetracking }}" - GITEA__mailer__ENABLED: "{{ gitea.mailer.enabled }}" - GITEA__mailer__FROM: "git@{{ system.hostname }}.{{ system.domain }}" - GITEA__repository__ENABLE_PUSH_CREATE_USER: "{{ gitea.repository.enable_push_create_user }}" - GITEA__repository__ENABLE_PUSH_CREATE_ORG: "{{ gitea.repository.enable_push_create_org }}" - GITEA__repository__DEFAULT_PUSH_CREATE_PRIVATE: "{{ gitea.repository.default_push_create_private }}" + env_file: "{{ git_user.home }}/gitea/environment.env" diff --git a/templates/environment.env.j2 b/templates/environment.env.j2 new file mode 100644 index 0000000..8394582 --- /dev/null +++ b/templates/environment.env.j2 @@ -0,0 +1,71 @@ + +USER_UID={{ git_user.uid }} +USER_GID={{ git_user.group }} +GITEA__APP_NAME={{ gitea.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 }} +{% endif %} +{% if 'require_signin_view' in gitea['service'] %} +GITEA__service__REQUIRE_SIGNIN_VIEW={{ gitea.service.require_signin_view }} +{% endif %} +{% if 'register_email_confirm' in gitea['service'] %} +GITEA__service__REGISTER_EMAIL_CONFIRM={{ gitea.service.register_email_confirm }} +{% endif %} +{% if 'enable_notify_mail' in gitea['service'] %} +GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea.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 }} +{% endif %} +{% if 'default_allow_create_organization' in gitea['service'] %} +GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea.service.default_allow_create_organization }} +{% endif %} +{% if 'default_enable_timetracking' in gitea['service'] %} +GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea.service.default_enable_timetracking }} +{% endif %} +{% endif %} {# /service #} + +{% if 'mailer' in gitea %} +{% if 'enabled' in gitea['mailer'] %} +GITEA__mailer__ENABLED={{ gitea.mailer.enabled }} +{% endif %} +{% if 'from' in gitea['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 }} +{% endif %} +{% if 'enable_push_create_org' in gitea['repository']%} +GITEA__repository__ENABLE_PUSH_CREATE_ORG={{ gitea.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 }} +{% 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 }} +{% endif %} +{% if 'ecdsa' in gitea['ssh']['minimum_key_sizes'] %} +GITEA__ssh.minimum_key_sizes__ECDSA={{ gitea.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 }} +{% endif %} +{% if 'dsa' in gitea['ssh']['minimum_key_sizes'] %} +GITEA__ssh.minimum_key_sizes__DSA={{ gitea.ssh.minimum_key_sizes.dsa }} +{% endif %} +{% endif %} +{% endif %} {# /ssh #} \ No newline at end of file