From 93d4f8d4258c886803664074eed6faafdff96a31 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 23 Nov 2022 10:14:28 +0200 Subject: [PATCH] Replace matrix-common-after systemd service management with com.devture.ansible.role.systemd_service_manager --- group_vars/matrix_servers | 250 ++++++++++-------- playbooks/matrix.yml | 3 + requirements.yml | 3 + roles/custom/matrix-base/defaults/main.yml | 21 -- .../matrix-common-after/defaults/main.yml | 17 -- .../custom/matrix-common-after/tasks/main.yml | 10 - .../matrix-common-after/tasks/start.yml | 48 ---- .../custom/matrix-common-after/tasks/stop.yml | 7 - .../tasks/init_additional_jvb.yml | 2 +- .../tasks/synapse/workers/setup_install.yml | 2 +- .../synapse/workers/util/inject_worker.yml | 2 +- .../tasks/validate_config.yml | 4 + 12 files changed, 150 insertions(+), 219 deletions(-) delete mode 100644 roles/custom/matrix-common-after/defaults/main.yml delete mode 100644 roles/custom/matrix-common-after/tasks/start.yml delete mode 100644 roles/custom/matrix-common-after/tasks/stop.yml diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index ccd7d5d9..74515ab2 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -19,6 +19,141 @@ # Also see `devture_docker_sdk_for_python_installation_enabled`. matrix_playbook_docker_installation_enabled: true +######################################################################## +# # +# /Playbook # +# # +######################################################################## + +######################################################################## +# # +# base # +# # +######################################################################## + +matrix_homeserver_app_service_config_files_auto: | + {{ + (['--mount type=bind,src=' + matrix_appservice_discord_config_path + '/registration.yaml,dst=/matrix-appservice-discord-registration.yaml,ro'] if matrix_appservice_discord_enabled else []) + + + (['--mount type=bind,src=' + matrix_appservice_irc_config_path + '/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro'] if matrix_appservice_irc_enabled else []) + + + (['--mount type=bind,src=' + matrix_appservice_kakaotalk_config_path + '/registration.yaml,dst=/matrix-appservice-kakaotalk-registration.yaml,ro'] if matrix_appservice_kakaotalk_enabled else []) + + + (['--mount type=bind,src=' + matrix_appservice_slack_config_path + '/slack-registration.yaml,dst=/matrix-appservice-slack-registration.yaml,ro'] if matrix_appservice_slack_enabled else []) + + + (['--mount type=bind,src=' + matrix_appservice_webhooks_config_path + '/webhooks-registration.yaml,dst=/matrix-appservice-webhooks-registration.yaml,ro'] if matrix_appservice_webhooks_enabled else []) + + + (['--mount type=bind,src=' + matrix_beeper_linkedin_config_path + '/registration.yaml,dst=/matrix-beeper-linkedin-registration.yaml,ro'] if matrix_beeper_linkedin_enabled else []) + + + (['--mount type=bind,src=' + matrix_go_skype_bridge_config_path + '/registration.yaml,dst=/matrix-go-skype-bridge-registration.yaml,ro'] if matrix_go_skype_bridge_enabled else []) + + + (['--mount type=bind,src=' + matrix_heisenbridge_base_path + '/registration.yaml,dst=/heisenbridge-registration.yaml,ro'] if matrix_heisenbridge_enabled else []) + + + (['--mount type=bind,src=' + matrix_hookshot_base_path + '/registration.yml,dst=/hookshot-registration.yml,ro'] if matrix_hookshot_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_discord_config_path + '/registration.yaml,dst=/matrix-mautrix-discord-registration.yaml,ro'] if matrix_mautrix_discord_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_facebook_config_path + '/registration.yaml,dst=/matrix-mautrix-facebook-registration.yaml,ro'] if matrix_mautrix_facebook_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_googlechat_config_path + '/registration.yaml,dst=/matrix-mautrix-googlechat-registration.yaml,ro'] if matrix_mautrix_googlechat_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_hangouts_config_path + '/registration.yaml,dst=/matrix-mautrix-hangouts-registration.yaml,ro'] if matrix_mautrix_hangouts_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_instagram_config_path + '/registration.yaml,dst=/matrix-mautrix-instagram-registration.yaml,ro'] if matrix_mautrix_instagram_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_signal_config_path + '/registration.yaml,dst=/matrix-mautrix-signal-registration.yaml,ro'] if matrix_mautrix_signal_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_telegram_config_path + '/registration.yaml,dst=/matrix-mautrix-telegram-registration.yaml,ro'] if matrix_mautrix_telegram_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_twitter_config_path + '/registration.yaml,dst=/matrix-mautrix-twitter-registration.yaml,ro'] if matrix_mautrix_twitter_enabled else []) + + + (['--mount type=bind,src=' + matrix_mautrix_whatsapp_config_path + '/registration.yaml,dst=/matrix-mautrix-whatsapp-registration.yaml,ro'] if matrix_mautrix_whatsapp_enabled else []) + + + (['--mount type=bind,src=' + matrix_mx_puppet_discord_config_path + '/registration.yaml,dst=/matrix-mx-puppet-discord-registration.yaml,ro'] if matrix_mx_puppet_discord_enabled else []) + + + (['--mount type=bind,src=' + matrix_mx_puppet_groupme_config_path + '/registration.yaml,dst=/matrix-mx-puppet-groupme-registration.yaml,ro'] if matrix_mx_puppet_groupme_enabled else []) + + + (['--mount type=bind,src=' + matrix_mx_puppet_instagram_config_path + '/registration.yaml,dst=/matrix-mx-puppet-instagram-registration.yaml,ro'] if matrix_mx_puppet_instagram_enabled else []) + + + (['--mount type=bind,src=' + matrix_mx_puppet_slack_config_path + '/registration.yaml,dst=/matrix-mx-puppet-slack-registration.yaml,ro'] if matrix_mx_puppet_slack_enabled else []) + + + (['--mount type=bind,src=' + matrix_mx_puppet_steam_config_path + '/registration.yaml,dst=/matrix-mx-puppet-steam-registration.yaml,ro'] if matrix_mx_puppet_steam_enabled else []) + + + (['--mount type=bind,src=' + matrix_mx_puppet_twitter_config_path + '/registration.yaml,dst=/matrix-mx-puppet-twitter-registration.yaml,ro'] if matrix_mx_puppet_twitter_enabled else []) + + + (['--mount type=bind,src=' + matrix_sms_bridge_config_path + '/registration.yaml,dst=/matrix-sms-bridge-registration.yaml,ro'] if matrix_sms_bridge_enabled else []) + + + (['--mount type=bind,src=' + matrix_cactus_comments_app_service_config_file + ',dst=/matrix-cactus-comments.yaml,ro'] if matrix_cactus_comments_enabled else []) + }} + +matrix_homeserver_additional_config_files_auto: | + {{ + (['/matrix-appservice-discord-registration.yaml'] if matrix_appservice_discord_enabled else []) + + + (['/matrix-appservice-irc-registration.yaml'] if matrix_appservice_irc_enabled else []) + + + (['/matrix-appservice-kakaotalk-registration.yaml'] if matrix_appservice_kakaotalk_enabled else []) + + + (['/matrix-appservice-slack-registration.yaml'] if matrix_appservice_slack_enabled else []) + + + (['/matrix-appservice-webhooks-registration.yaml'] if matrix_appservice_webhooks_enabled else []) + + + (['/matrix-beeper-linkedin-registration.yaml'] if matrix_beeper_linkedin_enabled else []) + + + (['/matrix-go-skype-bridge-registration.yaml'] if matrix_go_skype_bridge_enabled else []) + + + (['/heisenbridge-registration.yaml'] if matrix_heisenbridge_enabled else []) + + + (['/hookshot-registration.yml'] if matrix_hookshot_enabled else []) + + + (['/matrix-mautrix-discord-registration.yaml'] if matrix_mautrix_discord_enabled else []) + + + (['/matrix-mautrix-facebook-registration.yaml'] if matrix_mautrix_facebook_enabled else []) + + + (['/matrix-mautrix-googlechat-registration.yaml'] if matrix_mautrix_googlechat_enabled else []) + + + (['/matrix-mautrix-hangouts-registration.yaml'] if matrix_mautrix_hangouts_enabled else []) + + + (['/matrix-mautrix-instagram-registration.yaml'] if matrix_mautrix_instagram_enabled else []) + + + (['/matrix-mautrix-signal-registration.yaml'] if matrix_mautrix_signal_enabled else []) + + + (['/matrix-mautrix-telegram-registration.yaml'] if matrix_mautrix_telegram_enabled else []) + + + (['/matrix-mautrix-twitter-registration.yaml'] if matrix_mautrix_twitter_enabled else []) + + + (['/matrix-mautrix-whatsapp-registration.yaml'] if matrix_mautrix_whatsapp_enabled else []) + + + (['/matrix-mx-puppet-discord-registration.yaml'] if matrix_mx_puppet_discord_enabled else []) + + + (['/matrix-mx-puppet-groupme-registration.yaml'] if matrix_mx_puppet_groupme_enabled else []) + + + (['/matrix-mx-puppet-instagram-registration.yaml'] if matrix_mx_puppet_instagram_enabled else []) + + + (['/matrix-mx-puppet-slack-registration.yaml'] if matrix_mx_puppet_slack_enabled else []) + + + (['/matrix-mx-puppet-steam-registration.yaml'] if matrix_mx_puppet_steam_enabled else []) + + + (['/matrix-mx-puppet-twitter-registration.yaml'] if matrix_mx_puppet_twitter_enabled else []) + + + (['/matrix-sms-bridge-registration.yaml'] if matrix_sms_bridge_enabled else []) + + + (['/matrix-cactus-comments.yaml'] if matrix_cactus_comments_enabled else []) + }} + +######################################################################## +# # +# /base # +# # +######################################################################## + + +######################################################################## +# # +# com.devture.ansible.role.systemd_service_manager # +# # +######################################################################## + # This list is not exhaustive and final. # Synapse workers are still injected into the list at runtime. # Additional JVB workers (playbooks/jitsi_jvb.yml -- roles/custom/matrix-jitsi/tasks/init_additional_jvb.yml) override this variable at runtime as well. @@ -32,7 +167,7 @@ matrix_playbook_docker_installation_enabled: true # - so that, when the reverse-proxy is up (Matrix is up), all bots and bridges can be interacted with # - monitoring services (Prometheus, Grafana, ..) get a level of 4000 - they can start later than all-of-Matrix # - services which aren't time-sensitive (various crons and timers) get a level of 5000 - they can start later than all-of-Matrix -matrix_systemd_services_list_auto: | +devture_systemd_service_manager_services_list_auto: | {{ ([{'name': 'matrix-backup-borg.timer', 'priority': 5000}] if matrix_backup_borg_enabled else []) + @@ -177,124 +312,13 @@ matrix_systemd_services_list_auto: | ([{'name': 'matrix-synapse-reverse-proxy-companion.service', 'priority': 1500}] if matrix_synapse_reverse_proxy_companion_enabled else []) }} -matrix_homeserver_app_service_config_files_auto: | - {{ - (['--mount type=bind,src=' + matrix_appservice_discord_config_path + '/registration.yaml,dst=/matrix-appservice-discord-registration.yaml,ro'] if matrix_appservice_discord_enabled else []) - + - (['--mount type=bind,src=' + matrix_appservice_irc_config_path + '/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro'] if matrix_appservice_irc_enabled else []) - + - (['--mount type=bind,src=' + matrix_appservice_kakaotalk_config_path + '/registration.yaml,dst=/matrix-appservice-kakaotalk-registration.yaml,ro'] if matrix_appservice_kakaotalk_enabled else []) - + - (['--mount type=bind,src=' + matrix_appservice_slack_config_path + '/slack-registration.yaml,dst=/matrix-appservice-slack-registration.yaml,ro'] if matrix_appservice_slack_enabled else []) - + - (['--mount type=bind,src=' + matrix_appservice_webhooks_config_path + '/webhooks-registration.yaml,dst=/matrix-appservice-webhooks-registration.yaml,ro'] if matrix_appservice_webhooks_enabled else []) - + - (['--mount type=bind,src=' + matrix_beeper_linkedin_config_path + '/registration.yaml,dst=/matrix-beeper-linkedin-registration.yaml,ro'] if matrix_beeper_linkedin_enabled else []) - + - (['--mount type=bind,src=' + matrix_go_skype_bridge_config_path + '/registration.yaml,dst=/matrix-go-skype-bridge-registration.yaml,ro'] if matrix_go_skype_bridge_enabled else []) - + - (['--mount type=bind,src=' + matrix_heisenbridge_base_path + '/registration.yaml,dst=/heisenbridge-registration.yaml,ro'] if matrix_heisenbridge_enabled else []) - + - (['--mount type=bind,src=' + matrix_hookshot_base_path + '/registration.yml,dst=/hookshot-registration.yml,ro'] if matrix_hookshot_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_discord_config_path + '/registration.yaml,dst=/matrix-mautrix-discord-registration.yaml,ro'] if matrix_mautrix_discord_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_facebook_config_path + '/registration.yaml,dst=/matrix-mautrix-facebook-registration.yaml,ro'] if matrix_mautrix_facebook_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_googlechat_config_path + '/registration.yaml,dst=/matrix-mautrix-googlechat-registration.yaml,ro'] if matrix_mautrix_googlechat_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_hangouts_config_path + '/registration.yaml,dst=/matrix-mautrix-hangouts-registration.yaml,ro'] if matrix_mautrix_hangouts_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_instagram_config_path + '/registration.yaml,dst=/matrix-mautrix-instagram-registration.yaml,ro'] if matrix_mautrix_instagram_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_signal_config_path + '/registration.yaml,dst=/matrix-mautrix-signal-registration.yaml,ro'] if matrix_mautrix_signal_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_telegram_config_path + '/registration.yaml,dst=/matrix-mautrix-telegram-registration.yaml,ro'] if matrix_mautrix_telegram_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_twitter_config_path + '/registration.yaml,dst=/matrix-mautrix-twitter-registration.yaml,ro'] if matrix_mautrix_twitter_enabled else []) - + - (['--mount type=bind,src=' + matrix_mautrix_whatsapp_config_path + '/registration.yaml,dst=/matrix-mautrix-whatsapp-registration.yaml,ro'] if matrix_mautrix_whatsapp_enabled else []) - + - (['--mount type=bind,src=' + matrix_mx_puppet_discord_config_path + '/registration.yaml,dst=/matrix-mx-puppet-discord-registration.yaml,ro'] if matrix_mx_puppet_discord_enabled else []) - + - (['--mount type=bind,src=' + matrix_mx_puppet_groupme_config_path + '/registration.yaml,dst=/matrix-mx-puppet-groupme-registration.yaml,ro'] if matrix_mx_puppet_groupme_enabled else []) - + - (['--mount type=bind,src=' + matrix_mx_puppet_instagram_config_path + '/registration.yaml,dst=/matrix-mx-puppet-instagram-registration.yaml,ro'] if matrix_mx_puppet_instagram_enabled else []) - + - (['--mount type=bind,src=' + matrix_mx_puppet_slack_config_path + '/registration.yaml,dst=/matrix-mx-puppet-slack-registration.yaml,ro'] if matrix_mx_puppet_slack_enabled else []) - + - (['--mount type=bind,src=' + matrix_mx_puppet_steam_config_path + '/registration.yaml,dst=/matrix-mx-puppet-steam-registration.yaml,ro'] if matrix_mx_puppet_steam_enabled else []) - + - (['--mount type=bind,src=' + matrix_mx_puppet_twitter_config_path + '/registration.yaml,dst=/matrix-mx-puppet-twitter-registration.yaml,ro'] if matrix_mx_puppet_twitter_enabled else []) - + - (['--mount type=bind,src=' + matrix_sms_bridge_config_path + '/registration.yaml,dst=/matrix-sms-bridge-registration.yaml,ro'] if matrix_sms_bridge_enabled else []) - + - (['--mount type=bind,src=' + matrix_cactus_comments_app_service_config_file + ',dst=/matrix-cactus-comments.yaml,ro'] if matrix_cactus_comments_enabled else []) - }} - -matrix_homeserver_additional_config_files_auto: | - {{ - (['/matrix-appservice-discord-registration.yaml'] if matrix_appservice_discord_enabled else []) - + - (['/matrix-appservice-irc-registration.yaml'] if matrix_appservice_irc_enabled else []) - + - (['/matrix-appservice-kakaotalk-registration.yaml'] if matrix_appservice_kakaotalk_enabled else []) - + - (['/matrix-appservice-slack-registration.yaml'] if matrix_appservice_slack_enabled else []) - + - (['/matrix-appservice-webhooks-registration.yaml'] if matrix_appservice_webhooks_enabled else []) - + - (['/matrix-beeper-linkedin-registration.yaml'] if matrix_beeper_linkedin_enabled else []) - + - (['/matrix-go-skype-bridge-registration.yaml'] if matrix_go_skype_bridge_enabled else []) - + - (['/heisenbridge-registration.yaml'] if matrix_heisenbridge_enabled else []) - + - (['/hookshot-registration.yml'] if matrix_hookshot_enabled else []) - + - (['/matrix-mautrix-discord-registration.yaml'] if matrix_mautrix_discord_enabled else []) - + - (['/matrix-mautrix-facebook-registration.yaml'] if matrix_mautrix_facebook_enabled else []) - + - (['/matrix-mautrix-googlechat-registration.yaml'] if matrix_mautrix_googlechat_enabled else []) - + - (['/matrix-mautrix-hangouts-registration.yaml'] if matrix_mautrix_hangouts_enabled else []) - + - (['/matrix-mautrix-instagram-registration.yaml'] if matrix_mautrix_instagram_enabled else []) - + - (['/matrix-mautrix-signal-registration.yaml'] if matrix_mautrix_signal_enabled else []) - + - (['/matrix-mautrix-telegram-registration.yaml'] if matrix_mautrix_telegram_enabled else []) - + - (['/matrix-mautrix-twitter-registration.yaml'] if matrix_mautrix_twitter_enabled else []) - + - (['/matrix-mautrix-whatsapp-registration.yaml'] if matrix_mautrix_whatsapp_enabled else []) - + - (['/matrix-mx-puppet-discord-registration.yaml'] if matrix_mx_puppet_discord_enabled else []) - + - (['/matrix-mx-puppet-groupme-registration.yaml'] if matrix_mx_puppet_groupme_enabled else []) - + - (['/matrix-mx-puppet-instagram-registration.yaml'] if matrix_mx_puppet_instagram_enabled else []) - + - (['/matrix-mx-puppet-slack-registration.yaml'] if matrix_mx_puppet_slack_enabled else []) - + - (['/matrix-mx-puppet-steam-registration.yaml'] if matrix_mx_puppet_steam_enabled else []) - + - (['/matrix-mx-puppet-twitter-registration.yaml'] if matrix_mx_puppet_twitter_enabled else []) - + - (['/matrix-sms-bridge-registration.yaml'] if matrix_sms_bridge_enabled else []) - + - (['/matrix-cactus-comments.yaml'] if matrix_cactus_comments_enabled else []) - }} - ######################################################################## # # -# /Playbook # +# /com.devture.ansible.role.systemd_service_manager # # # ######################################################################## - ######################################################################## # # # com.devture.ansible.role.timesync # diff --git a/playbooks/matrix.yml b/playbooks/matrix.yml index 1ecfba32..8d2be5cb 100755 --- a/playbooks/matrix.yml +++ b/playbooks/matrix.yml @@ -100,6 +100,9 @@ - custom/matrix-user-creator - custom/matrix-common-after + - when: devture_systemd_service_manager_enabled | bool + role: galaxy/com.devture.ansible.role.systemd_service_manager + # This is pretty much last, because we want it to better serve as a "last known good configuration". # See: https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/2217#issuecomment-1301487601 - when: devture_playbook_state_preserver_enabled | bool diff --git a/requirements.yml b/requirements.yml index ed4b8fb1..e8b411a8 100644 --- a/requirements.yml +++ b/requirements.yml @@ -18,5 +18,8 @@ - src: git+https://github.com/devture/com.devture.ansible.role.playbook_state_preserver.git version: ff2fd42e1c1a9e28e3312bbd725395f9c2fc7f16 +- src: git+https://github.com/devture/com.devture.ansible.role.systemd_service_manager.git + version: 8b6a14d649f8b0e868c7073b34f5d2fda6bde9e0 + - src: git+https://github.com/devture/com.devture.ansible.role.playbook_runtime_messages.git version: f1c78d4e85e875129790c58335d0e44385683f6b diff --git a/roles/custom/matrix-base/defaults/main.yml b/roles/custom/matrix-base/defaults/main.yml index dfaeb69d..768bc6ec 100644 --- a/roles/custom/matrix-base/defaults/main.yml +++ b/roles/custom/matrix-base/defaults/main.yml @@ -253,27 +253,6 @@ matrix_well_known_matrix_server_enabled: true # See `matrix_homeserver_admin_contacts`, `matrix_homeserver_support_url`, etc. matrix_well_known_matrix_support_enabled: false -# matrix_systemd_services_list_auto contains a list of systemd services and their priorities. -# This list is managed by the playbook. You're not meant to override this variable. -# To add your own items to the list, use `matrix_systemd_services_list_additional` -matrix_systemd_services_list_auto: [] - -# matrix_systemd_services_list_additional contains your own list of systemd services and their priorities. -# -# Example: -# matrix_systemd_services_list_additional: -# - name: some-service.service -# priority: 1250 -# - name: another-service.service -# priority: 3500 -matrix_systemd_services_list_additional: [] - -# matrix_systemd_services_list contains a list of systemd services and their priorities. -matrix_systemd_services_list: "{{ matrix_systemd_services_list_auto + matrix_systemd_services_list_additional }}" - -# matrix_systemd_services_autostart_enabled controls whether systemd services should auto-start when the system reboots -matrix_systemd_services_autostart_enabled: true - matrix_homeserver_container_extra_arguments_auto: [] matrix_homeserver_app_service_config_files_auto: [] diff --git a/roles/custom/matrix-common-after/defaults/main.yml b/roles/custom/matrix-common-after/defaults/main.yml deleted file mode 100644 index 51c48c7d..00000000 --- a/roles/custom/matrix-common-after/defaults/main.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -# Specifies how long to wait between starting systemd services and checking if they're started. -# -# A too low value may lead to a failure, as services may not have enough time to start and potentially fail. -# -# A value higher than 30 seconds (or any multiple of that) may also not work well, because a failing systemd service -# auto-restarts after 30 seconds (`RestartSec=30` in systemd service files). -# Checking if a service is running right after it had potentially restarted in such a way will lead us to -# thinking it's running, while it's merely starting again (and likely to fail again, given that it already did once). -# -# All of the services we manage are also started sequentially, which in itself can take a long time. -# There may be a ~10 second (or even larger) interval between starting the first service and starting the last one. -# This makes it even harder to pick a correct value. Such a 10 second gap and a waiting time of 20 seconds will -# put us right at the "dangerous" 30-second mark. -# -# We can try to measure this gap and adjust our waiting time accordingly, but we currently don't. -matrix_common_after_systemd_service_start_wait_for_timeout_seconds: 15 diff --git a/roles/custom/matrix-common-after/tasks/main.yml b/roles/custom/matrix-common-after/tasks/main.yml index 2cffecb1..498c8390 100644 --- a/roles/custom/matrix-common-after/tasks/main.yml +++ b/roles/custom/matrix-common-after/tasks/main.yml @@ -1,15 +1,5 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/start.yml" - when: run_start | bool - tags: - - start - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/stop.yml" - when: run_stop | bool - tags: - - stop - - ansible.builtin.import_tasks: "{{ role_path }}/tasks/run_docker_prune.yml" tags: - run-docker-prune diff --git a/roles/custom/matrix-common-after/tasks/start.yml b/roles/custom/matrix-common-after/tasks/start.yml deleted file mode 100644 index 60f571bc..00000000 --- a/roles/custom/matrix-common-after/tasks/start.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- - -- name: Ensure systemd is reloaded - ansible.builtin.service: - daemon_reload: true - -- name: Ensure Matrix services are stopped - ansible.builtin.service: - name: "{{ item.name }}" - state: stopped - with_items: "{{ matrix_systemd_services_list | sort (attribute='priority,name', reverse=true) }}" - when: not ansible_check_mode - -- name: Ensure Matrix services are started - ansible.builtin.service: - name: "{{ item.name }}" - state: started - enabled: "{{ matrix_systemd_services_autostart_enabled }}" - with_items: "{{ matrix_systemd_services_list | sort (attribute='priority,name') }}" - when: not ansible_check_mode - -# If we check service state immediately, we may succeed, -# because it takes some time for the service to attempt to start and actually fail. -# -# Waiting too long (30s) may not work for a similar reason, -# as we may run into systemd's automatic restart logic retrying the service. -- name: Wait a bit, so that services can start (or fail) - ansible.builtin.wait_for: - timeout: "{{ matrix_common_after_systemd_service_start_wait_for_timeout_seconds }}" - delegate_to: 127.0.0.1 - become: false - -- block: - - name: Populate service facts - ansible.builtin.service_facts: - - - name: Fail if service isn't detected to be running - ansible.builtin.fail: - msg: >- - {{ item }} was not detected to be running. - It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.). - Try running `systemctl status {{ item }}` and `journalctl -fu {{ item }}` on the server to investigate. - If you're on a slow or overloaded server, it may be that services take a longer time to start and that this error is a false-positive. - You can consider raising the value of the `matrix_common_after_systemd_service_start_wait_for_timeout_seconds` variable. - See `roles/custom/matrix-common-after/defaults/main.yml` for more details about that. - with_items: "{{ matrix_systemd_services_list | map(attribute='name') }}" - when: - - "item.endswith('.service') and (ansible_facts.services[item] | default(none) is none or ansible_facts.services[item].state != 'running')" diff --git a/roles/custom/matrix-common-after/tasks/stop.yml b/roles/custom/matrix-common-after/tasks/stop.yml deleted file mode 100644 index 4fb19ebd..00000000 --- a/roles/custom/matrix-common-after/tasks/stop.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- name: Ensure Matrix services stopped - ansible.builtin.service: - name: "{{ item.name }}" - state: stopped - with_items: "{{ matrix_systemd_services_list | sort (attribute='priority,name', reverse=true) }}" diff --git a/roles/custom/matrix-jitsi/tasks/init_additional_jvb.yml b/roles/custom/matrix-jitsi/tasks/init_additional_jvb.yml index b3f83d94..f5a6e185 100644 --- a/roles/custom/matrix-jitsi/tasks/init_additional_jvb.yml +++ b/roles/custom/matrix-jitsi/tasks/init_additional_jvb.yml @@ -1,5 +1,5 @@ --- - ansible.builtin.set_fact: - matrix_systemd_services_list: "{{ [{'name': 'matrix-jitsi-jvb.service', 'priority': 1000}] }}" + devture_systemd_service_manager_services_list_auto: "{{ [{'name': 'matrix-jitsi-jvb.service', 'priority': 1000}] }}" when: matrix_jitsi_enabled | bool diff --git a/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml b/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml index ca80e454..0f2105ed 100644 --- a/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml +++ b/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml @@ -27,7 +27,7 @@ state: stopped enabled: false with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}" - when: "not ansible_check_mode and item.path | basename not in matrix_systemd_services_list | map(attribute='name')" + when: "not ansible_check_mode and item.path | basename not in devture_systemd_service_manager_services_list | map(attribute='name')" - name: Ensure unnecessary worker systemd services are cleaned ansible.builtin.file: diff --git a/roles/custom/matrix-synapse/tasks/synapse/workers/util/inject_worker.yml b/roles/custom/matrix-synapse/tasks/synapse/workers/util/inject_worker.yml index aebcbc89..27f499d6 100644 --- a/roles/custom/matrix-synapse/tasks/synapse/workers/util/inject_worker.yml +++ b/roles/custom/matrix-synapse/tasks/synapse/workers/util/inject_worker.yml @@ -53,7 +53,7 @@ when: "'replication_port' not in matrix_synapse_worker_details" - ansible.builtin.set_fact: - matrix_systemd_services_list_auto: "{{ matrix_systemd_services_list_auto + [{'name': (matrix_synapse_worker_details.name + '.service'), 'priority': 1100}] }}" + devture_systemd_service_manager_services_list_auto: "{{ devture_systemd_service_manager_services_list_auto + [{'name': (matrix_synapse_worker_details.name + '.service'), 'priority': 1100}] }}" - ansible.builtin.set_fact: matrix_synapse_webserving_workers_systemd_services_list: "{{ matrix_synapse_webserving_workers_systemd_services_list + [matrix_synapse_worker_details.name + '.service'] }}" diff --git a/roles/custom/matrix_playbook_migration/tasks/validate_config.yml b/roles/custom/matrix_playbook_migration/tasks/validate_config.yml index 93f977d1..49e31ebb 100644 --- a/roles/custom/matrix_playbook_migration/tasks/validate_config.yml +++ b/roles/custom/matrix_playbook_migration/tasks/validate_config.yml @@ -30,3 +30,7 @@ - {'old': 'matrix_docker_installation_enabled', 'new': 'matrix_playbook_docker_installation_enabled'} - {'old': 'matrix_docker_package_name', 'new': ''} + + - {'old': 'matrix_systemd_services_list', 'new': 'devture_systemd_service_manager_services_list_additional'} + - {'old': 'matrix_common_after_systemd_service_start_wait_for_timeout_seconds', 'new': 'devture_systemd_service_manager_up_verification_delay_seconds'} + - {'old': 'matrix_systemd_services_autostart_enabled', 'new': 'devture_systemd_service_manager_services_autostart_enabled'}