Signed-off-by: Suguru Hirahara <did🔑z6MkvVZk1A3KBApWJXv2Ju4H14ErDfRGxh8zxdXSZ4vACDg5>
pull/5288/head
| @@ -1,86 +0,0 @@ | |||||
| # SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr | |||||
| # SPDX-FileCopyrightText: 2022 - 2025 Slavi Pantaleev | |||||
| # SPDX-FileCopyrightText: 2022 Erick Wibben | |||||
| # SPDX-FileCopyrightText: 2022 MDAD project contributors | |||||
| # SPDX-FileCopyrightText: 2022 Nikita Chernyi | |||||
| # SPDX-FileCopyrightText: 2023 Samuel Meenzen | |||||
| # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara | |||||
| # | |||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| --- | |||||
| # matrix-registration-bot creates and manages registration tokens for a Matrix server | |||||
| # Project source code URL: https://github.com/moan0s/matrix-registration-bot | |||||
| matrix_bot_matrix_registration_bot_enabled: true | |||||
| matrix_bot_matrix_registration_bot_container_image_self_build: false | |||||
| matrix_bot_matrix_registration_bot_container_repo: "https://github.com/moan0s/matrix-registration-bot.git" | |||||
| matrix_bot_matrix_registration_bot_container_repo_version: "{{ 'main' if matrix_bot_matrix_registration_bot_version == 'latest' else ('v' + matrix_bot_matrix_registration_bot_version) }}" | |||||
| matrix_bot_matrix_registration_bot_container_src_files_path: "{{ matrix_bot_matrix_registration_bot_base_path }}/docker-src" | |||||
| # renovate: datasource=docker depName=moanos/matrix-registration-bot | |||||
| matrix_bot_matrix_registration_bot_version: 1.3.0 | |||||
| matrix_bot_matrix_registration_bot_container_iteration: 0 | |||||
| matrix_bot_matrix_registration_bot_container_tag: "{{ matrix_bot_matrix_registration_bot_version }}-{{ matrix_bot_matrix_registration_bot_container_iteration }}" | |||||
| matrix_bot_matrix_registration_bot_container_image: "{{ matrix_bot_matrix_registration_bot_container_image_registry_prefix }}moanos/matrix-registration-bot:{{ matrix_bot_matrix_registration_bot_container_tag }}" | |||||
| matrix_bot_matrix_registration_bot_container_image_registry_prefix: "{{ 'localhost/' if matrix_bot_matrix_registration_bot_container_image_self_build else matrix_bot_matrix_registration_bot_container_image_registry_prefix_upstream }}" | |||||
| matrix_bot_matrix_registration_bot_container_image_registry_prefix_upstream: "{{ matrix_bot_matrix_registration_bot_container_image_registry_prefix_upstream_default }}" | |||||
| matrix_bot_matrix_registration_bot_container_image_registry_prefix_upstream_default: "docker.io/" | |||||
| matrix_bot_matrix_registration_bot_base_path: "{{ matrix_base_data_path }}/matrix-registration-bot" | |||||
| matrix_bot_matrix_registration_bot_config_path: "{{ matrix_bot_matrix_registration_bot_base_path }}/config" | |||||
| matrix_bot_matrix_registration_bot_data_path: "{{ matrix_bot_matrix_registration_bot_base_path }}/data" | |||||
| matrix_bot_matrix_registration_bot_bot_server: "{{ matrix_homeserver_url }}" | |||||
| # The bot's username. This user needs to be created manually beforehand. | |||||
| # Also see `matrix_bot_matrix_registration_bot_user_password`. | |||||
| matrix_bot_matrix_registration_bot_matrix_user_id_localpart: "bot.matrix-registration-bot" | |||||
| matrix_bot_matrix_registration_bot_matrix_user_id: '@{{ matrix_bot_matrix_registration_bot_matrix_user_id_localpart }}:{{ matrix_domain }}' | |||||
| # The bot's password (can also be used to login via a client like Element Web) | |||||
| matrix_bot_matrix_registration_bot_bot_password: '' | |||||
| # Optional bot command prefix | |||||
| matrix_bot_matrix_registration_bot_bot_prefix: "" | |||||
| # Homeserver base URL | |||||
| matrix_bot_matrix_registration_bot_api_base_url: "{{ matrix_homeserver_url }}" | |||||
| # Optional variable that only needs to be set if the bot account is not admin | |||||
| # Needs to be a valid access token of an admin account | |||||
| matrix_bot_matrix_registration_bot_api_token: '' | |||||
| matrix_bot_matrix_registration_bot_device_id: "matrix-docker-ansible-deploy" | |||||
| # Valid values: ERROR, INFO, DEBUG | |||||
| matrix_bot_matrix_registration_bot_logging_level: INFO | |||||
| matrix_bot_matrix_registration_bot_container_network: "" | |||||
| matrix_bot_matrix_registration_bot_container_additional_networks: "{{ matrix_bot_matrix_registration_bot_container_additional_networks_auto + matrix_bot_matrix_registration_bot_container_additional_networks_custom }}" | |||||
| matrix_bot_matrix_registration_bot_container_additional_networks_auto: [] | |||||
| matrix_bot_matrix_registration_bot_container_additional_networks_custom: [] | |||||
| # A list of extra arguments to pass to the container | |||||
| matrix_bot_matrix_registration_bot_container_extra_arguments: [] | |||||
| # List of systemd services that matrix-bot-matrix-registration-bot.service depends on | |||||
| matrix_bot_matrix_registration_bot_systemd_required_services_list: "{{ matrix_bot_matrix_registration_bot_systemd_required_services_list_default + matrix_bot_matrix_registration_bot_systemd_required_services_list_auto + matrix_bot_matrix_registration_bot_systemd_required_services_list_custom }}" | |||||
| matrix_bot_matrix_registration_bot_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" | |||||
| matrix_bot_matrix_registration_bot_systemd_required_services_list_auto: [] | |||||
| matrix_bot_matrix_registration_bot_systemd_required_services_list_custom: [] | |||||
| # List of systemd services that matrix-bot-matrix-registration-bot.service wants | |||||
| matrix_bot_matrix_registration_bot_systemd_wanted_services_list: [] | |||||
| # matrix_bot_matrix_registration_bot_restart_necessary controls whether the service | |||||
| # will be restarted (when true) or merely started (when false) by the | |||||
| # systemd service manager role (when conditional restart is enabled). | |||||
| # | |||||
| # This value is automatically computed during installation based on whether | |||||
| # any configuration files, the systemd service file, or the container image changed. | |||||
| # The default of `false` means "no restart needed" — appropriate when the role's | |||||
| # installation tasks haven't run (e.g., due to --tags skipping them). | |||||
| matrix_bot_matrix_registration_bot_restart_necessary: false | |||||
| @@ -1,16 +0,0 @@ | |||||
| # SPDX-FileCopyrightText: 2023 Julian-Samuel Gebühr | |||||
| # | |||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| --- | |||||
| - name: Delete cache files | |||||
| ansible.builtin.file: | |||||
| state: "{{ item }}" | |||||
| path: "{{ matrix_bot_matrix_registration_bot_data_path }}" | |||||
| mode: '0750' | |||||
| owner: "{{ matrix_user_name }}" | |||||
| group: "{{ matrix_group_name }}" | |||||
| with_items: | |||||
| - absent | |||||
| - directory | |||||
| @@ -1,31 +0,0 @@ | |||||
| # SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr | |||||
| # SPDX-FileCopyrightText: 2022 - 2023 Slavi Pantaleev | |||||
| # | |||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| --- | |||||
| - tags: | |||||
| - setup-all | |||||
| - setup-bot-matrix-registration-bot | |||||
| - install-all | |||||
| - install-bot-matrix-registration-bot | |||||
| block: | |||||
| - when: matrix_bot_matrix_registration_bot_enabled | bool | |||||
| ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" | |||||
| - when: matrix_bot_matrix_registration_bot_enabled | bool | |||||
| ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" | |||||
| - tags: | |||||
| - setup-all | |||||
| - setup-bot-matrix-registration-bot | |||||
| block: | |||||
| - when: not matrix_bot_matrix_registration_bot_enabled | bool | |||||
| ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" | |||||
| - tags: | |||||
| - bot-matrix-registration-bot-clean-cache | |||||
| block: | |||||
| - when: matrix_bot_matrix_registration_bot_enabled | bool | |||||
| ansible.builtin.include_tasks: "{{ role_path }}/tasks/clean_cache.yml" | |||||
| @@ -1,86 +0,0 @@ | |||||
| # SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr | |||||
| # SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev | |||||
| # SPDX-FileCopyrightText: 2022 Sebastian Gumprich | |||||
| # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara | |||||
| # SPDX-FileCopyrightText: 2024 David Mehren | |||||
| # | |||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| --- | |||||
| - name: Ensure matrix-registration-bot paths exist | |||||
| ansible.builtin.file: | |||||
| path: "{{ item.path }}" | |||||
| state: directory | |||||
| mode: '0750' | |||||
| owner: "{{ matrix_user_name }}" | |||||
| group: "{{ matrix_group_name }}" | |||||
| with_items: | |||||
| - {path: "{{ matrix_bot_matrix_registration_bot_config_path }}", when: true} | |||||
| - {path: "{{ matrix_bot_matrix_registration_bot_data_path }}", when: true} | |||||
| - {path: "{{ matrix_bot_matrix_registration_bot_container_src_files_path }}", when: "{{ matrix_bot_matrix_registration_bot_container_image_self_build }}"} | |||||
| when: "item.when | bool" | |||||
| - name: Ensure matrix-registration-bot configuration file created | |||||
| ansible.builtin.template: | |||||
| src: "{{ role_path }}/templates/config.yaml.j2" | |||||
| dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/config.yaml" | |||||
| owner: "{{ matrix_user_name }}" | |||||
| group: "{{ matrix_group_name }}" | |||||
| mode: '0640' | |||||
| register: matrix_bot_matrix_registration_bot_config_result | |||||
| - name: Ensure matrix-registration-bot image is pulled | |||||
| community.docker.docker_image_pull: | |||||
| name: "{{ matrix_bot_matrix_registration_bot_container_image }}" | |||||
| pull: always | |||||
| when: "not matrix_bot_matrix_registration_bot_container_image_self_build | bool" | |||||
| register: matrix_bot_matrix_registration_bot_container_image_pull_result | |||||
| retries: "{{ devture_playbook_help_container_retries_count }}" | |||||
| delay: "{{ devture_playbook_help_container_retries_delay }}" | |||||
| until: matrix_bot_matrix_registration_bot_container_image_pull_result is not failed | |||||
| - when: matrix_bot_matrix_registration_bot_container_image_self_build | bool | |||||
| block: | |||||
| - name: Ensure matrix-registration-bot repository is present on self-build | |||||
| ansible.builtin.git: | |||||
| repo: "{{ matrix_bot_matrix_registration_bot_container_repo }}" | |||||
| version: "{{ matrix_bot_matrix_registration_bot_container_repo_version }}" | |||||
| dest: "{{ matrix_bot_matrix_registration_bot_container_src_files_path }}" | |||||
| force: "yes" | |||||
| become: true | |||||
| become_user: "{{ matrix_user_name }}" | |||||
| register: matrix_bot_matrix_registration_bot_git_pull_results | |||||
| - name: Ensure matrix-registration-bot image is built | |||||
| community.docker.docker_image_build: | |||||
| name: "{{ matrix_bot_matrix_registration_bot_container_image }}" | |||||
| dockerfile: Dockerfile | |||||
| path: "{{ matrix_bot_matrix_registration_bot_container_src_files_path }}" | |||||
| pull: true | |||||
| rebuild: "{{ 'always' if matrix_bot_matrix_registration_bot_git_pull_results.changed | bool else 'never' }}" | |||||
| register: matrix_bot_matrix_registration_bot_container_image_build_result | |||||
| - name: Ensure matrix-registration-bot container network is created | |||||
| community.general.docker_network: | |||||
| enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" | |||||
| name: "{{ matrix_bot_matrix_registration_bot_container_network }}" | |||||
| driver: bridge | |||||
| driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" | |||||
| - name: Ensure matrix-bot-matrix-registration-bot.service installed | |||||
| ansible.builtin.template: | |||||
| src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2" | |||||
| dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-matrix-registration-bot.service" | |||||
| mode: '0644' | |||||
| register: matrix_bot_matrix_registration_bot_systemd_service_result | |||||
| - name: Determine whether matrix-registration-bot needs a restart | |||||
| ansible.builtin.set_fact: | |||||
| matrix_bot_matrix_registration_bot_restart_necessary: >- | |||||
| {{ | |||||
| matrix_bot_matrix_registration_bot_config_result.changed | default(false) | |||||
| or matrix_bot_matrix_registration_bot_systemd_service_result.changed | default(false) | |||||
| or matrix_bot_matrix_registration_bot_container_image_pull_result.changed | default(false) | |||||
| or matrix_bot_matrix_registration_bot_container_image_build_result.changed | default(false) | |||||
| }} | |||||
| @@ -1,31 +0,0 @@ | |||||
| # SPDX-FileCopyrightText: 2022 Julian-Samuel Gebühr | |||||
| # SPDX-FileCopyrightText: 2022 Sebastian Gumprich | |||||
| # SPDX-FileCopyrightText: 2022 Slavi Pantaleev | |||||
| # | |||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| --- | |||||
| - name: Check existence of matrix-matrix-registration-bot service | |||||
| ansible.builtin.stat: | |||||
| path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-matrix-registration-bot.service" | |||||
| register: matrix_bot_matrix_registration_bot_service_stat | |||||
| - when: matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool | |||||
| block: | |||||
| - name: Ensure matrix-matrix-registration-bot is stopped | |||||
| ansible.builtin.service: | |||||
| name: matrix-bot-matrix-registration-bot | |||||
| state: stopped | |||||
| enabled: false | |||||
| daemon_reload: true | |||||
| - name: Ensure matrix-bot-matrix-registration-bot.service doesn't exist | |||||
| ansible.builtin.file: | |||||
| path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-matrix-registration-bot.service" | |||||
| state: absent | |||||
| - name: Ensure Matrix matrix-registration-bot paths don't exist | |||||
| ansible.builtin.file: | |||||
| path: "{{ matrix_bot_matrix_registration_bot_base_path }}" | |||||
| state: absent | |||||
| @@ -1,37 +0,0 @@ | |||||
| # SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr | |||||
| # SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev | |||||
| # SPDX-FileCopyrightText: 2025 Suguru Hirahara | |||||
| # | |||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| --- | |||||
| - name: (Deprecation) Catch and report renamed settings | |||||
| ansible.builtin.fail: | |||||
| msg: >- | |||||
| Your configuration contains a variable, which now has a different name. | |||||
| Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml). | |||||
| when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0" | |||||
| with_items: | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_bot_access_token', 'new': '<removed>'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_matrix_homeserver_url', 'new': 'matrix_bot_matrix_registration_bot_api_base_url'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_image', 'new': 'matrix_bot_matrix_registration_bot_container_image'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_image_force_pull', 'new': '<removed> (the new community.docker.docker_image_pull module handles this natively)'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_container_image_force_pull', 'new': '<removed> (the new community.docker.docker_image_pull module handles this natively)'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_image_registry_prefix', 'new': 'matrix_bot_matrix_registration_bot_container_image_registry_prefix'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_image_registry_prefix_upstream', 'new': 'matrix_bot_matrix_registration_bot_container_image_registry_prefix_upstream'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_image_registry_prefix_upstream_default', 'new': 'matrix_bot_matrix_registration_bot_container_image_registry_prefix_upstream_default'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_iteration', 'new': 'matrix_bot_matrix_registration_bot_container_iteration'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_repo', 'new': 'matrix_bot_matrix_registration_bot_container_repo'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_repo_version', 'new': 'matrix_bot_matrix_registration_bot_container_repo_version'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_src_files_path', 'new': 'matrix_bot_matrix_registration_bot_container_src_files_path'} | |||||
| - {'old': 'matrix_bot_matrix_registration_bot_docker_tag', 'new': 'matrix_bot_matrix_registration_bot_container_tag'} | |||||
| - name: Fail if required settings not defined | |||||
| ansible.builtin.fail: | |||||
| msg: >- | |||||
| You need to define a required configuration setting (`{{ item }}`). | |||||
| when: "lookup('vars', item, default='') == ''" | |||||
| with_items: | |||||
| - "matrix_bot_matrix_registration_bot_bot_password" | |||||
| - "matrix_bot_matrix_registration_bot_api_base_url" | |||||
| @@ -1,24 +0,0 @@ | |||||
| {# | |||||
| SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr | |||||
| SPDX-FileCopyrightText: 2022 Slavi Pantaleev | |||||
| SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara | |||||
| SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| #} | |||||
| bot: | |||||
| server: {{ matrix_bot_matrix_registration_bot_bot_server|to_json }} | |||||
| username: {{ matrix_bot_matrix_registration_bot_matrix_user_id_localpart|to_json }} | |||||
| password: {{ matrix_bot_matrix_registration_bot_bot_password|to_json }} | |||||
| prefix: {{ matrix_bot_matrix_registration_bot_bot_prefix|to_json }} | |||||
| api: | |||||
| # API endpoint of the registration tokens | |||||
| base_url: {{ matrix_bot_matrix_registration_bot_api_base_url|to_json }} | |||||
| {% if matrix_bot_matrix_registration_bot_api_token | length > 0 %} | |||||
| # Access token of an administrator on the server | |||||
| token: {{ matrix_bot_matrix_registration_bot_api_token|to_json }} | |||||
| {% endif %} | |||||
| logging: | |||||
| level: {{ matrix_bot_matrix_registration_bot_logging_level|to_json }} | |||||
| @@ -1,45 +0,0 @@ | |||||
| #jinja2: lstrip_blocks: True | |||||
| [Unit] | |||||
| Description=Matrix registration bot | |||||
| {% for service in matrix_bot_matrix_registration_bot_systemd_required_services_list %} | |||||
| Requires={{ service }} | |||||
| After={{ service }} | |||||
| {% endfor %} | |||||
| {% for service in matrix_bot_matrix_registration_bot_systemd_wanted_services_list %} | |||||
| Wants={{ service }} | |||||
| {% endfor %} | |||||
| DefaultDependencies=no | |||||
| [Service] | |||||
| Type=simple | |||||
| 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 -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-bot-matrix-registration-bot 2>/dev/null || true' | |||||
| ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-matrix-registration-bot 2>/dev/null || true' | |||||
| ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ | |||||
| --rm \ | |||||
| --name=matrix-bot-matrix-registration-bot \ | |||||
| --log-driver=none \ | |||||
| --cap-drop=ALL \ | |||||
| -e "CONFIG_PATH=/config/config.yaml" \ | |||||
| --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ | |||||
| --read-only \ | |||||
| --mount type=bind,src={{ matrix_bot_matrix_registration_bot_config_path }},dst=/config,ro \ | |||||
| --mount type=bind,src={{ matrix_bot_matrix_registration_bot_data_path }},dst=/data \ | |||||
| --network={{ matrix_bot_matrix_registration_bot_container_network }} \ | |||||
| {{ matrix_bot_matrix_registration_bot_container_image }} | |||||
| {% for network in matrix_bot_matrix_registration_bot_container_additional_networks %} | |||||
| ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-bot-matrix-registration-bot | |||||
| {% endfor %} | |||||
| ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-bot-matrix-registration-bot | |||||
| ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-bot-matrix-registration-bot 2>/dev/null || true' | |||||
| ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-matrix-registration-bot 2>/dev/null || true' | |||||
| Restart=always | |||||
| RestartSec=30 | |||||
| SyslogIdentifier=matrix-bot-matrix-registration-bot | |||||
| [Install] | |||||
| WantedBy=multi-user.target | |||||
| @@ -1,6 +0,0 @@ | |||||
| SPDX-FileCopyrightText: 2022 - 2025 Slavi Pantaleev | |||||
| SPDX-FileCopyrightText: 2022 Erick Wibben | |||||
| SPDX-FileCopyrightText: 2022 Julian-Samuel Gebühr | |||||
| SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara | |||||
| SPDX-License-Identifier: AGPL-3.0-or-later | |||||