From d7af37e9e9076ec85d883ffb6abfcb73df219155 Mon Sep 17 00:00:00 2001 From: rakshazi Date: Fri, 7 Jan 2022 09:41:52 +0200 Subject: [PATCH] matrix-bot-honoroit feedback --- roles/matrix-bot-honoroit/defaults/main.yml | 10 +++++++++- roles/matrix-bot-honoroit/tasks/setup_install.yml | 6 ++++++ roles/matrix-bot-honoroit/templates/env.j2 | 15 +++++++++++++++ .../systemd/matrix-bot-honoroit.service.j2 | 14 +------------- 4 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 roles/matrix-bot-honoroit/templates/env.j2 diff --git a/roles/matrix-bot-honoroit/defaults/main.yml b/roles/matrix-bot-honoroit/defaults/main.yml index ac612f84..ea83dde6 100644 --- a/roles/matrix-bot-honoroit/defaults/main.yml +++ b/roles/matrix-bot-honoroit/defaults/main.yml @@ -8,7 +8,8 @@ matrix_bot_honoroit_docker_repo: "https://gitlab.com/etke.cc/honoroit.git" matrix_bot_honoroit_docker_src_files_path: "{{ matrix_base_data_path }}/honoroit/docker-src" matrix_bot_honoroit_version: v0.9.0 -matrix_bot_honoroit_docker_image: "registry.gitlab.com/etke.cc/honoroit:{{ matrix_bot_honoroit_version }}" +matrix_bot_honoroit_docker_image: "{{ matrix_bot_honoroit_docker_image_name_prefix }}honoroit:{{ matrix_bot_honoroit_version }}" +matrix_bot_honoroit_docker_image_name_prefix: "{{ 'localhost/' if matrix_bot_honoroit_container_image_self_build else 'registry.gitlab.com/etke.cc/' }}" matrix_bot_honoroit_docker_image_force_pull: "{{ matrix_bot_honoroit_docker_image.endswith(':latest') }}" matrix_bot_honoroit_base_path: "{{ matrix_base_data_path }}/honoroit" @@ -93,3 +94,10 @@ matrix_bot_honoroit_text_emptyroom: '' # Text: done matrix_bot_honoroit_text_done: '' + +# Additional environment variables to pass to the Honoroit container +# +# Example: +# matrix_bot_honoroit_environment_variables_extension: | +# HONOROIT_TEXT_DONE=Done +matrix_bot_honoroit_environment_variables_extension: '' diff --git a/roles/matrix-bot-honoroit/tasks/setup_install.yml b/roles/matrix-bot-honoroit/tasks/setup_install.yml index 33723175..615235cb 100644 --- a/roles/matrix-bot-honoroit/tasks/setup_install.yml +++ b/roles/matrix-bot-honoroit/tasks/setup_install.yml @@ -39,6 +39,12 @@ - { path: "{{ matrix_bot_honoroit_docker_src_files_path }}", when: true} when: "item.when|bool" +- name: Ensure honoroit environment variables file created + template: + src: "{{ role_path }}/templates/env.j2" + dest: "{{ matrix_bot_honoroit_config_path }}/env" + mode: 0640 + - name: Ensure honoroit image is pulled docker_image: name: "{{ matrix_bot_honoroit_docker_image }}" diff --git a/roles/matrix-bot-honoroit/templates/env.j2 b/roles/matrix-bot-honoroit/templates/env.j2 new file mode 100644 index 00000000..4b1dd43f --- /dev/null +++ b/roles/matrix-bot-honoroit/templates/env.j2 @@ -0,0 +1,15 @@ +HONOROIT_LOGIN={{ matrix_bot_honoroit_login }} +HONOROIT_PASSWORD={{ matrix_bot_honoroit_password }} +HONOROIT_HOMESERVER={{ matrix_bot_honoroit_homeserver }} +HONOROIT_ROOMID={{ matrix_bot_honoroit_roomid }} +HONOROIT_DB_DSN={{ matrix_bot_honoroit_database_connection_string }} +HONOROIT_DB_DIALECT={{ matrix_bot_honoroit_database_dialect }} +HONOROIT_PREFIX={{ matrix_bot_honoroit_prefix }} +HONOROIT_SENTRY={{ matrix_bot_honoroit_sentry }} +HONOROIT_LOGLEVEL={{ matrix_bot_honoroit_loglevel }} +HONOROIT_TEXT_GREETINGS={{ matrix_bot_honoroit_text_greetings }} +HONOROIT_TEXT_ERROR={{ matrix_bot_honoroit_text_error }} +HONOROIT_TEXT_EMPTYROOM={{ matrix_bot_honoroit_text_emptyroom }} +HONOROIT_TEXT_DONE={{ matrix_bot_honoroit_text_done }} + +{{ matrix_bot_honoroit_environment_variables_extension }} diff --git a/roles/matrix-bot-honoroit/templates/systemd/matrix-bot-honoroit.service.j2 b/roles/matrix-bot-honoroit/templates/systemd/matrix-bot-honoroit.service.j2 index 38c2c7ff..c4eb1a94 100644 --- a/roles/matrix-bot-honoroit/templates/systemd/matrix-bot-honoroit.service.j2 +++ b/roles/matrix-bot-honoroit/templates/systemd/matrix-bot-honoroit.service.j2 @@ -22,19 +22,7 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-honoroit \ --cap-drop=ALL \ --read-only \ --network={{ matrix_docker_network }} \ - -e 'HONOROIT_LOGIN={{ matrix_bot_honoroit_login }}' \ - -e 'HONOROIT_PASSWORD={{ matrix_bot_honoroit_password }}' \ - -e 'HONOROIT_HOMESERVER={{ matrix_bot_honoroit_homeserver }}' \ - -e 'HONOROIT_ROOMID={{ matrix_bot_honoroit_roomid }}' \ - -e 'HONOROIT_DB_DSN={{ matrix_bot_honoroit_database_connection_string }}' \ - -e 'HONOROIT_DB_DIALECT={{ matrix_bot_honoroit_database_dialect }}' \ - -e 'HONOROIT_PREFIX={{ matrix_bot_honoroit_prefix }}' \ - -e 'HONOROIT_SENTRY={{ matrix_bot_honoroit_sentry }}' \ - -e 'HONOROIT_LOGLEVEL={{ matrix_bot_honoroit_loglevel }}' \ - -e 'HONOROIT_TEXT_GREETINGS={{ matrix_bot_honoroit_text_greetings }}' \ - -e 'HONOROIT_TEXT_ERROR={{ matrix_bot_honoroit_text_error }}' \ - -e 'HONOROIT_TEXT_EMPTYROOM={{ matrix_bot_honoroit_text_emptyroom }}' \ - -e 'HONOROIT_TEXT_DONE={{ matrix_bot_honoroit_text_done }}' \ + --env-file={{ matrix_bot_honoroit_config_path }}/env \ --mount type=bind,src={{ matrix_bot_honoroit_data_path }},dst=/data \ {% for arg in matrix_bot_honoroit_container_extra_arguments %} {{ arg }} \