Initial work on matrix-homeserver-proxy role and eliminating matrix-nginx-proxy

This is still very far from usable.

Various bridges and bots are still talking to
`matrix-nginx-proxy` instead of the new `matrix-homeserver-proxy` role.
These services need to be reworked. While reworking them,
various cleanups are being done as well as adding Traefik-labels to
those that need them.
This commit is contained in:
Slavi Pantaleev
2024-01-02 15:56:56 +02:00
parent c744d29567
commit 4a6287c528
35 changed files with 968 additions and 166 deletions

View File

@ -26,11 +26,20 @@ matrix_bot_chatgpt_container_src_path: "{{ matrix_bot_chatgpt_base_path }}/conta
# We use a small value here, because this container does not seem to handle the SIGTERM signal.
matrix_bot_chatgpt_container_stop_grace_time_seconds: 1
matrix_bot_chatgpt_container_network: ""
matrix_bot_chatgpt_container_additional_networks: "{{ matrix_bot_chatgpt_container_additional_networks_auto + matrix_bot_chatgpt_container_additional_networks_custom }}"
matrix_bot_chatgpt_container_additional_networks_auto: []
matrix_bot_chatgpt_container_additional_networks_custom: []
# A list of extra arguments to pass to the container
matrix_bot_chatgpt_container_extra_arguments: []
# List of systemd services that matrix-bot-chatgpt.service depends on
matrix_bot_chatgpt_systemd_required_services_list: ['docker.service']
matrix_bot_chatgpt_systemd_required_services_list: "{{ matrix_bot_chatgpt_systemd_required_services_list_default + matrix_bot_chatgpt_systemd_required_services_list_auto + matrix_bot_chatgpt_systemd_required_services_list_custom }}"
matrix_bot_chatgpt_systemd_required_services_list_default: ['docker.service']
matrix_bot_chatgpt_systemd_required_services_list_auto: []
matrix_bot_chatgpt_systemd_required_services_list_custom: []
# List of systemd services that matrix-bot-chatgpt.service wants
matrix_bot_chatgpt_systemd_wanted_services_list: []
@ -47,7 +56,7 @@ matrix_bot_chatgpt_keyv_bot_storage: true
# Matrix Static Settings (required, see notes)
# Defaults to "https://matrix.org"
matrix_bot_chatgpt_matrix_homeserver_url: "{{ matrix_homeserver_container_url }}" # MATRIX_HOMESERVER_URL=
matrix_bot_chatgpt_matrix_homeserver_url: "" # MATRIX_HOMESERVER_URL=
# With the @ and :DOMAIN, ie @SOMETHING:DOMAIN, needs to be set, created manually beforehand.
matrix_bot_chatgpt_matrix_bot_username_localpart: 'bot.chatgpt'
matrix_bot_chatgpt_matrix_bot_username: "@{{ matrix_bot_chatgpt_matrix_bot_username_localpart }}:{{ matrix_domain }}" # MATRIX_BOT_USERNAME=

View File

@ -56,6 +56,11 @@
path: "{{ matrix_bot_chatgpt_container_src_path }}"
pull: true
- name: Ensure chatgpt container network is created
community.general.docker_network:
name: "{{ matrix_bot_chatgpt_container_network }}"
driver: bridge
- name: Ensure matrix-bot-chatgpt.service installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-chatgpt.service.j2"

View File

@ -8,6 +8,8 @@
with_items:
- {'name': 'matrix_bot_chatgpt_openai_api_key', when: true}
- {'name': 'matrix_bot_chatgpt_matrix_bot_username', when: true}
- {'name': 'matrix_bot_chatgpt_container_network', when: true}
- {'name': 'matrix_bot_chatgpt_matrix_homeserver_url', when: true}
- name: Fail if OpenAI configuration not up-to-date.
ansible.builtin.fail:

View File

@ -16,7 +16,7 @@ Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ matrix_bot_chatgpt_container_stop_grace_time_seconds }} matrix-bot-chatgpt 2>/dev/null || true'
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-chatgpt 2>/dev/null || true'
ExecStart={{ devture_systemd_docker_base_host_command_docker }} run \
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--rm \
--name=matrix-bot-chatgpt \
--log-driver=none \
@ -24,7 +24,7 @@ ExecStart={{ devture_systemd_docker_base_host_command_docker }} run \
--cap-drop=ALL \
--read-only \
--tmpfs /tmp \
--network={{ matrix_docker_network }} \
--network={{ matrix_bot_chatgpt_container_network }} \
--env-file={{ matrix_bot_chatgpt_config_path }}/env \
--mount type=bind,src={{ matrix_bot_chatgpt_data_path }},dst=/data \
--env HOME=/data/home \
@ -33,6 +33,12 @@ ExecStart={{ devture_systemd_docker_base_host_command_docker }} run \
{% endfor %}
{{ matrix_bot_chatgpt_container_image }}
{% for network in matrix_bot_chatgpt_container_additional_networks %}
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-bot-chatgpt
{% endfor %}
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-bot-chatgpt
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ matrix_bot_chatgpt_container_stop_grace_time_seconds }} matrix-bot-chatgpt 2>/dev/null || true'
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-chatgpt 2>/dev/null || true'
Restart=always