diff --git a/requirements.yml b/requirements.yml index 71b596cb8..0d77588a6 100644 --- a/requirements.yml +++ b/requirements.yml @@ -13,13 +13,13 @@ version: 327d2e17f5189ac2480d6012f58cf64a2b46efba - src: git+https://github.com/devture/com.devture.ansible.role.timesync.git - version: 461ace97fcf0e36c76747b36fcad8587d9b072f5 + version: 660f384f176a9ea3b5cc702bde39e7dc10bf6186 - 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: 96c31c43b6937428e3f5d12520f8a41a1b5465d7 + version: 6ccb88ac5fc27e1e70afcd48278ade4b564a9096 - src: git+https://github.com/devture/com.devture.ansible.role.playbook_runtime_messages.git - version: f1c78d4e85e875129790c58335d0e44385683f6b + version: 9b4b088c62b528b73a9a7c93d3109b091dd42ec6 diff --git a/roles/custom/matrix-aux/tasks/main.yml b/roles/custom/matrix-aux/tasks/main.yml index df7c77d0c..63ef998a8 100644 --- a/roles/custom/matrix-aux/tasks/main.yml +++ b/roles/custom/matrix-aux/tasks/main.yml @@ -1,7 +1,7 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml" - when: run_stop | bool +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup.yml" tags: - setup-all - setup-aux-files diff --git a/roles/custom/matrix-backup-borg/tasks/main.yml b/roles/custom/matrix-backup-borg/tasks/main.yml index e8c020a47..0c8a9b7e4 100644 --- a/roles/custom/matrix-backup-borg/tasks/main.yml +++ b/roles/custom/matrix-backup-borg/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_backup_borg_enabled | bool" - tags: - - setup-all - - setup-backup-borg +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + when: "run_setup | bool and matrix_backup_borg_enabled | bool" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_backup_borg_enabled | bool" - tags: - - setup-all - - setup-backup-borg + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + when: "run_setup | bool and matrix_backup_borg_enabled | bool" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_backup_borg_enabled | bool" + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" + when: "run_setup | bool and not matrix_backup_borg_enabled | bool" tags: - setup-all - setup-backup-borg diff --git a/roles/custom/matrix-bot-buscarron/tasks/main.yml b/roles/custom/matrix-bot-buscarron/tasks/main.yml index 0d575393f..b12579541 100644 --- a/roles/custom/matrix-bot-buscarron/tasks/main.yml +++ b/roles/custom/matrix-bot-buscarron/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_buscarron_enabled | bool" - tags: - - setup-all - - setup-bot-buscarron +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + when: "run_setup | bool and matrix_bot_buscarron_enabled | bool" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_buscarron_enabled | bool" - tags: - - setup-all - - setup-bot-buscarron + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + when: "run_setup | bool and matrix_bot_buscarron_enabled | bool" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_buscarron_enabled | bool" + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" + when: "run_setup | bool and not matrix_bot_buscarron_enabled | bool" tags: - setup-all - setup-bot-buscarron diff --git a/roles/custom/matrix-bot-go-neb/tasks/main.yml b/roles/custom/matrix-bot-go-neb/tasks/main.yml index 4fc22e591..1955eee83 100644 --- a/roles/custom/matrix-bot-go-neb/tasks/main.yml +++ b/roles/custom/matrix-bot-go-neb/tasks/main.yml @@ -1,19 +1,17 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_go_neb_enabled | bool" +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + when: "run_setup | bool and matrix_bot_go_neb_enabled | bool" + + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + when: "run_setup | bool and matrix_bot_go_neb_enabled | bool" + + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" + when: "run_setup | bool and not matrix_bot_go_neb_enabled | bool" tags: - setup-all - setup-bot-go-neb -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_go_neb_enabled | bool" - tags: - - setup-all - - setup-bot-go-neb -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_go_neb_enabled | bool" - tags: - - setup-all - - setup-bot-go-neb + diff --git a/roles/custom/matrix-bot-honoroit/tasks/main.yml b/roles/custom/matrix-bot-honoroit/tasks/main.yml index 09fab3272..fde2b6e3b 100644 --- a/roles/custom/matrix-bot-honoroit/tasks/main.yml +++ b/roles/custom/matrix-bot-honoroit/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_honoroit_enabled | bool" - tags: - - setup-all - - setup-bot-honoroit +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + when: "run_setup | bool and matrix_bot_honoroit_enabled | bool" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_honoroit_enabled | bool" - tags: - - setup-all - - setup-bot-honoroit + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + when: "run_setup | bool and matrix_bot_honoroit_enabled | bool" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_honoroit_enabled | bool" + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" + when: "run_setup | bool and not matrix_bot_honoroit_enabled | bool" tags: - setup-all - setup-bot-honoroit diff --git a/roles/custom/matrix-bot-matrix-registration-bot/tasks/main.yml b/roles/custom/matrix-bot-matrix-registration-bot/tasks/main.yml index 5f44faac5..d0c7a1578 100644 --- a/roles/custom/matrix-bot-matrix-registration-bot/tasks/main.yml +++ b/roles/custom/matrix-bot-matrix-registration-bot/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_matrix_registration_bot_enabled | bool" - tags: - - setup-all - - setup-bot-matrix-registration-bot +- block: + - when: matrix_bot_matrix_registration_bot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_matrix_registration_bot_enabled | bool" - tags: - - setup-all - - setup-bot-matrix-registration-bot + - when: matrix_bot_matrix_registration_bot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_matrix_registration_bot_enabled | bool" + - when: not matrix_bot_matrix_registration_bot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-bot-matrix-registration-bot diff --git a/roles/custom/matrix-bot-matrix-reminder-bot/tasks/main.yml b/roles/custom/matrix-bot-matrix-reminder-bot/tasks/main.yml index 8340ef67e..091b0cc18 100644 --- a/roles/custom/matrix-bot-matrix-reminder-bot/tasks/main.yml +++ b/roles/custom/matrix-bot-matrix-reminder-bot/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_matrix_reminder_bot_enabled | bool" - tags: - - setup-all - - setup-bot-matrix-reminder-bot +- block: + - when: matrix_bot_matrix_reminder_bot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_matrix_reminder_bot_enabled | bool" - tags: - - setup-all - - setup-bot-matrix-reminder-bot + - when: matrix_bot_matrix_reminder_bot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_matrix_reminder_bot_enabled | bool" + - when: not matrix_bot_matrix_reminder_bot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-bot-matrix-reminder-bot diff --git a/roles/custom/matrix-bot-maubot/tasks/main.yml b/roles/custom/matrix-bot-maubot/tasks/main.yml index 5e48eed97..917fea776 100644 --- a/roles/custom/matrix-bot-maubot/tasks/main.yml +++ b/roles/custom/matrix-bot-maubot/tasks/main.yml @@ -1,25 +1,22 @@ --- -- when: matrix_bot_maubot_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_bot_maubot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup|bool and matrix_bot_maubot_enabled|bool" - tags: - - setup-all - - setup-bot-maubot -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup|bool and matrix_bot_maubot_enabled|bool" - tags: - - setup-all - - setup-bot-maubot +- block: + - when: matrix_bot_maubot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup|bool and not matrix_bot_maubot_enabled|bool" + - when: matrix_bot_maubot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_bot_maubot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-bot-maubot diff --git a/roles/custom/matrix-bot-mjolnir/tasks/main.yml b/roles/custom/matrix-bot-mjolnir/tasks/main.yml index 02a22bb1c..25e9d74db 100644 --- a/roles/custom/matrix-bot-mjolnir/tasks/main.yml +++ b/roles/custom/matrix-bot-mjolnir/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_mjolnir_enabled | bool" - tags: - - setup-all - - setup-bot-mjolnir +- block: + - when: matrix_bot_mjolnir_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_mjolnir_enabled | bool" - tags: - - setup-all - - setup-bot-mjolnir + - when: matrix_bot_mjolnir_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_mjolnir_enabled | bool" + - when: not matrix_bot_mjolnir_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-bot-mjolnir diff --git a/roles/custom/matrix-bot-postmoogle/tasks/main.yml b/roles/custom/matrix-bot-postmoogle/tasks/main.yml index 4e2ab51b9..62623c4d5 100644 --- a/roles/custom/matrix-bot-postmoogle/tasks/main.yml +++ b/roles/custom/matrix-bot-postmoogle/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_bot_postmoogle_enabled | bool" - tags: - - setup-all - - setup-bot-postmoogle +- block: + - when: matrix_bot_postmoogle_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_bot_postmoogle_enabled | bool" - tags: - - setup-all - - setup-bot-postmoogle + - when: matrix_bot_postmoogle_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_bot_postmoogle_enabled | bool" + - when: not matrix_bot_postmoogle_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-bot-postmoogle diff --git a/roles/custom/matrix-bridge-appservice-discord/tasks/main.yml b/roles/custom/matrix-bridge-appservice-discord/tasks/main.yml index 249668583..6627d6103 100644 --- a/roles/custom/matrix-bridge-appservice-discord/tasks/main.yml +++ b/roles/custom/matrix-bridge-appservice-discord/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_appservice_discord_enabled | bool" - tags: - - setup-all - - setup-appservice-discord +- block: + - when: matrix_appservice_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_appservice_discord_enabled | bool" - tags: - - setup-all - - setup-appservice-discord + - when: matrix_appservice_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_appservice_discord_enabled | bool" + - when: not matrix_appservice_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-appservice-discord diff --git a/roles/custom/matrix-bridge-appservice-irc/tasks/main.yml b/roles/custom/matrix-bridge-appservice-irc/tasks/main.yml index f66b729ba..b994ddb04 100644 --- a/roles/custom/matrix-bridge-appservice-irc/tasks/main.yml +++ b/roles/custom/matrix-bridge-appservice-irc/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_appservice_irc_enabled | bool" - tags: - - setup-all - - setup-appservice-irc +- block: + - when: matrix_appservice_irc_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_appservice_irc_enabled | bool" - tags: - - setup-all - - setup-appservice-irc + - when: matrix_appservice_irc_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_appservice_irc_enabled | bool" + - when: not matrix_appservice_irc_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-appservice-irc diff --git a/roles/custom/matrix-bridge-appservice-kakaotalk/tasks/main.yml b/roles/custom/matrix-bridge-appservice-kakaotalk/tasks/main.yml index a4dffd76f..be24d778e 100644 --- a/roles/custom/matrix-bridge-appservice-kakaotalk/tasks/main.yml +++ b/roles/custom/matrix-bridge-appservice-kakaotalk/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_appservice_kakaotalk_enabled | bool" - tags: - - setup-all - - setup-appservice-kakaotalk +- block: + - when: matrix_appservice_kakaotalk_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_appservice_kakaotalk_enabled | bool" - tags: - - setup-all - - setup-appservice-kakaotalk + - when: matrix_appservice_kakaotalk_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_appservice_kakaotalk_enabled | bool" + - when: not matrix_appservice_kakaotalk_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-appservice-kakaotalk diff --git a/roles/custom/matrix-bridge-appservice-slack/tasks/main.yml b/roles/custom/matrix-bridge-appservice-slack/tasks/main.yml index 608b02195..277e41776 100644 --- a/roles/custom/matrix-bridge-appservice-slack/tasks/main.yml +++ b/roles/custom/matrix-bridge-appservice-slack/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_appservice_slack_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_appservice_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_appservice_slack_enabled | bool" - tags: - - setup-all - - setup-appservice-slack +- block: + - when: matrix_appservice_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_appservice_slack_enabled | bool" - tags: - - setup-all - - setup-appservice-slack + - when: matrix_appservice_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_appservice_slack_enabled | bool" + - when: not matrix_appservice_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-appservice-slack diff --git a/roles/custom/matrix-bridge-appservice-webhooks/tasks/main.yml b/roles/custom/matrix-bridge-appservice-webhooks/tasks/main.yml index 24908e83a..97793d88d 100644 --- a/roles/custom/matrix-bridge-appservice-webhooks/tasks/main.yml +++ b/roles/custom/matrix-bridge-appservice-webhooks/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_appservice_webhooks_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_appservice_webhooks_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_appservice_webhooks_enabled | bool" - tags: - - setup-all - - setup-appservice-webhooks +- block: + - when: matrix_appservice_webhooks_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_appservice_webhooks_enabled | bool" - tags: - - setup-all - - setup-appservice-webhooks + - when: matrix_appservice_webhooks_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_appservice_webhooks_enabled | bool" + - when: not matrix_appservice_webhooks_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-appservice-webhooks diff --git a/roles/custom/matrix-bridge-beeper-linkedin/tasks/main.yml b/roles/custom/matrix-bridge-beeper-linkedin/tasks/main.yml index 9ba728f13..57dcc2a33 100644 --- a/roles/custom/matrix-bridge-beeper-linkedin/tasks/main.yml +++ b/roles/custom/matrix-bridge-beeper-linkedin/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_beeper_linkedin_enabled | bool" - tags: - - setup-all - - setup-beeper-linkedin +- block: + - when: matrix_beeper_linkedin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup and matrix_beeper_linkedin_enabled" - tags: - - setup-all - - setup-beeper-linkedin + - when: matrix_beeper_linkedin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup and not matrix_beeper_linkedin_enabled" + - when: not matrix_beeper_linkedin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-beeper-linkedin diff --git a/roles/custom/matrix-bridge-go-skype-bridge/tasks/main.yml b/roles/custom/matrix-bridge-go-skype-bridge/tasks/main.yml index 3b8fdb245..cc41f4bd2 100644 --- a/roles/custom/matrix-bridge-go-skype-bridge/tasks/main.yml +++ b/roles/custom/matrix-bridge-go-skype-bridge/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_go_skype_bridge_enabled | bool" - tags: - - setup-all - - setup-go-skype-bridge +- block: + - when: matrix_go_skype_bridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_go_skype_bridge_enabled | bool" - tags: - - setup-all - - setup-go-skype-bridge + - when: matrix_go_skype_bridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_go_skype_bridge_enabled | bool" + - when: not matrix_go_skype_bridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-go-skype-bridge diff --git a/roles/custom/matrix-bridge-heisenbridge/tasks/main.yml b/roles/custom/matrix-bridge-heisenbridge/tasks/main.yml index 70bc86c31..38b891cff 100644 --- a/roles/custom/matrix-bridge-heisenbridge/tasks/main.yml +++ b/roles/custom/matrix-bridge-heisenbridge/tasks/main.yml @@ -1,13 +1,11 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_heisenbridge_enabled | bool" - tags: - - setup-all - - setup-heisenbridge +- block: + - when: matrix_heisenbridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_heisenbridge_enabled | bool" + - when: not matrix_heisenbridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-heisenbridge diff --git a/roles/custom/matrix-bridge-hookshot/tasks/main.yml b/roles/custom/matrix-bridge-hookshot/tasks/main.yml index 5d93af3a5..505b86ed3 100644 --- a/roles/custom/matrix-bridge-hookshot/tasks/main.yml +++ b/roles/custom/matrix-bridge-hookshot/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_hookshot_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_hookshot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_hookshot_enabled | bool" - tags: - - setup-all - - setup-hookshot +- block: + - when: matrix_hookshot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_hookshot_enabled | bool" - tags: - - setup-all - - setup-hookshot + - when: matrix_hookshot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_hookshot_enabled | bool" + - when: not matrix_hookshot_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-hookshot diff --git a/roles/custom/matrix-bridge-mautrix-discord/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-discord/tasks/main.yml index 2b68f1ed4..5c38db0a2 100644 --- a/roles/custom/matrix-bridge-mautrix-discord/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-discord/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_discord_enabled | bool" - tags: - - setup-all - - setup-mautrix-discord +- block: + - when: matrix_mautrix_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup and matrix_mautrix_discord_enabled" - tags: - - setup-all - - setup-mautrix-discord + - when: matrix_mautrix_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup and not matrix_mautrix_discord_enabled" + - when: not matrix_mautrix_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-discord diff --git a/roles/custom/matrix-bridge-mautrix-facebook/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-facebook/tasks/main.yml index f166cc5eb..9e17b87b9 100644 --- a/roles/custom/matrix-bridge-mautrix-facebook/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-facebook/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_mautrix_facebook_enabled | bool and matrix_mautrix_facebook_appservice_public_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_mautrix_facebook_enabled | bool and matrix_mautrix_facebook_appservice_public_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_facebook_enabled | bool" - tags: - - setup-all - - setup-mautrix-facebook +- block: + - when: matrix_mautrix_facebook_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_facebook_enabled | bool" - tags: - - setup-all - - setup-mautrix-facebook + - when: matrix_mautrix_facebook_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_facebook_enabled | bool" + - when: not matrix_mautrix_facebook_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-facebook diff --git a/roles/custom/matrix-bridge-mautrix-googlechat/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-googlechat/tasks/main.yml index e20422a72..9bdc30610 100644 --- a/roles/custom/matrix-bridge-mautrix-googlechat/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-googlechat/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_mautrix_googlechat_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_mautrix_googlechat_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_googlechat_enabled | bool" - tags: - - setup-all - - setup-mautrix-googlechat +- block: + - when: matrix_mautrix_googlechat_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_googlechat_enabled | bool" - tags: - - setup-all - - setup-mautrix-googlechat + - when: matrix_mautrix_googlechat_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_googlechat_enabled | bool" + - when: not matrix_mautrix_googlechat_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-googlechat diff --git a/roles/custom/matrix-bridge-mautrix-hangouts/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-hangouts/tasks/main.yml index a1b7115bd..cce772214 100644 --- a/roles/custom/matrix-bridge-mautrix-hangouts/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-hangouts/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_mautrix_hangouts_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_mautrix_hangouts_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_hangouts_enabled | bool" - tags: - - setup-all - - setup-mautrix-hangouts +- block: + - when: matrix_mautrix_hangouts_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_hangouts_enabled | bool" - tags: - - setup-all - - setup-mautrix-hangouts + - when: matrix_mautrix_hangouts_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_hangouts_enabled | bool" + - when: not matrix_mautrix_hangouts_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-hangouts diff --git a/roles/custom/matrix-bridge-mautrix-instagram/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-instagram/tasks/main.yml index 403546ff4..f559c69d7 100644 --- a/roles/custom/matrix-bridge-mautrix-instagram/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-instagram/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_instagram_enabled | bool" - tags: - - setup-all - - setup-mautrix-instagram +- block: + - when: matrix_mautrix_instagram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_instagram_enabled | bool" - tags: - - setup-all - - setup-mautrix-instagram + - when: matrix_mautrix_instagram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_instagram_enabled | bool" + - when: not matrix_mautrix_instagram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-instagram diff --git a/roles/custom/matrix-bridge-mautrix-signal/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-signal/tasks/main.yml index 6b69be288..a4cd677b8 100644 --- a/roles/custom/matrix-bridge-mautrix-signal/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-signal/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_signal_enabled | bool" - tags: - - setup-all - - setup-mautrix-signal +- block: + - when: matrix_mautrix_signal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_signal_enabled | bool" - tags: - - setup-all - - setup-mautrix-signal + - when: matrix_mautrix_signal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_signal_enabled | bool" + - when: not matrix_mautrix_signal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-signal diff --git a/roles/custom/matrix-bridge-mautrix-telegram/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-telegram/tasks/main.yml index d4a5f8054..a62efb7a5 100644 --- a/roles/custom/matrix-bridge-mautrix-telegram/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-telegram/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_mautrix_telegram_enabled | bool and matrix_mautrix_telegram_appservice_public_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_mautrix_telegram_enabled | bool and matrix_mautrix_telegram_appservice_public_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_telegram_enabled | bool" - tags: - - setup-all - - setup-mautrix-telegram +- block: + - when: matrix_mautrix_telegram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_telegram_enabled | bool" - tags: - - setup-all - - setup-mautrix-telegram + - when: matrix_mautrix_telegram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_telegram_enabled | bool" + - when: not matrix_mautrix_telegram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-telegram diff --git a/roles/custom/matrix-bridge-mautrix-twitter/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-twitter/tasks/main.yml index 08e840aa5..aee0daf7d 100644 --- a/roles/custom/matrix-bridge-mautrix-twitter/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-twitter/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_twitter_enabled | bool" - tags: - - setup-all - - setup-mautrix-twitter +- block: + - when: matrix_mautrix_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mautrix_twitter_enabled | bool" - tags: - - setup-all - - setup-mautrix-twitter + - when: matrix_mautrix_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mautrix_twitter_enabled | bool" + - when: not matrix_mautrix_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-twitter diff --git a/roles/custom/matrix-bridge-mautrix-whatsapp/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-whatsapp/tasks/main.yml index c5b3b153b..4d2342502 100644 --- a/roles/custom/matrix-bridge-mautrix-whatsapp/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-whatsapp/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mautrix_whatsapp_enabled | bool" - tags: - - setup-all - - setup-mautrix-whatsapp +- block: + - when: matrix_mautrix_whatsapp_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup and matrix_mautrix_whatsapp_enabled" - tags: - - setup-all - - setup-mautrix-whatsapp + - when: matrix_mautrix_whatsapp_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup and not matrix_mautrix_whatsapp_enabled" + - when: not matrix_mautrix_whatsapp_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mautrix-whatsapp diff --git a/roles/custom/matrix-bridge-mx-puppet-discord/tasks/main.yml b/roles/custom/matrix-bridge-mx-puppet-discord/tasks/main.yml index c65a04e3b..a77f22650 100644 --- a/roles/custom/matrix-bridge-mx-puppet-discord/tasks/main.yml +++ b/roles/custom/matrix-bridge-mx-puppet-discord/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mx_puppet_discord_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-discord +- block: + - when: matrix_mx_puppet_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mx_puppet_discord_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-discord + - when: matrix_mx_puppet_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mx_puppet_discord_enabled | bool" + - when: not matrix_mx_puppet_discord_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mx-puppet-discord diff --git a/roles/custom/matrix-bridge-mx-puppet-groupme/tasks/main.yml b/roles/custom/matrix-bridge-mx-puppet-groupme/tasks/main.yml index f6707d4e3..6f2a03875 100644 --- a/roles/custom/matrix-bridge-mx-puppet-groupme/tasks/main.yml +++ b/roles/custom/matrix-bridge-mx-puppet-groupme/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mx_puppet_groupme_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-groupme +- block: + - when: matrix_mx_puppet_groupme_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mx_puppet_groupme_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-groupme + - when: matrix_mx_puppet_groupme_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mx_puppet_groupme_enabled | bool" + - when: not matrix_mx_puppet_groupme_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mx-puppet-groupme diff --git a/roles/custom/matrix-bridge-mx-puppet-instagram/tasks/main.yml b/roles/custom/matrix-bridge-mx-puppet-instagram/tasks/main.yml index 220fb46fc..620b0da57 100644 --- a/roles/custom/matrix-bridge-mx-puppet-instagram/tasks/main.yml +++ b/roles/custom/matrix-bridge-mx-puppet-instagram/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mx_puppet_instagram_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-instagram +- block: + - when: matrix_mx_puppet_instagram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mx_puppet_instagram_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-instagram + - when: matrix_mx_puppet_instagram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mx_puppet_instagram_enabled | bool" + - when: not matrix_mx_puppet_instagram_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mx-puppet-instagram diff --git a/roles/custom/matrix-bridge-mx-puppet-slack/tasks/main.yml b/roles/custom/matrix-bridge-mx-puppet-slack/tasks/main.yml index 8850e6bcb..2fe8ea420 100644 --- a/roles/custom/matrix-bridge-mx-puppet-slack/tasks/main.yml +++ b/roles/custom/matrix-bridge-mx-puppet-slack/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_mx_puppet_slack_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_mx_puppet_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mx_puppet_slack_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-slack +- block: + - when: matrix_mx_puppet_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mx_puppet_slack_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-slack + - when: matrix_mx_puppet_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mx_puppet_slack_enabled | bool" + - when: not matrix_mx_puppet_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mx-puppet-slack diff --git a/roles/custom/matrix-bridge-mx-puppet-steam/tasks/main.yml b/roles/custom/matrix-bridge-mx-puppet-steam/tasks/main.yml index 9feb22fb9..a6cab2b0b 100644 --- a/roles/custom/matrix-bridge-mx-puppet-steam/tasks/main.yml +++ b/roles/custom/matrix-bridge-mx-puppet-steam/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mx_puppet_steam_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-steam +- block: + - when: matrix_mx_puppet_steam_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mx_puppet_steam_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-steam + - when: matrix_mx_puppet_steam_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mx_puppet_steam_enabled | bool" + - when: not matrix_mx_puppet_steam_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mx-puppet-steam diff --git a/roles/custom/matrix-bridge-mx-puppet-twitter/tasks/main.yml b/roles/custom/matrix-bridge-mx-puppet-twitter/tasks/main.yml index 87f947096..3e1fe73c9 100644 --- a/roles/custom/matrix-bridge-mx-puppet-twitter/tasks/main.yml +++ b/roles/custom/matrix-bridge-mx-puppet-twitter/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_mx_puppet_twitter_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_mx_puppet_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_mx_puppet_twitter_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-twitter +- block: + - when: matrix_mx_puppet_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_mx_puppet_twitter_enabled | bool" - tags: - - setup-all - - setup-mx-puppet-twitter + - when: matrix_mx_puppet_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_mx_puppet_twitter_enabled | bool" + - when: not matrix_mx_puppet_twitter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mx-puppet-twitter diff --git a/roles/custom/matrix-bridge-sms/tasks/main.yml b/roles/custom/matrix-bridge-sms/tasks/main.yml index 4d4895c46..a802054c6 100644 --- a/roles/custom/matrix-bridge-sms/tasks/main.yml +++ b/roles/custom/matrix-bridge-sms/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_sms_bridge_enabled | bool" - tags: - - setup-all - - setup-matrix-sms-bridge +- block: + - when: matrix_sms_bridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_sms_bridge_enabled | bool" - tags: - - setup-all - - setup-matrix-sms-bridge + - when: matrix_sms_bridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_sms_bridge_enabled | bool" + - when: not matrix_sms_bridge_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-matrix-sms-bridge diff --git a/roles/custom/matrix-cactus-comments/tasks/main.yml b/roles/custom/matrix-cactus-comments/tasks/main.yml index 4bef51535..dab5a1209 100644 --- a/roles/custom/matrix-cactus-comments/tasks/main.yml +++ b/roles/custom/matrix-cactus-comments/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_cactus_comments_enabled | bool and matrix_cactus_comments_serve_client_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_cactus_comments_enabled | bool and matrix_cactus_comments_serve_client_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_cactus_comments_enabled | bool" - tags: - - setup-all - - setup-cactus-comments +- block: + - when: matrix_cactus_comments_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_cactus_comments_enabled | bool" - tags: - - setup-all - - setup-cactus-comments + - when: matrix_cactus_comments_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_cactus_comments_enabled | bool" + - when: not matrix_cactus_comments_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-cactus-comments diff --git a/roles/custom/matrix-client-cinny/tasks/main.yml b/roles/custom/matrix-client-cinny/tasks/main.yml index e0f1579cb..c67116e67 100644 --- a/roles/custom/matrix-client-cinny/tasks/main.yml +++ b/roles/custom/matrix-client-cinny/tasks/main.yml @@ -1,26 +1,20 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_client_cinny_enabled | bool" +- block: + - when: matrix_client_cinny_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_client_cinny_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_client_cinny_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-client-cinny -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_client_cinny_enabled | bool" - tags: - - setup-all - - setup-client-cinny - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check.yml" - delegate_to: 127.0.0.1 - become: false - when: "run_self_check | bool and matrix_client_cinny_enabled | bool" +- block: + - when: matrix_client_cinny_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" tags: - self-check - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_client_cinny_enabled | bool" - tags: - - setup-all - - setup-client-cinny diff --git a/roles/custom/matrix-client-cinny/tasks/self_check.yml b/roles/custom/matrix-client-cinny/tasks/self_check.yml index e0f9bfc1e..c1c6195e0 100644 --- a/roles/custom/matrix-client-cinny/tasks/self_check.yml +++ b/roles/custom/matrix-client-cinny/tasks/self_check.yml @@ -11,6 +11,8 @@ register: matrix_client_cinny_self_check_result check_mode: false ignore_errors: true + delegate_to: 127.0.0.1 + become: false - name: Fail if Cinny not working ansible.builtin.fail: diff --git a/roles/custom/matrix-client-element/tasks/main.yml b/roles/custom/matrix-client-element/tasks/main.yml index 7dbe9ce82..b75a3d5dc 100644 --- a/roles/custom/matrix-client-element/tasks/main.yml +++ b/roles/custom/matrix-client-element/tasks/main.yml @@ -1,38 +1,23 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_client_element_enabled | bool" +- block: + - when: matrix_client_element_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_client_element_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/prepare_themes.yml" + + - when: matrix_client_element_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_client_element_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-client-element -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/prepare_themes.yml" - when: run_setup | bool - tags: - - setup-all - - setup-client-element - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/migrate_riot_web.yml" - when: run_setup | bool - tags: - - setup-all - - setup-client-element - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_client_element_enabled | bool" - tags: - - setup-all - - setup-client-element - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_client_element_enabled | bool" - tags: - - setup-all - - setup-client-element - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check.yml" - delegate_to: 127.0.0.1 - become: false - when: "run_self_check | bool and matrix_client_element_enabled | bool" +- block: + - when: matrix_client_element_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" tags: - self-check diff --git a/roles/custom/matrix-client-element/tasks/migrate_riot_web.yml b/roles/custom/matrix-client-element/tasks/migrate_riot_web.yml deleted file mode 100644 index bb62b7ce5..000000000 --- a/roles/custom/matrix-client-element/tasks/migrate_riot_web.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- - -- name: Check existence of matrix-riot-web.service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-riot-web.service" - register: matrix_client_riot_web_service_stat - when: "matrix_client_element_enabled | bool" - -- name: Ensure matrix-riot-web is stopped - ansible.builtin.service: - name: matrix-riot-web - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "matrix_client_element_enabled | bool and matrix_client_riot_web_service_stat.stat.exists" - -- name: Ensure matrix-riot-web.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-riot-web.service" - state: absent - when: "matrix_client_element_enabled | bool and matrix_client_riot_web_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-riot-web.service removal - ansible.builtin.service: - daemon_reload: true - when: "matrix_client_element_enabled | bool and matrix_client_riot_web_service_stat.stat.exists" - -- name: Check existence of /matrix/riot-web - ansible.builtin.stat: - path: "/matrix/riot-web" - register: matrix_client_riot_web_dir_stat - when: "matrix_client_element_enabled | bool" - -- name: Relocate /matrix/riot-web to /matrix/client-element - ansible.builtin.command: "mv /matrix/riot-web /matrix/client-element" - when: "matrix_client_element_enabled | bool and matrix_client_riot_web_dir_stat.stat.exists" diff --git a/roles/custom/matrix-client-element/tasks/self_check.yml b/roles/custom/matrix-client-element/tasks/self_check.yml index 031bb5f90..c336e4b65 100644 --- a/roles/custom/matrix-client-element/tasks/self_check.yml +++ b/roles/custom/matrix-client-element/tasks/self_check.yml @@ -11,6 +11,8 @@ register: matrix_client_element_self_check_result check_mode: false ignore_errors: true + delegate_to: 127.0.0.1 + become: false - name: Fail if Element not working ansible.builtin.fail: diff --git a/roles/custom/matrix-client-hydrogen/tasks/main.yml b/roles/custom/matrix-client-hydrogen/tasks/main.yml index 3f5023937..220a4d130 100644 --- a/roles/custom/matrix-client-hydrogen/tasks/main.yml +++ b/roles/custom/matrix-client-hydrogen/tasks/main.yml @@ -1,26 +1,20 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_client_hydrogen_enabled | bool" +- block: + - when: matrix_client_hydrogen_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_client_hydrogen_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_client_hydrogen_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-client-hydrogen -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_client_hydrogen_enabled | bool" - tags: - - setup-all - - setup-client-hydrogen - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_client_hydrogen_enabled | bool" - tags: - - setup-all - - setup-client-hydrogen - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check.yml" - delegate_to: 127.0.0.1 - become: false - when: "run_self_check | bool and matrix_client_hydrogen_enabled | bool" +- block: + - when: matrix_client_hydrogen_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" tags: - self-check diff --git a/roles/custom/matrix-client-hydrogen/tasks/self_check.yml b/roles/custom/matrix-client-hydrogen/tasks/self_check.yml index 978e531f2..478f0dc86 100644 --- a/roles/custom/matrix-client-hydrogen/tasks/self_check.yml +++ b/roles/custom/matrix-client-hydrogen/tasks/self_check.yml @@ -11,6 +11,8 @@ register: matrix_client_hydrogen_self_check_result check_mode: false ignore_errors: true + delegate_to: 127.0.0.1 + become: false - name: Fail if Hydrogen not working ansible.builtin.fail: diff --git a/roles/custom/matrix-common-after/tasks/main.yml b/roles/custom/matrix-common-after/tasks/main.yml index 498c83907..fe23e467b 100644 --- a/roles/custom/matrix-common-after/tasks/main.yml +++ b/roles/custom/matrix-common-after/tasks/main.yml @@ -1,5 +1,6 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/run_docker_prune.yml" +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/run_docker_prune.yml" tags: - run-docker-prune diff --git a/roles/custom/matrix-conduit/tasks/conduit/setup.yml b/roles/custom/matrix-conduit/tasks/conduit/setup.yml deleted file mode 100644 index 425d0f7e9..000000000 --- a/roles/custom/matrix-conduit/tasks/conduit/setup.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/conduit/setup_install.yml" - when: "matrix_conduit_enabled | bool" - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/conduit/setup_uninstall.yml" - when: "not matrix_conduit_enabled | bool" diff --git a/roles/custom/matrix-conduit/tasks/main.yml b/roles/custom/matrix-conduit/tasks/main.yml index 85ad539b7..e731f21a8 100644 --- a/roles/custom/matrix-conduit/tasks/main.yml +++ b/roles/custom/matrix-conduit/tasks/main.yml @@ -1,7 +1,11 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/conduit/setup.yml" - when: run_setup | bool +- block: + - when: matrix_conduit_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_conduit_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-conduit diff --git a/roles/custom/matrix-conduit/tasks/conduit/setup_install.yml b/roles/custom/matrix-conduit/tasks/setup_install.yml similarity index 100% rename from roles/custom/matrix-conduit/tasks/conduit/setup_install.yml rename to roles/custom/matrix-conduit/tasks/setup_install.yml diff --git a/roles/custom/matrix-conduit/tasks/conduit/setup_uninstall.yml b/roles/custom/matrix-conduit/tasks/setup_uninstall.yml similarity index 100% rename from roles/custom/matrix-conduit/tasks/conduit/setup_uninstall.yml rename to roles/custom/matrix-conduit/tasks/setup_uninstall.yml diff --git a/roles/custom/matrix-corporal/tasks/main.yml b/roles/custom/matrix-corporal/tasks/main.yml index 1021518c7..3f18ed0cf 100644 --- a/roles/custom/matrix-corporal/tasks/main.yml +++ b/roles/custom/matrix-corporal/tasks/main.yml @@ -1,20 +1,20 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_corporal_enabled | bool" +- block: + - when: matrix_corporal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_corporal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_corporal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-corporal -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_corporal.yml" - when: run_setup | bool - tags: - - setup-all - - setup-corporal - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_corporal.yml" - delegate_to: 127.0.0.1 - become: false - when: "run_self_check | bool and matrix_corporal_enabled | bool" +- block: + - when: matrix_corporal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" tags: - self-check diff --git a/roles/custom/matrix-corporal/tasks/self_check_corporal.yml b/roles/custom/matrix-corporal/tasks/self_check.yml similarity index 96% rename from roles/custom/matrix-corporal/tasks/self_check_corporal.yml rename to roles/custom/matrix-corporal/tasks/self_check.yml index 3ddda8e04..bf0e768b4 100644 --- a/roles/custom/matrix-corporal/tasks/self_check_corporal.yml +++ b/roles/custom/matrix-corporal/tasks/self_check.yml @@ -11,6 +11,8 @@ check_mode: false register: result_corporal_client_api ignore_errors: true + delegate_to: 127.0.0.1 + become: false - name: Fail if Matrix Corporal HTTP gateway not working ansible.builtin.fail: diff --git a/roles/custom/matrix-corporal/tasks/setup_corporal.yml b/roles/custom/matrix-corporal/tasks/setup_install.yml similarity index 53% rename from roles/custom/matrix-corporal/tasks/setup_corporal.yml rename to roles/custom/matrix-corporal/tasks/setup_install.yml index 3f6ac86cd..e257d0118 100644 --- a/roles/custom/matrix-corporal/tasks/setup_corporal.yml +++ b/roles/custom/matrix-corporal/tasks/setup_install.yml @@ -1,9 +1,5 @@ --- -# -# Tasks related to setting up matrix-corporal -# - - name: Ensure Matrix Corporal paths exist ansible.builtin.file: path: "{{ item }}" @@ -15,7 +11,6 @@ - "{{ matrix_corporal_config_dir_path }}" - "{{ matrix_corporal_cache_dir_path }}" - "{{ matrix_corporal_var_dir_path }}" - when: matrix_corporal_enabled | bool - name: Ensure Matrix Corporal repository is present on self-build ansible.builtin.git: @@ -26,7 +21,7 @@ become: true become_user: "{{ matrix_user_username }}" register: matrix_corporal_git_pull_results - when: "matrix_corporal_enabled | bool and matrix_corporal_container_image_self_build | bool" + when: matrix_corporal_container_image_self_build | bool - name: Ensure Matrix Corporal Docker image is built community.docker.docker_image: @@ -38,7 +33,7 @@ dockerfile: etc/docker/Dockerfile path: "{{ matrix_corporal_container_src_files_path }}" pull: true - when: "matrix_corporal_enabled | bool and matrix_corporal_container_image_self_build | bool" + when: matrix_corporal_container_image_self_build | bool - name: Ensure Matrix Corporal Docker image is pulled community.docker.docker_image: @@ -46,7 +41,7 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_corporal_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_corporal_docker_image_force_pull }}" - when: "matrix_corporal_enabled | bool and not matrix_corporal_container_image_self_build | bool" + when: not matrix_corporal_container_image_self_build | bool register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -59,7 +54,6 @@ mode: 0644 owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" - when: matrix_corporal_enabled | bool - name: Ensure matrix-corporal.service installed ansible.builtin.template: @@ -67,55 +61,3 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" mode: 0644 register: matrix_corporal_systemd_service_result - when: matrix_corporal_enabled | bool - -- name: Ensure systemd reloaded after matrix-corporal.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_corporal_enabled | bool and matrix_corporal_systemd_service_result.changed" - - -# -# Tasks related to getting rid of matrix-corporal (if it was previously enabled) -# - -- name: Check existence of matrix-corporal service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" - register: matrix_corporal_service_stat - when: "not matrix_corporal_enabled | bool" - -- name: Ensure matrix-corporal is stopped - ansible.builtin.service: - name: matrix-corporal - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_corporal_enabled | bool and matrix_corporal_service_stat.stat.exists" - -- name: Ensure matrix-corporal.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" - state: absent - when: "not matrix_corporal_enabled | bool and matrix_corporal_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-corporal.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_corporal_enabled | bool and matrix_corporal_service_stat.stat.exists" - -- name: Ensure matrix-corporal files don't exist - ansible.builtin.file: - path: "{{ item }}" - state: absent - with_items: - - "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" - - "{{ matrix_corporal_config_dir_path }}/config.json" - when: "not matrix_corporal_enabled | bool" - -- name: Ensure Matrix Corporal Docker image doesn't exist - community.docker.docker_image: - name: "{{ matrix_corporal_docker_image }}" - state: absent - when: "not matrix_corporal_enabled | bool" diff --git a/roles/custom/matrix-corporal/tasks/setup_uninstall.yml b/roles/custom/matrix-corporal/tasks/setup_uninstall.yml new file mode 100644 index 000000000..81e1b751d --- /dev/null +++ b/roles/custom/matrix-corporal/tasks/setup_uninstall.yml @@ -0,0 +1,38 @@ +--- + +- name: Check existence of matrix-corporal service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" + register: matrix_corporal_service_stat + +- when: matrix_corporal_service_stat.stat.exists | bool + block: + - name: Ensure matrix-corporal is stopped + ansible.builtin.service: + name: matrix-corporal + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-corporal.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" + state: absent + + - name: Ensure systemd reloaded after matrix-corporal.service removal + ansible.builtin.service: + daemon_reload: true + +- name: Ensure matrix-corporal files don't exist + ansible.builtin.file: + path: "{{ item }}" + state: absent + with_items: + - "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" + - "{{ matrix_corporal_config_dir_path }}/config.json" + +- name: Ensure Matrix Corporal Docker image doesn't exist + community.docker.docker_image: + name: "{{ matrix_corporal_docker_image }}" + state: absent diff --git a/roles/custom/matrix-coturn/tasks/main.yml b/roles/custom/matrix-coturn/tasks/main.yml index f2fc66d53..393ed6915 100644 --- a/roles/custom/matrix-coturn/tasks/main.yml +++ b/roles/custom/matrix-coturn/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_coturn_enabled | bool" - tags: - - setup-all - - setup-coturn +- block: + - when: matrix_coturn_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_coturn_enabled | bool" - tags: - - setup-all - - setup-coturn + - when: matrix_coturn_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_coturn_enabled | bool" + - when: not matrix_coturn_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-coturn diff --git a/roles/custom/matrix-dendrite/tasks/main.yml b/roles/custom/matrix-dendrite/tasks/main.yml index 5a5b04dee..62057ded2 100644 --- a/roles/custom/matrix-dendrite/tasks/main.yml +++ b/roles/custom/matrix-dendrite/tasks/main.yml @@ -1,32 +1,26 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: run_setup | bool +- block: + - when: matrix_dendrite_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_dendrite_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_dendrite.yml" tags: - setup-all - setup-dendrite -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_dendrite.yml" - when: run_setup | bool - tags: - - setup-all - - setup-dendrite +- block: + - when: matrix_dendrite_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_client_api.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/register_user.yml" - when: run_dendrite_register_user | bool and matrix_dendrite_enabled | bool + - when: matrix_dendrite_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_federation_api.yml" + tags: + - self-check + +- block: + - when: matrix_dendrite_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/register_user.yml" tags: - register-user - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_client_api.yml" - delegate_to: 127.0.0.1 - become: false - when: run_self_check | bool and matrix_dendrite_enabled | bool - tags: - - self-check - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_federation_api.yml" - delegate_to: 127.0.0.1 - become: false - when: run_self_check | bool and matrix_dendrite_enabled | bool - tags: - - self-check diff --git a/roles/custom/matrix-dendrite/tasks/register_user.yml b/roles/custom/matrix-dendrite/tasks/register_user.yml index d37e633bf..6b4de7e93 100644 --- a/roles/custom/matrix-dendrite/tasks/register_user.yml +++ b/roles/custom/matrix-dendrite/tasks/register_user.yml @@ -1,4 +1,5 @@ --- + - name: Fail if playbook called incorrectly ansible.builtin.fail: msg: "The `username` variable needs to be provided to this playbook, via --extra-vars" diff --git a/roles/custom/matrix-dendrite/tasks/self_check_client_api.yml b/roles/custom/matrix-dendrite/tasks/self_check_client_api.yml index 99b6cb40d..f6eb602c6 100644 --- a/roles/custom/matrix-dendrite/tasks/self_check_client_api.yml +++ b/roles/custom/matrix-dendrite/tasks/self_check_client_api.yml @@ -7,6 +7,8 @@ register: result_matrix_dendrite_client_api ignore_errors: true check_mode: false + delegate_to: 127.0.0.1 + become: false - name: Fail if Matrix Client API not working ansible.builtin.fail: diff --git a/roles/custom/matrix-dendrite/tasks/self_check_federation_api.yml b/roles/custom/matrix-dendrite/tasks/self_check_federation_api.yml index 25b2871ce..bba20ff16 100644 --- a/roles/custom/matrix-dendrite/tasks/self_check_federation_api.yml +++ b/roles/custom/matrix-dendrite/tasks/self_check_federation_api.yml @@ -7,6 +7,8 @@ register: result_matrix_dendrite_federation_api ignore_errors: true check_mode: false + delegate_to: 127.0.0.1 + become: false - name: Fail if Matrix Federation API not working ansible.builtin.fail: diff --git a/roles/custom/matrix-dimension/tasks/main.yml b/roles/custom/matrix-dimension/tasks/main.yml index 38f780e93..5d6f54432 100644 --- a/roles/custom/matrix-dimension/tasks/main.yml +++ b/roles/custom/matrix-dimension/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: run_setup | bool - tags: - - setup-all - - setup-dimension +- block: + - when: matrix_dimension_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: run_setup | bool and matrix_dimension_enabled | bool - tags: - - setup-all - - setup-dimension + - when: matrix_dimension_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: run_setup | bool and not matrix_dimension_enabled | bool + - when: not matrix_dimension_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-dimension diff --git a/roles/custom/matrix-dynamic-dns/tasks/main.yml b/roles/custom/matrix-dynamic-dns/tasks/main.yml index bec7785c9..6f5a35a5e 100644 --- a/roles/custom/matrix-dynamic-dns/tasks/main.yml +++ b/roles/custom/matrix-dynamic-dns/tasks/main.yml @@ -1,19 +1,21 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_dynamic_dns_enabled | bool" +- block: + - when: matrix_appservice_slack_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - - setup-dynamic-dns + - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/install.yml" - when: "run_setup | bool and matrix_dynamic_dns_enabled | bool" - tags: - - setup-all - - setup-dynamic-dns +- block: + - when: matrix_dynamic_dns_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/uninstall.yml" - when: "run_setup | bool and not matrix_dynamic_dns_enabled | bool" + - when: matrix_dynamic_dns_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_dynamic_dns_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-dynamic-dns diff --git a/roles/custom/matrix-dynamic-dns/tasks/install.yml b/roles/custom/matrix-dynamic-dns/tasks/setup_install.yml similarity index 100% rename from roles/custom/matrix-dynamic-dns/tasks/install.yml rename to roles/custom/matrix-dynamic-dns/tasks/setup_install.yml diff --git a/roles/custom/matrix-dynamic-dns/tasks/uninstall.yml b/roles/custom/matrix-dynamic-dns/tasks/setup_uninstall.yml similarity index 100% rename from roles/custom/matrix-dynamic-dns/tasks/uninstall.yml rename to roles/custom/matrix-dynamic-dns/tasks/setup_uninstall.yml diff --git a/roles/custom/matrix-email2matrix/tasks/main.yml b/roles/custom/matrix-email2matrix/tasks/main.yml index 4339b4db3..c3e21d94d 100644 --- a/roles/custom/matrix-email2matrix/tasks/main.yml +++ b/roles/custom/matrix-email2matrix/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_email2matrix_enabled | bool" - tags: - - setup-all - - setup-email2matrix +- block: + - when: matrix_email2matrix_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_email2matrix_enabled | bool" - tags: - - setup-all - - setup-email2matrix + - when: matrix_email2matrix_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_email2matrix_enabled | bool" + - when: not matrix_email2matrix_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-email2matrix diff --git a/roles/custom/matrix-etherpad/tasks/main.yml b/roles/custom/matrix-etherpad/tasks/main.yml index a2c9e077b..46a04a48b 100644 --- a/roles/custom/matrix-etherpad/tasks/main.yml +++ b/roles/custom/matrix-etherpad/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_etherpad_enabled | bool and matrix_etherpad_mode == 'dimension' - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_etherpad_enabled | bool and matrix_etherpad_mode == 'dimension' + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: run_setup | bool and matrix_etherpad_enabled | bool - tags: - - setup-all - - setup-etherpad +- block: + - when: matrix_etherpad_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: run_setup | bool and matrix_etherpad_enabled | bool - tags: - - setup-all - - setup-etherpad + - when: matrix_etherpad_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: run_setup | bool and not matrix_etherpad_enabled | bool + - when: not matrix_etherpad_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-etherpad diff --git a/roles/custom/matrix-grafana/tasks/main.yml b/roles/custom/matrix-grafana/tasks/main.yml index 573f792f6..fc1f3dc6f 100644 --- a/roles/custom/matrix-grafana/tasks/main.yml +++ b/roles/custom/matrix-grafana/tasks/main.yml @@ -1,12 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_grafana_enabled | bool" - tags: - - setup-all - - setup-grafana +- block: + - when: matrix_grafana_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml" + - when: matrix_grafana_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_grafana_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-grafana diff --git a/roles/custom/matrix-grafana/tasks/setup.yml b/roles/custom/matrix-grafana/tasks/setup_install.yml similarity index 65% rename from roles/custom/matrix-grafana/tasks/setup.yml rename to roles/custom/matrix-grafana/tasks/setup_install.yml index eabd25e5f..86a6b04b8 100644 --- a/roles/custom/matrix-grafana/tasks/setup.yml +++ b/roles/custom/matrix-grafana/tasks/setup_install.yml @@ -1,16 +1,11 @@ --- -# -# Tasks related to setting up matrix-grafana -# - - name: Ensure matrix-grafana image is pulled community.docker.docker_image: name: "{{ matrix_grafana_docker_image }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_grafana_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_grafana_docker_image_force_pull }}" - when: "matrix_grafana_enabled | bool" register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -31,7 +26,6 @@ - "{{ matrix_grafana_config_path }}/provisioning/dashboards" - "{{ matrix_grafana_config_path }}/dashboards" - "{{ matrix_grafana_data_path }}" - when: matrix_grafana_enabled | bool - name: Ensure grafana.ini present ansible.builtin.template: @@ -40,7 +34,6 @@ mode: 0440 owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" - when: matrix_grafana_enabled | bool - name: Ensure provisioning/datasources/default.yaml present ansible.builtin.template: @@ -49,7 +42,6 @@ mode: 0440 owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" - when: matrix_grafana_enabled | bool - name: Ensure provisioning/dashboards/default.yaml present ansible.builtin.template: @@ -58,7 +50,6 @@ mode: 0440 owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" - when: matrix_grafana_enabled | bool - name: Ensure dashboard(s) downloaded ansible.builtin.get_url: @@ -69,7 +60,6 @@ owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" with_items: "{{ matrix_grafana_dashboard_download_urls }}" - when: matrix_grafana_enabled | bool register: result retries: "{{ devture_playbook_help_geturl_retries_count }}" delay: "{{ devture_playbook_help_geturl_retries_delay }}" @@ -81,38 +71,3 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-grafana.service" mode: 0644 register: matrix_grafana_systemd_service_result - when: matrix_grafana_enabled | bool - -- name: Ensure systemd reloaded after matrix-grafana.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_grafana_enabled | bool and matrix_grafana_systemd_service_result.changed" - -# -# Tasks related to getting rid of matrix-grafana (if it was previously enabled) -# - -- name: Check existence of matrix-grafana service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-grafana.service" - register: matrix_grafana_service_stat - -- name: Ensure matrix-grafana is stopped - ansible.builtin.service: - name: matrix-grafana - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_grafana_enabled | bool and matrix_grafana_service_stat.stat.exists" - -- name: Ensure matrix-grafana.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-grafana.service" - state: absent - when: "not matrix_grafana_enabled | bool and matrix_grafana_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-grafana.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_grafana_enabled | bool and matrix_grafana_service_stat.stat.exists" diff --git a/roles/custom/matrix-grafana/tasks/setup_uninstall.yml b/roles/custom/matrix-grafana/tasks/setup_uninstall.yml new file mode 100644 index 000000000..6c054ff09 --- /dev/null +++ b/roles/custom/matrix-grafana/tasks/setup_uninstall.yml @@ -0,0 +1,21 @@ +--- + +- name: Check existence of matrix-grafana service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-grafana.service" + register: matrix_grafana_service_stat + +- when: matrix_grafana_service_stat.stat.exists | bool + block: + - name: Ensure matrix-grafana is stopped + ansible.builtin.service: + name: matrix-grafana + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-grafana.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-grafana.service" + state: absent diff --git a/roles/custom/matrix-jitsi/tasks/main.yml b/roles/custom/matrix-jitsi/tasks/main.yml index 9aac5eae8..8a2b9e43e 100644 --- a/roles/custom/matrix-jitsi/tasks/main.yml +++ b/roles/custom/matrix-jitsi/tasks/main.yml @@ -1,43 +1,50 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init_additional_jvb.yml" +- block: + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/init_additional_jvb.yml" tags: - setup-additional-jitsi-jvb -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_jitsi_enabled | bool" +- block: + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_base.yml" tags: - setup-all - setup-jitsi - setup-additional-jitsi-jvb -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_jitsi_base.yml" - when: run_setup | bool - tags: - - setup-all - - setup-jitsi - - setup-additional-jitsi-jvb - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_jitsi_web.yml" - when: run_setup | bool - tags: - - setup-all - - setup-jitsi - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_jitsi_prosody.yml" - when: run_setup | bool - tags: - - setup-all - - setup-jitsi - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_jitsi_jicofo.yml" - when: run_setup | bool - tags: - - setup-all - - setup-jitsi - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_jitsi_jvb.yml" - when: run_setup | bool +- block: + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_web_install.yml" + + - when: not matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_web_uninstall.yml" + + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_prosody_install.yml" + + - when: not matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_prosody_uninstall.yml" + + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_jicofo_install.yml" + + - when: not matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_jicofo_uninstall.yml" + tags: + - setup-all + - setup-jitsi + +- block: + - when: matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_jvb_install.yml" + + - when: not matrix_jitsi_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_jitsi_jvb_uninstall.yml" tags: - setup-all - setup-jitsi diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml index c52c19021..d273b425a 100644 --- a/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml @@ -4,10 +4,6 @@ name: custom/matrix-base tasks_from: ensure_openssl_installed -# -# Tasks related to setting up jitsi -# - - name: Ensure Matrix jitsi base path exists ansible.builtin.file: path: "{{ item.path }}" @@ -17,8 +13,4 @@ group: "{{ matrix_user_groupname }}" with_items: - {path: "{{ matrix_jitsi_base_path }}", when: true} - when: matrix_jitsi_enabled | bool and item.when - -# -# Tasks related to getting rid of jitsi (if it was previously enabled) -# + when: item.when | bool diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo_install.yml similarity index 52% rename from roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo.yml rename to roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo_install.yml index d93953086..6782ecd5b 100644 --- a/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo.yml +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo_install.yml @@ -1,9 +1,5 @@ --- -# -# Tasks related to setting up jitsi-jicofo -# - - name: Ensure Matrix jitsi-jicofo path exists ansible.builtin.file: path: "{{ item.path }}" @@ -14,7 +10,7 @@ with_items: - {path: "{{ matrix_jitsi_jicofo_base_path }}", when: true} - {path: "{{ matrix_jitsi_jicofo_config_path }}", when: true} - when: matrix_jitsi_enabled | bool and item.when + when: item.when | bool - name: Ensure jitsi-jicofo Docker image is pulled community.docker.docker_image: @@ -22,7 +18,6 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_jitsi_jicofo_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_jitsi_jicofo_docker_image_force_pull }}" - when: matrix_jitsi_enabled | bool register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -47,7 +42,6 @@ with_items: - sip-communicator.properties - logging.properties - when: matrix_jitsi_enabled | bool - name: Ensure matrix-jitsi-jicofo.service installed ansible.builtin.template: @@ -55,48 +49,3 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jicofo.service" mode: 0644 register: matrix_jitsi_jicofo_systemd_service_result - when: matrix_jitsi_enabled | bool - -- name: Ensure systemd reloaded after matrix-jitsi-jicofo.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_jitsi_enabled and matrix_jitsi_jicofo_systemd_service_result.changed" - -# -# Tasks related to getting rid of jitsi-jicofo (if it was previously enabled) -# - -- name: Check existence of matrix-jitsi-jicofo service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jicofo.service" - register: matrix_jitsi_jicofo_service_stat - when: "not matrix_jitsi_enabled | bool" - -- name: Ensure matrix-jitsi-jicofo is stopped - ansible.builtin.service: - name: matrix-jitsi-jicofo - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_jicofo_service_stat.stat.exists" - -- name: Ensure matrix-jitsi-jicofo.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jicofo.service" - state: absent - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_jicofo_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-jitsi-jicofo.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_jicofo_service_stat.stat.exists" - -- name: Ensure Matrix jitsi-jicofo paths doesn't exist - ansible.builtin.file: - path: "{{ matrix_jitsi_jicofo_base_path }}" - state: absent - when: "not matrix_jitsi_enabled | bool" - -# Intentionally not removing the Docker image when uninstalling. -# We can't be sure it had been pulled by us in the first place. diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo_uninstall.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo_uninstall.yml new file mode 100644 index 000000000..8e76ddea3 --- /dev/null +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jicofo_uninstall.yml @@ -0,0 +1,26 @@ +--- + +- name: Check existence of matrix-jitsi-jicofo service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jicofo.service" + register: matrix_jitsi_jicofo_service_stat + +- when: matrix_jitsi_jicofo_service_stat.stat.exists | bool + block: + - name: Ensure matrix-jitsi-jicofo is stopped + ansible.builtin.service: + name: matrix-jitsi-jicofo + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-jitsi-jicofo.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jicofo.service" + state: absent + + - name: Ensure Matrix jitsi-jicofo paths doesn't exist + ansible.builtin.file: + path: "{{ matrix_jitsi_jicofo_base_path }}" + state: absent diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb_install.yml similarity index 50% rename from roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb.yml rename to roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb_install.yml index 966572af5..356b40680 100644 --- a/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb.yml +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb_install.yml @@ -1,9 +1,5 @@ --- -# -# Tasks related to setting up jitsi-jvb -# - - name: Ensure Matrix jitsi-jvb path exists ansible.builtin.file: path: "{{ item.path }}" @@ -14,7 +10,7 @@ with_items: - {path: "{{ matrix_jitsi_jvb_base_path }}", when: true} - {path: "{{ matrix_jitsi_jvb_config_path }}", when: true} - when: matrix_jitsi_enabled | bool and item.when + when: item.when | bool - name: Ensure jitsi-jvb Docker image is pulled community.docker.docker_image: @@ -22,7 +18,6 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_jitsi_jvb_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_jitsi_jvb_docker_image_force_pull }}" - when: matrix_jitsi_enabled | bool register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -38,7 +33,6 @@ with_items: - custom-sip-communicator.properties - logging.properties - when: matrix_jitsi_enabled | bool - name: Ensure jitsi-jvb environment variables file created ansible.builtin.template: @@ -47,56 +41,9 @@ owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" mode: 0640 - when: matrix_jitsi_enabled | bool - name: Ensure matrix-jitsi-jvb.service installed ansible.builtin.template: src: "{{ role_path }}/templates/jvb/matrix-jitsi-jvb.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jvb.service" mode: 0644 - register: matrix_jitsi_jvb_systemd_service_result - when: matrix_jitsi_enabled | bool - -- name: Ensure systemd reloaded after matrix-jitsi-jvb.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_jitsi_enabled and matrix_jitsi_jvb_systemd_service_result.changed" - -# -# Tasks related to getting rid of jitsi-jvb (if it was previously enabled) -# - -- name: Check existence of matrix-jitsi-jvb service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jvb.service" - register: matrix_jitsi_jvb_service_stat - when: "not matrix_jitsi_enabled | bool" - -- name: Ensure matrix-jitsi-jvb is stopped - ansible.builtin.service: - name: matrix-jitsi-jvb - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_jvb_service_stat.stat.exists" - -- name: Ensure matrix-jitsi-jvb.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jvb.service" - state: absent - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_jvb_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-jitsi-jvb.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_jvb_service_stat.stat.exists" - -- name: Ensure Matrix jitsi-jvb paths doesn't exist - ansible.builtin.file: - path: "{{ matrix_jitsi_jvb_base_path }}" - state: absent - when: "not matrix_jitsi_enabled | bool" - -# Intentionally not removing the Docker image when uninstalling. -# We can't be sure it had been pulled by us in the first place. diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb_uninstall.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb_uninstall.yml new file mode 100644 index 000000000..f883a3a2f --- /dev/null +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_jvb_uninstall.yml @@ -0,0 +1,26 @@ +--- + +- name: Check existence of matrix-jitsi-jvb service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jvb.service" + register: matrix_jitsi_jvb_service_stat + +- when: matrix_jitsi_jvb_service_stat.stat.exists | bool + block: + - name: Ensure matrix-jitsi-jvb is stopped + ansible.builtin.service: + name: matrix-jitsi-jvb + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-jitsi-jvb.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-jvb.service" + state: absent + + - name: Ensure Matrix jitsi-jvb paths doesn't exist + ansible.builtin.file: + path: "{{ matrix_jitsi_jvb_base_path }}" + state: absent diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody.yml deleted file mode 100644 index 1a1656b2c..000000000 --- a/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- - -# -# Tasks related to setting up jitsi-prosody -# - -- name: Ensure Matrix jitsi-prosody environment exists - ansible.builtin.file: - path: "{{ item.path }}" - state: directory - mode: 0777 - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" - with_items: - - {path: "{{ matrix_jitsi_prosody_base_path }}", when: true} - - {path: "{{ matrix_jitsi_prosody_config_path }}", when: true} - - {path: "{{ matrix_jitsi_prosody_plugins_path }}", when: true} - when: matrix_jitsi_enabled | bool and item.when - -- name: Ensure jitsi-prosody Docker image is pulled - community.docker.docker_image: - name: "{{ matrix_jitsi_prosody_docker_image }}" - source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" - force_source: "{{ matrix_jitsi_prosody_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" - force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_jitsi_prosody_docker_image_force_pull }}" - when: matrix_jitsi_enabled | bool - register: result - retries: "{{ devture_playbook_help_container_retries_count }}" - delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed - -- name: Ensure jitsi-prosody environment variables file is created - ansible.builtin.template: - src: "{{ role_path }}/templates/prosody/env.j2" - dest: "{{ matrix_jitsi_prosody_base_path }}/env" - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" - mode: 0640 - when: matrix_jitsi_enabled | bool - -- name: Ensure matrix-jitsi-prosody.service file is installed - ansible.builtin.template: - src: "{{ role_path }}/templates/prosody/matrix-jitsi-prosody.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-prosody.service" - mode: 0644 - register: matrix_jitsi_prosody_systemd_service_result - when: matrix_jitsi_enabled | bool - -- name: Ensure systemd service is reloaded after matrix-jitsi-prosody.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_jitsi_enabled and matrix_jitsi_prosody_systemd_service_result.changed" - -- name: Ensure authentication is properly configured - ansible.builtin.include_tasks: - file: "{{ role_path }}/tasks/util/setup_jitsi_auth.yml" - when: - - matrix_jitsi_enabled | bool - - matrix_jitsi_enable_auth | bool - - -# -# Tasks related to getting rid of jitsi-prosody (if it was previously enabled) -# - -- name: Ensure matrix-jitsi-prosody.service file exists - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-prosody.service" - register: matrix_jitsi_prosody_service_stat - when: "not matrix_jitsi_enabled | bool" - -- name: Ensure matrix-jitsi-prosody is stopped - ansible.builtin.service: - name: matrix-jitsi-prosody - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_prosody_service_stat.stat.exists" - -- name: Ensure matrix-jitsi-prosody.service file doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-prosody.service" - state: absent - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_prosody_service_stat.stat.exists" - -- name: Ensure systemd is reloaded after matrix-jitsi-prosody.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_prosody_service_stat.stat.exists" - -- name: Ensure Matrix jitsi-prosody paths doesn't exist - ansible.builtin.file: - path: "{{ matrix_jitsi_prosody_base_path }}" - state: absent - when: "not matrix_jitsi_enabled | bool" - -# Intentionally not removing the Docker image when uninstalling. -# We can't be sure it had been pulled by us in the first place. diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody_install.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody_install.yml new file mode 100644 index 000000000..785811666 --- /dev/null +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody_install.yml @@ -0,0 +1,45 @@ +--- + +- name: Ensure Matrix jitsi-prosody environment exists + ansible.builtin.file: + path: "{{ item.path }}" + state: directory + mode: 0777 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + with_items: + - {path: "{{ matrix_jitsi_prosody_base_path }}", when: true} + - {path: "{{ matrix_jitsi_prosody_config_path }}", when: true} + - {path: "{{ matrix_jitsi_prosody_plugins_path }}", when: true} + when: item.when | bool + +- name: Ensure jitsi-prosody Docker image is pulled + community.docker.docker_image: + name: "{{ matrix_jitsi_prosody_docker_image }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_jitsi_prosody_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_jitsi_prosody_docker_image_force_pull }}" + register: result + retries: "{{ devture_playbook_help_container_retries_count }}" + delay: "{{ devture_playbook_help_container_retries_delay }}" + until: result is not failed + +- name: Ensure jitsi-prosody environment variables file is created + ansible.builtin.template: + src: "{{ role_path }}/templates/prosody/env.j2" + dest: "{{ matrix_jitsi_prosody_base_path }}/env" + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + mode: 0640 + +- name: Ensure matrix-jitsi-prosody.service file is installed + ansible.builtin.template: + src: "{{ role_path }}/templates/prosody/matrix-jitsi-prosody.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-prosody.service" + mode: 0644 + register: matrix_jitsi_prosody_systemd_service_result + +- name: Ensure authentication is properly configured + ansible.builtin.include_tasks: + file: "{{ role_path }}/tasks/util/setup_jitsi_auth.yml" + when: matrix_jitsi_enable_auth | bool diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody_uninstall.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody_uninstall.yml new file mode 100644 index 000000000..3fd44f72d --- /dev/null +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_prosody_uninstall.yml @@ -0,0 +1,26 @@ +--- + +- name: Check if matrix-jitsi-prosody.service file exists + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-prosody.service" + register: matrix_jitsi_prosody_service_stat + +- when: matrix_jitsi_prosody_service_stat.stat.exists | bool + block: + - name: Ensure matrix-jitsi-prosody is stopped + ansible.builtin.service: + name: matrix-jitsi-prosody + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-jitsi-prosody.service file doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-prosody.service" + state: absent + + - name: Ensure Matrix jitsi-prosody paths doesn't exist + ansible.builtin.file: + path: "{{ matrix_jitsi_prosody_base_path }}" + state: absent diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_web.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_web_install.yml similarity index 53% rename from roles/custom/matrix-jitsi/tasks/setup_jitsi_web.yml rename to roles/custom/matrix-jitsi/tasks/setup_jitsi_web_install.yml index b6d3241b5..710b2b0ca 100644 --- a/roles/custom/matrix-jitsi/tasks/setup_jitsi_web.yml +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_web_install.yml @@ -1,9 +1,5 @@ --- -# -# Tasks related to setting up jitsi-web -# - - name: Ensure Matrix jitsi-web path exists ansible.builtin.file: path: "{{ item.path }}" @@ -16,7 +12,7 @@ - {path: "{{ matrix_jitsi_web_config_path }}", when: true} - {path: "{{ matrix_jitsi_web_transcripts_path }}", when: true} - {path: "{{ matrix_jitsi_web_crontabs_path }}", when: true} - when: matrix_jitsi_enabled | bool and item.when + when: item.when | bool - name: Ensure jitsi-web Docker image is pulled community.docker.docker_image: @@ -24,7 +20,6 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_jitsi_web_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_jitsi_web_docker_image_force_pull }}" - when: matrix_jitsi_enabled | bool register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -37,7 +32,6 @@ owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" mode: 0640 - when: matrix_jitsi_enabled | bool - name: Ensure jitsi-web configuration files created ansible.builtin.template: @@ -49,7 +43,6 @@ with_items: - custom-config.js - custom-interface_config.js - when: matrix_jitsi_enabled | bool - name: Ensure matrix-jitsi-web.service installed ansible.builtin.template: @@ -57,48 +50,3 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-web.service" mode: 0644 register: matrix_jitsi_web_systemd_service_result - when: matrix_jitsi_enabled | bool - -- name: Ensure systemd reloaded after matrix-jitsi-web.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_jitsi_enabled and matrix_jitsi_web_systemd_service_result.changed" - -# -# Tasks related to getting rid of jitsi-web (if it was previously enabled) -# - -- name: Check existence of matrix-jitsi-web service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-web.service" - register: matrix_jitsi_web_service_stat - when: "not matrix_jitsi_enabled | bool" - -- name: Ensure matrix-jitsi-web is stopped - ansible.builtin.service: - name: matrix-jitsi-web - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_web_service_stat.stat.exists" - -- name: Ensure matrix-jitsi-web.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-web.service" - state: absent - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_web_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-jitsi-web.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_jitsi_enabled | bool and matrix_jitsi_web_service_stat.stat.exists" - -- name: Ensure Matrix jitsi-web paths doesn't exist - ansible.builtin.file: - path: "{{ matrix_jitsi_web_base_path }}" - state: absent - when: "not matrix_jitsi_enabled | bool" - -# Intentionally not removing the Docker image when uninstalling. -# We can't be sure it had been pulled by us in the first place. diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_web_uninstall.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_web_uninstall.yml new file mode 100644 index 000000000..7c99c2802 --- /dev/null +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_web_uninstall.yml @@ -0,0 +1,26 @@ +--- + +- name: Check existence of matrix-jitsi-web service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-web.service" + register: matrix_jitsi_web_service_stat + +- when: matrix_jitsi_web_service_stat.stat.exists | bool + block: + - name: Ensure matrix-jitsi-web is stopped + ansible.builtin.service: + name: matrix-jitsi-web + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-jitsi-web.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jitsi-web.service" + state: absent + + - name: Ensure Matrix jitsi-web paths doesn't exist + ansible.builtin.file: + path: "{{ matrix_jitsi_web_base_path }}" + state: absent diff --git a/roles/custom/matrix-ldap-registration-proxy/tasks/main.yml b/roles/custom/matrix-ldap-registration-proxy/tasks/main.yml index 1bba9ad1d..758bea97a 100644 --- a/roles/custom/matrix-ldap-registration-proxy/tasks/main.yml +++ b/roles/custom/matrix-ldap-registration-proxy/tasks/main.yml @@ -1,25 +1,21 @@ --- -- when: matrix_ldap_registration_proxy_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_ldap_registration_proxy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_ldap_registration_proxy_enabled | bool" - tags: - - setup-all - - setup-matrix-ldap-registration-proxy +- block: + - when: matrix_ldap_registration_proxy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_ldap_registration_proxy_enabled | bool" - tags: - - setup-all - - setup-matrix-ldap-registration-proxy + - when: matrix_ldap_registration_proxy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_ldap_registration_proxy_enabled | bool" + - when: not matrix_ldap_registration_proxy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-matrix-ldap-registration-proxy diff --git a/roles/custom/matrix-ma1sd/tasks/main.yml b/roles/custom/matrix-ma1sd/tasks/main.yml index add76bb2d..c1208f749 100644 --- a/roles/custom/matrix-ma1sd/tasks/main.yml +++ b/roles/custom/matrix-ma1sd/tasks/main.yml @@ -1,26 +1,19 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_ma1sd_enabled | bool" +- block: + - when: matrix_ma1sd_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_ma1sd_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_ma1sd_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - - setup-all - setup-ma1sd -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_ma1sd_enabled | bool" - tags: - - setup-all - - setup-ma1sd - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_ma1sd_enabled | bool" - tags: - - setup-all - - setup-ma1sd - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_ma1sd.yml" - delegate_to: 127.0.0.1 - become: false - when: "run_self_check | bool and matrix_ma1sd_enabled | bool" +- block: + - when: matrix_ma1sd_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" tags: - self-check diff --git a/roles/custom/matrix-ma1sd/tasks/self_check_ma1sd.yml b/roles/custom/matrix-ma1sd/tasks/self_check.yml similarity index 95% rename from roles/custom/matrix-ma1sd/tasks/self_check_ma1sd.yml rename to roles/custom/matrix-ma1sd/tasks/self_check.yml index 6fde9dd2f..66765727e 100644 --- a/roles/custom/matrix-ma1sd/tasks/self_check_ma1sd.yml +++ b/roles/custom/matrix-ma1sd/tasks/self_check.yml @@ -11,6 +11,8 @@ check_mode: false register: result_ma1sd ignore_errors: true + delegate_to: 127.0.0.1 + become: false - name: Fail if ma1sd Identity Service not working ansible.builtin.fail: diff --git a/roles/custom/matrix-mailer/tasks/main.yml b/roles/custom/matrix-mailer/tasks/main.yml index cf9123bf3..2c2a03675 100644 --- a/roles/custom/matrix-mailer/tasks/main.yml +++ b/roles/custom/matrix-mailer/tasks/main.yml @@ -1,7 +1,11 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_mailer.yml" - when: run_setup | bool +- block: + - when: matrix_mailer_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_mailer_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-mailer diff --git a/roles/custom/matrix-mailer/tasks/setup_mailer.yml b/roles/custom/matrix-mailer/tasks/setup_install.yml similarity index 57% rename from roles/custom/matrix-mailer/tasks/setup_mailer.yml rename to roles/custom/matrix-mailer/tasks/setup_install.yml index 5d81565a2..113551657 100644 --- a/roles/custom/matrix-mailer/tasks/setup_mailer.yml +++ b/roles/custom/matrix-mailer/tasks/setup_install.yml @@ -1,9 +1,5 @@ --- -# -# Tasks related to setting up the mailer -# - - name: Ensure mailer base path exists ansible.builtin.file: path: "{{ item.path }}" @@ -14,14 +10,13 @@ with_items: - {path: "{{ matrix_mailer_base_path }}", when: true} - {path: "{{ matrix_mailer_container_image_self_build_src_files_path }}", when: "{{ matrix_mailer_container_image_self_build }}"} - when: "matrix_mailer_enabled | bool and item.when" + when: item.when | bool - name: Ensure mailer environment variables file created ansible.builtin.template: src: "{{ role_path }}/templates/env-mailer.j2" dest: "{{ matrix_mailer_base_path }}/env-mailer" mode: 0640 - when: matrix_mailer_enabled | bool - name: Ensure exim-relay repository is present on self-build ansible.builtin.git: @@ -32,7 +27,7 @@ become: true become_user: "{{ matrix_user_username }}" register: matrix_mailer_git_pull_results - when: "matrix_mailer_enabled | bool and matrix_mailer_container_image_self_build | bool" + when: matrix_mailer_container_image_self_build | bool - name: Ensure exim-relay Docker image is built community.docker.docker_image: @@ -44,7 +39,7 @@ dockerfile: Dockerfile path: "{{ matrix_mailer_container_image_self_build_src_files_path }}" pull: true - when: "matrix_mailer_enabled | bool and matrix_mailer_container_image_self_build | bool" + when: matrix_mailer_container_image_self_build | bool - name: Ensure exim-relay image is pulled community.docker.docker_image: @@ -52,7 +47,7 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_mailer_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_docker_image_force_pull }}" - when: "matrix_mailer_enabled | bool and not matrix_mailer_container_image_self_build | bool" + when: "not matrix_mailer_container_image_self_build | bool" register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -64,51 +59,8 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service" mode: 0644 register: matrix_mailer_systemd_service_result - when: matrix_mailer_enabled | bool - name: Ensure systemd reloaded after matrix-mailer.service installation ansible.builtin.service: daemon_reload: true - when: "matrix_mailer_enabled | bool and matrix_mailer_systemd_service_result.changed" - -# -# Tasks related to getting rid of the mailer (if it was previously enabled) -# - -- name: Check existence of matrix-mailer service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service" - register: matrix_mailer_service_stat - when: "not matrix_mailer_enabled | bool" - -- name: Ensure matrix-mailer is stopped - ansible.builtin.service: - name: matrix-mailer - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_mailer_enabled | bool and matrix_mailer_service_stat.stat.exists" - -- name: Ensure matrix-mailer.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service" - state: absent - when: "not matrix_mailer_enabled | bool and matrix_mailer_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-mailer.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_mailer_enabled | bool and matrix_mailer_service_stat.stat.exists" - -- name: Ensure Matrix mailer environment variables path doesn't exist - ansible.builtin.file: - path: "{{ matrix_mailer_base_path }}" - state: absent - when: "not matrix_mailer_enabled | bool" - -- name: Ensure mailer Docker image doesn't exist - community.docker.docker_image: - name: "{{ matrix_mailer_docker_image }}" - state: absent - when: "not matrix_mailer_enabled | bool" + when: matrix_mailer_systemd_service_result.changed | bool diff --git a/roles/custom/matrix-mailer/tasks/setup_uninstall.yml b/roles/custom/matrix-mailer/tasks/setup_uninstall.yml new file mode 100644 index 000000000..d8fb65c30 --- /dev/null +++ b/roles/custom/matrix-mailer/tasks/setup_uninstall.yml @@ -0,0 +1,35 @@ +--- + +- name: Check existence of matrix-mailer service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service" + register: matrix_mailer_service_stat + +- when: matrix_mailer_service_stat.stat.exists | bool + block: + - name: Ensure matrix-mailer is stopped + ansible.builtin.service: + name: matrix-mailer + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-mailer.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mailer.service" + state: absent + + - name: Ensure systemd reloaded after matrix-mailer.service removal + ansible.builtin.service: + daemon_reload: true + +- name: Ensure Matrix mailer path doesn't exist + ansible.builtin.file: + path: "{{ matrix_mailer_base_path }}" + state: absent + +- name: Ensure mailer Docker image doesn't exist + community.docker.docker_image: + name: "{{ matrix_mailer_docker_image }}" + state: absent diff --git a/roles/custom/matrix-nginx-proxy/tasks/main.yml b/roles/custom/matrix-nginx-proxy/tasks/main.yml index 168608daa..7ead49700 100644 --- a/roles/custom/matrix-nginx-proxy/tasks/main.yml +++ b/roles/custom/matrix-nginx-proxy/tasks/main.yml @@ -22,10 +22,8 @@ - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_well_known.yml" - delegate_to: 127.0.0.1 - become: false - when: run_self_check | bool +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_well_known.yml" tags: - self-check diff --git a/roles/custom/matrix-ntfy/tasks/main.yml b/roles/custom/matrix-ntfy/tasks/main.yml index 8a4acd7ce..1c2c266e1 100644 --- a/roles/custom/matrix-ntfy/tasks/main.yml +++ b/roles/custom/matrix-ntfy/tasks/main.yml @@ -1,20 +1,17 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_ntfy_enabled | bool" +- block: + - when: matrix_ntfy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_ntfy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-ntfy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_ntfy_enabled | bool" - tags: - - setup-all - - setup-ntfy - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check.yml" - delegate_to: 127.0.0.1 - become: false - when: "run_self_check | bool and matrix_ntfy_enabled | bool" +- block: + - when: matrix_ntfy_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" tags: - self-check diff --git a/roles/custom/matrix-ntfy/tasks/self_check.yml b/roles/custom/matrix-ntfy/tasks/self_check.yml index 02529f35e..bdbd666a0 100644 --- a/roles/custom/matrix-ntfy/tasks/self_check.yml +++ b/roles/custom/matrix-ntfy/tasks/self_check.yml @@ -14,6 +14,8 @@ register: matrix_ntfy_self_check_result check_mode: false ignore_errors: true + delegate_to: 127.0.0.1 + become: false - name: Fail if ntfy not working ansible.builtin.fail: diff --git a/roles/custom/matrix-postgres-backup/tasks/main.yml b/roles/custom/matrix-postgres-backup/tasks/main.yml index 4fef6f459..1408f695c 100644 --- a/roles/custom/matrix-postgres-backup/tasks/main.yml +++ b/roles/custom/matrix-postgres-backup/tasks/main.yml @@ -1,13 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_postgres_backup_enabled | bool" - tags: - - setup-all - - setup-postgres-backup +- block: + - when: matrix_postgres_backup_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_postgres_backup.yml" - when: run_setup | bool + - when: matrix_postgres_backup_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_postgres_backup_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-postgres-backup diff --git a/roles/custom/matrix-postgres-backup/tasks/setup_install.yml b/roles/custom/matrix-postgres-backup/tasks/setup_install.yml new file mode 100644 index 000000000..d26fff6e4 --- /dev/null +++ b/roles/custom/matrix-postgres-backup/tasks/setup_install.yml @@ -0,0 +1,57 @@ +--- + + +- ansible.builtin.import_role: + name: custom/matrix-postgres + tasks_from: detect_existing_postgres_version + when: 'matrix_postgres_backup_postgres_data_path != ""' + +# If we have found an existing version (installed from before), we use its corresponding Docker image. +# If not, we install using the latest Postgres. +# +# Upgrading is supposed to be performed separately and explicitly (see `upgrade_postgres.yml`). +- ansible.builtin.set_fact: + matrix_postgres_backup_docker_image_to_use: "{{ matrix_postgres_backup_docker_image_latest if matrix_postgres_backup_detected_version_corresponding_docker_image | default('') == '' else matrix_postgres_backup_detected_version_corresponding_docker_image }}" + +- name: Ensure postgres backup Docker image is pulled + community.docker.docker_image: + name: "{{ matrix_postgres_backup_docker_image_to_use }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_postgres_backup_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_postgres_backup_docker_image_force_pull }}" + register: result + retries: "{{ devture_playbook_help_container_retries_count }}" + delay: "{{ devture_playbook_help_container_retries_delay }}" + until: result is not failed + +- name: Ensure Postgres backup paths exist + ansible.builtin.file: + path: "{{ item }}" + state: directory + mode: 0700 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + with_items: + - "{{ matrix_postgres_backup_path }}" + +- name: Ensure Postgres environment variables file created + ansible.builtin.template: + src: "{{ role_path }}/templates/{{ item }}.j2" + dest: "{{ matrix_postgres_backup_path }}/{{ item }}" + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + mode: 0640 + with_items: + - "env-postgres-backup" + +- name: Ensure matrix-postgres-backup.service installed + ansible.builtin.template: + src: "{{ role_path }}/templates/systemd/matrix-postgres-backup.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postgres-backup.service" + mode: 0644 + register: matrix_postgres_backup_systemd_service_result + +- name: Ensure systemd reloaded after matrix-postgres-backup.service installation + ansible.builtin.service: + daemon_reload: true + when: matrix_postgres_backup_systemd_service_result.changed | bool diff --git a/roles/custom/matrix-postgres-backup/tasks/setup_postgres_backup.yml b/roles/custom/matrix-postgres-backup/tasks/setup_postgres_backup.yml deleted file mode 100644 index 6066ee491..000000000 --- a/roles/custom/matrix-postgres-backup/tasks/setup_postgres_backup.yml +++ /dev/null @@ -1,112 +0,0 @@ ---- - -# -# Tasks related to setting up postgres backup -# -- ansible.builtin.import_role: - name: custom/matrix-postgres - tasks_from: detect_existing_postgres_version - when: 'matrix_postgres_backup_enabled | bool and matrix_postgres_backup_postgres_data_path != ""' - -# If we have found an existing version (installed from before), we use its corresponding Docker image. -# If not, we install using the latest Postgres. -# -# Upgrading is supposed to be performed separately and explicitly (see `upgrade_postgres.yml`). -- ansible.builtin.set_fact: - matrix_postgres_backup_docker_image_to_use: "{{ matrix_postgres_backup_docker_image_latest if matrix_postgres_backup_detected_version_corresponding_docker_image | default('') == '' else matrix_postgres_backup_detected_version_corresponding_docker_image }}" - when: matrix_postgres_backup_enabled | bool - -- name: Ensure postgres backup Docker image is pulled - community.docker.docker_image: - name: "{{ matrix_postgres_backup_docker_image_to_use }}" - source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" - force_source: "{{ matrix_postgres_backup_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" - force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_postgres_backup_docker_image_force_pull }}" - when: matrix_postgres_backup_enabled | bool - register: result - retries: "{{ devture_playbook_help_container_retries_count }}" - delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed - -- name: Ensure Postgres backup paths exist - ansible.builtin.file: - path: "{{ item }}" - state: directory - mode: 0700 - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" - with_items: - - "{{ matrix_postgres_backup_path }}" - when: matrix_postgres_backup_enabled | bool - -- name: Ensure Postgres environment variables file created - ansible.builtin.template: - src: "{{ role_path }}/templates/{{ item }}.j2" - dest: "{{ matrix_postgres_backup_path }}/{{ item }}" - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" - mode: 0640 - with_items: - - "env-postgres-backup" - when: matrix_postgres_backup_enabled | bool - -- name: Ensure matrix-postgres-backup.service installed - ansible.builtin.template: - src: "{{ role_path }}/templates/systemd/matrix-postgres-backup.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postgres-backup.service" - mode: 0644 - register: matrix_postgres_backup_systemd_service_result - when: matrix_postgres_backup_enabled | bool - -- name: Ensure systemd reloaded after matrix-postgres-backup.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_postgres_backup_enabled | bool and matrix_postgres_backup_systemd_service_result.changed" - -# -# Tasks related to getting rid of postgres backup (if it was previously enabled) -# - -- name: Check existence of matrix-postgres-backup service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postgres-backup.service" - register: matrix_postgres_backup_service_stat - when: "not matrix_postgres_backup_enabled | bool" - -- name: Ensure matrix-postgres-backup is stopped - ansible.builtin.service: - name: matrix-postgres-backup - state: stopped - enabled: false - daemon_reload: true - when: "not matrix_postgres_backup_enabled | bool and matrix_postgres_backup_service_stat.stat.exists" - -- name: Ensure matrix-postgres-backup.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postgres-backup.service" - state: absent - when: "not matrix_postgres_backup_enabled | bool and matrix_postgres_backup_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-postgres-backup.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_postgres_backup_enabled | bool and matrix_postgres_backup_service_stat.stat.exists" - -- name: Check existence of matrix-postgres-backup backup path - ansible.builtin.stat: - path: "{{ matrix_postgres_backup_path }}" - register: matrix_postgres_backup_path_stat - when: "not matrix_postgres_backup_enabled | bool" - -# We just want to notify the user. Deleting data is too destructive. -- name: Inject warning if matrix-postgres backup data remains - ansible.builtin.set_fact: - devture_playbook_runtime_messages_list: | - {{ - devture_playbook_runtime_messages_list | default([]) - + - [ - "NOTE: You are not using the local backup service to backup the PostgreSQL database, but some old data remains from before in `{{ matrix_postgres_backup_path }}`. Feel free to delete it." - ] - }} - when: "not matrix_postgres_backup_enabled | bool and matrix_postgres_backup_path_stat.stat.exists" diff --git a/roles/custom/matrix-postgres-backup/tasks/setup_uninstall.yml b/roles/custom/matrix-postgres-backup/tasks/setup_uninstall.yml new file mode 100644 index 000000000..0b3709ebe --- /dev/null +++ b/roles/custom/matrix-postgres-backup/tasks/setup_uninstall.yml @@ -0,0 +1,43 @@ +--- + +- name: Check existence of matrix-postgres-backup service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postgres-backup.service" + register: matrix_postgres_backup_service_stat + + +- when: matrix_postgres_backup_service_stat.stat.exists | bool + block: + - name: Ensure matrix-postgres-backup is stopped + ansible.builtin.service: + name: matrix-postgres-backup + state: stopped + enabled: false + daemon_reload: true + + - name: Ensure matrix-postgres-backup.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postgres-backup.service" + state: absent + + - name: Ensure systemd reloaded after matrix-postgres-backup.service removal + ansible.builtin.service: + daemon_reload: true + +- name: Check existence of matrix-postgres-backup backup path + ansible.builtin.stat: + path: "{{ matrix_postgres_backup_path }}" + register: matrix_postgres_backup_path_stat + +# We just want to notify the user. Deleting data is too destructive. +- name: Inject warning if matrix-postgres backup data remains + ansible.builtin.set_fact: + devture_playbook_runtime_messages_list: | + {{ + devture_playbook_runtime_messages_list | default([]) + + + [ + "NOTE: You are not using the local backup service to backup the PostgreSQL database, but some old data remains from before in `{{ matrix_postgres_backup_path }}`. Feel free to delete it." + ] + }} + when: matrix_postgres_backup_path_stat.stat.exists | bool diff --git a/roles/custom/matrix-prometheus-node-exporter/tasks/main.yml b/roles/custom/matrix-prometheus-node-exporter/tasks/main.yml index 145adfdd0..c86cdad73 100644 --- a/roles/custom/matrix-prometheus-node-exporter/tasks/main.yml +++ b/roles/custom/matrix-prometheus-node-exporter/tasks/main.yml @@ -1,12 +1,18 @@ --- -- when: matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_metrics_proxying_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_metrics_proxying_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml" +- block: + - when: matrix_prometheus_node_exporter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_prometheus_node_exporter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-prometheus-node-exporter diff --git a/roles/custom/matrix-prometheus-node-exporter/tasks/setup.yml b/roles/custom/matrix-prometheus-node-exporter/tasks/setup.yml deleted file mode 100644 index 0b0c5704a..000000000 --- a/roles/custom/matrix-prometheus-node-exporter/tasks/setup.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- - -# -# Tasks related to setting up matrix-prometheus-node-exporter -# - -- name: Ensure matrix-prometheus-node-exporter image is pulled - community.docker.docker_image: - name: "{{ matrix_prometheus_node_exporter_docker_image }}" - source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" - force_source: "{{ matrix_prometheus_node_exporter_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" - force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_prometheus_node_exporter_docker_image_force_pull }}" - when: "matrix_prometheus_node_exporter_enabled | bool" - register: result - retries: "{{ devture_playbook_help_container_retries_count }}" - delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed - -- name: Ensure matrix-prometheus-node-exporter.service installed - ansible.builtin.template: - src: "{{ role_path }}/templates/systemd/matrix-prometheus-node-exporter.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-node-exporter.service" - mode: 0644 - register: matrix_prometheus_node_exporter_systemd_service_result - when: matrix_prometheus_node_exporter_enabled | bool - -- name: Ensure systemd reloaded after matrix-prometheus.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_systemd_service_result.changed" - -# -# Tasks related to getting rid of matrix-prometheus-node-exporter (if it was previously enabled) -# - -- name: Check existence of matrix-prometheus-node-exporter service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-node-exporter.service" - register: matrix_prometheus_node_exporter_service_stat - -- name: Ensure matrix-prometheus-node-exporter is stopped - ansible.builtin.service: - name: matrix-prometheus-node-exporter - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_service_stat.stat.exists" - -- name: Ensure matrix-prometheus-node-exporter.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-node-exporter.service" - state: absent - when: "not matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-prometheus-node-exporter.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_service_stat.stat.exists" diff --git a/roles/custom/matrix-prometheus-node-exporter/tasks/setup_install.yml b/roles/custom/matrix-prometheus-node-exporter/tasks/setup_install.yml new file mode 100644 index 000000000..3c0af96b9 --- /dev/null +++ b/roles/custom/matrix-prometheus-node-exporter/tasks/setup_install.yml @@ -0,0 +1,19 @@ +--- + +- name: Ensure matrix-prometheus-node-exporter image is pulled + community.docker.docker_image: + name: "{{ matrix_prometheus_node_exporter_docker_image }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_prometheus_node_exporter_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_prometheus_node_exporter_docker_image_force_pull }}" + register: result + retries: "{{ devture_playbook_help_container_retries_count }}" + delay: "{{ devture_playbook_help_container_retries_delay }}" + until: result is not failed + +- name: Ensure matrix-prometheus-node-exporter.service installed + ansible.builtin.template: + src: "{{ role_path }}/templates/systemd/matrix-prometheus-node-exporter.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-node-exporter.service" + mode: 0644 + register: matrix_prometheus_node_exporter_systemd_service_result diff --git a/roles/custom/matrix-prometheus-node-exporter/tasks/setup_uninstall.yml b/roles/custom/matrix-prometheus-node-exporter/tasks/setup_uninstall.yml new file mode 100644 index 000000000..7239c0ac1 --- /dev/null +++ b/roles/custom/matrix-prometheus-node-exporter/tasks/setup_uninstall.yml @@ -0,0 +1,25 @@ +--- + +- name: Check existence of matrix-prometheus-node-exporter service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-node-exporter.service" + register: matrix_prometheus_node_exporter_service_stat + +- when: matrix_prometheus_node_exporter_service_stat.stat.exists | bool + block: + - name: Ensure matrix-prometheus-node-exporter is stopped + ansible.builtin.service: + name: matrix-prometheus-node-exporter + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-prometheus-node-exporter.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-node-exporter.service" + state: absent + + - name: Ensure systemd reloaded after matrix-prometheus-node-exporter.service removal + ansible.builtin.service: + daemon_reload: true diff --git a/roles/custom/matrix-prometheus-postgres-exporter/tasks/main.yml b/roles/custom/matrix-prometheus-postgres-exporter/tasks/main.yml index 59911efbe..2e06fdd57 100644 --- a/roles/custom/matrix-prometheus-postgres-exporter/tasks/main.yml +++ b/roles/custom/matrix-prometheus-postgres-exporter/tasks/main.yml @@ -1,12 +1,18 @@ --- -- when: matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_metrics_proxying_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_prometheus_postgres_exporter_enabled | bool and matrix_prometheus_postgres_exporter_metrics_proxying_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml" +- block: + - when: matrix_prometheus_postgres_exporter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_prometheus_postgres_exporter_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-prometheus-postgres-exporter diff --git a/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup.yml b/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup.yml deleted file mode 100644 index 1ab157994..000000000 --- a/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- - -# -# Tasks related to setting up matrix-prometheus-postgres-exporter -# - -- name: Ensure matrix-prometheus-postgres-exporter image is pulled - community.docker.docker_image: - name: "{{ matrix_prometheus_postgres_exporter_docker_image }}" - source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" - force_source: "{{ matrix_prometheus_postgres_exporter_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" - force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_prometheus_postgres_exporter_docker_image_force_pull }}" - when: "matrix_prometheus_postgres_exporter_enabled | bool" - register: result - retries: "{{ devture_playbook_help_container_retries_count }}" - delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed - -- name: Ensure matrix-prometheus-postgres-exporter.service installed - ansible.builtin.template: - src: "{{ role_path }}/templates/systemd/matrix-prometheus-postgres-exporter.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-postgres-exporter.service" - mode: 0644 - register: matrix_prometheus_postgres_exporter_systemd_service_result - when: matrix_prometheus_postgres_exporter_enabled | bool - -- name: Ensure systemd reloaded after matrix-prometheus.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_prometheus_postgres_exporter_enabled | bool and matrix_prometheus_postgres_exporter_systemd_service_result.changed" - -# -# Tasks related to getting rid of matrix-prometheus-postgres-exporter (if it was previously enabled) -# - -- name: Check existence of matrix-prometheus-postgres-exporter service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-postgres-exporter.service" - register: matrix_prometheus_postgres_exporter_service_stat - -- name: Ensure matrix-prometheus-postgres-exporter is stopped - ansible.builtin.service: - name: matrix-prometheus-postgres-exporter - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_prometheus_postgres_exporter_enabled | bool and matrix_prometheus_postgres_exporter_service_stat.stat.exists" - -- name: Ensure matrix-prometheus-postgres-exporter.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-postgres-exporter.service" - state: absent - when: "not matrix_prometheus_postgres_exporter_enabled | bool and matrix_prometheus_postgres_exporter_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-prometheus-postgres-exporter.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_prometheus_postgres_exporter_enabled | bool and matrix_prometheus_postgres_exporter_service_stat.stat.exists" diff --git a/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup_install.yml b/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup_install.yml new file mode 100644 index 000000000..ee0f9bef7 --- /dev/null +++ b/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup_install.yml @@ -0,0 +1,19 @@ +--- + +- name: Ensure matrix-prometheus-postgres-exporter image is pulled + community.docker.docker_image: + name: "{{ matrix_prometheus_postgres_exporter_docker_image }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_prometheus_postgres_exporter_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_prometheus_postgres_exporter_docker_image_force_pull }}" + register: result + retries: "{{ devture_playbook_help_container_retries_count }}" + delay: "{{ devture_playbook_help_container_retries_delay }}" + until: result is not failed + +- name: Ensure matrix-prometheus-postgres-exporter.service installed + ansible.builtin.template: + src: "{{ role_path }}/templates/systemd/matrix-prometheus-postgres-exporter.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-postgres-exporter.service" + mode: 0644 + register: matrix_prometheus_postgres_exporter_systemd_service_result diff --git a/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup_uninstall.yml b/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup_uninstall.yml new file mode 100644 index 000000000..b3fdfd591 --- /dev/null +++ b/roles/custom/matrix-prometheus-postgres-exporter/tasks/setup_uninstall.yml @@ -0,0 +1,21 @@ +--- + +- name: Check existence of matrix-prometheus-postgres-exporter service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-postgres-exporter.service" + register: matrix_prometheus_postgres_exporter_service_stat + +- when: matrix_prometheus_postgres_exporter_service_stat.stat.exists | bool + block: + - name: Ensure matrix-prometheus-postgres-exporter is stopped + ansible.builtin.service: + name: matrix-prometheus-postgres-exporter + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-prometheus-postgres-exporter.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-postgres-exporter.service" + state: absent diff --git a/roles/custom/matrix-prometheus/tasks/main.yml b/roles/custom/matrix-prometheus/tasks/main.yml index 61cd86dbc..737f656b3 100644 --- a/roles/custom/matrix-prometheus/tasks/main.yml +++ b/roles/custom/matrix-prometheus/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_prometheus_enabled | bool" - tags: - - setup-all - - setup-prometheus +- block: + - when: matrix_prometheus_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_prometheus_enabled | bool" - tags: - - setup-all - - setup-prometheus + - when: matrix_prometheus_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_prometheus_enabled | bool" + - when: not matrix_prometheus_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-prometheus diff --git a/roles/custom/matrix-redis/tasks/main.yml b/roles/custom/matrix-redis/tasks/main.yml index 51b3e12cc..da2f1dcbc 100644 --- a/roles/custom/matrix-redis/tasks/main.yml +++ b/roles/custom/matrix-redis/tasks/main.yml @@ -1,7 +1,11 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_redis.yml" - when: run_setup | bool +- block: + - when: matrix_redis_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_redis_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-redis diff --git a/roles/custom/matrix-redis/tasks/setup_install.yml b/roles/custom/matrix-redis/tasks/setup_install.yml new file mode 100644 index 000000000..1384c042c --- /dev/null +++ b/roles/custom/matrix-redis/tasks/setup_install.yml @@ -0,0 +1,49 @@ +--- + +- name: Ensure redis Docker image is pulled + community.docker.docker_image: + name: "{{ matrix_redis_docker_image_to_use }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_redis_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_redis_docker_image_force_pull }}" + register: result + retries: "{{ devture_playbook_help_container_retries_count }}" + delay: "{{ devture_playbook_help_container_retries_delay }}" + until: result is not failed + +- name: Ensure redis paths exist + ansible.builtin.file: + path: "{{ item }}" + state: directory + mode: 0700 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + with_items: + - "{{ matrix_redis_base_path }}" + - "{{ matrix_redis_data_path }}" + +# We do this as a separate task, because: +# - we'd like to do it for the data path only, not for the base path (which contains root-owned environment variable files we'd like to leave as-is) +# - we need to do it without `mode`, or we risk making certain `.conf` and other files's executable bit to flip to true +- name: Ensure redis data path ownership is correct + ansible.builtin.file: + path: "{{ matrix_redis_data_path }}" + state: directory + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + recurse: true + +- name: Ensure redis environment variables file created + ansible.builtin.template: + src: "{{ role_path }}/templates/{{ item }}.j2" + dest: "{{ matrix_redis_base_path }}/{{ item }}" + mode: 0644 + with_items: + - "redis.conf" + +- name: Ensure matrix-redis.service installed + ansible.builtin.template: + src: "{{ role_path }}/templates/systemd/matrix-redis.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service" + mode: 0644 + register: matrix_redis_systemd_service_result diff --git a/roles/custom/matrix-redis/tasks/setup_redis.yml b/roles/custom/matrix-redis/tasks/setup_redis.yml deleted file mode 100644 index b1b4c0b5c..000000000 --- a/roles/custom/matrix-redis/tasks/setup_redis.yml +++ /dev/null @@ -1,104 +0,0 @@ ---- - -# -# Tasks related to setting up an internal redis server -# - -- name: Ensure redis Docker image is pulled - community.docker.docker_image: - name: "{{ matrix_redis_docker_image_to_use }}" - source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" - force_source: "{{ matrix_redis_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" - force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_redis_docker_image_force_pull }}" - when: matrix_redis_enabled | bool - register: result - retries: "{{ devture_playbook_help_container_retries_count }}" - delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed - -- name: Ensure redis paths exist - ansible.builtin.file: - path: "{{ item }}" - state: directory - mode: 0700 - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_username }}" - with_items: - - "{{ matrix_redis_base_path }}" - - "{{ matrix_redis_data_path }}" - when: matrix_redis_enabled | bool - -# We do this as a separate task, because: -# - we'd like to do it for the data path only, not for the base path (which contains root-owned environment variable files we'd like to leave as-is) -# - we need to do it without `mode`, or we risk making certain `.conf` and other files's executable bit to flip to true -- name: Ensure redis data path ownership is correct - ansible.builtin.file: - path: "{{ matrix_redis_data_path }}" - state: directory - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_username }}" - recurse: true - when: matrix_redis_enabled | bool - -- name: Ensure redis environment variables file created - ansible.builtin.template: - src: "{{ role_path }}/templates/{{ item }}.j2" - dest: "{{ matrix_redis_base_path }}/{{ item }}" - mode: 0644 - with_items: - - "redis.conf" - when: matrix_redis_enabled | bool - -- name: Ensure matrix-redis.service installed - ansible.builtin.template: - src: "{{ role_path }}/templates/systemd/matrix-redis.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service" - mode: 0644 - register: matrix_redis_systemd_service_result - when: matrix_redis_enabled | bool - -- name: Ensure systemd reloaded after matrix-redis.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_redis_enabled | bool and matrix_redis_systemd_service_result.changed" - -# -# Tasks related to getting rid of the internal redis server (if it was previously enabled) -# - -- name: Check existence of matrix-redis service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service" - register: matrix_redis_service_stat - when: "not matrix_redis_enabled | bool" - -- name: Ensure matrix-redis is stopped - ansible.builtin.service: - name: matrix-redis - state: stopped - enabled: false - daemon_reload: true - when: "not matrix_redis_enabled | bool and matrix_redis_service_stat.stat.exists" - -- name: Ensure matrix-redis.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service" - state: absent - when: "not matrix_redis_enabled | bool and matrix_redis_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-redis.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_redis_enabled | bool and matrix_redis_service_stat.stat.exists" - -- name: Check existence of matrix-redis local data path - ansible.builtin.stat: - path: "{{ matrix_redis_data_path }}" - register: matrix_redis_data_path_stat - when: "not matrix_redis_enabled | bool" - -# We just want to notify the user. Deleting data is too destructive. -- name: Notify if matrix-redis local data remains - ansible.builtin.debug: - msg: "Note: You are not using a local redis instance, but some old data remains from before in `{{ matrix_redis_data_path }}`. Feel free to delete it." - when: "not matrix_redis_enabled | bool and matrix_redis_data_path_stat.stat.exists" diff --git a/roles/custom/matrix-redis/tasks/setup_uninstall.yml b/roles/custom/matrix-redis/tasks/setup_uninstall.yml new file mode 100644 index 000000000..e2bbc9e44 --- /dev/null +++ b/roles/custom/matrix-redis/tasks/setup_uninstall.yml @@ -0,0 +1,31 @@ +--- + +- name: Check existence of matrix-redis service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service" + register: matrix_redis_service_stat + +- when: matrix_redis_service_stat.stat.exists | bool + block: + - name: Ensure matrix-redis is stopped + ansible.builtin.service: + name: matrix-redis + state: stopped + enabled: false + daemon_reload: true + + - name: Ensure matrix-redis.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service" + state: absent + +- name: Check existence of matrix-redis local data path + ansible.builtin.stat: + path: "{{ matrix_redis_data_path }}" + register: matrix_redis_data_path_stat + +# We just want to notify the user. Deleting data is too destructive. +- name: Notify if matrix-redis local data remains + ansible.builtin.debug: + msg: "Note: You are not using a local redis instance, but some old data remains from before in `{{ matrix_redis_data_path }}`. Feel free to delete it." + when: matrix_redis_data_path_stat.stat.exists | bool diff --git a/roles/custom/matrix-registration/tasks/main.yml b/roles/custom/matrix-registration/tasks/main.yml index 1b129b2c9..ee1101829 100644 --- a/roles/custom/matrix-registration/tasks/main.yml +++ b/roles/custom/matrix-registration/tasks/main.yml @@ -1,35 +1,33 @@ --- -- when: matrix_registration_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_registration_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: "run_setup | bool and matrix_registration_enabled | bool" +- block: + - when: matrix_registration_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_registration_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_registration_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-matrix-registration -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: "run_setup | bool and matrix_registration_enabled | bool" - tags: - - setup-all - - setup-matrix-registration - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: "run_setup | bool and not matrix_registration_enabled | bool" - tags: - - setup-all - - setup-matrix-registration - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/generate_token.yml" - when: "run_setup | bool and matrix_registration_enabled | bool" +- block: + - when: matrix_registration_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/generate_token.yml" tags: - generate-matrix-registration-token -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/list_tokens.yml" - when: "run_setup | bool and matrix_registration_enabled | bool" +- block: + - when: matrix_registration_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/list_tokens.yml" tags: - list-matrix-registration-tokens diff --git a/roles/custom/matrix-sygnal/tasks/main.yml b/roles/custom/matrix-sygnal/tasks/main.yml index fb25feed8..146774883 100644 --- a/roles/custom/matrix-sygnal/tasks/main.yml +++ b/roles/custom/matrix-sygnal/tasks/main.yml @@ -1,19 +1,14 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: run_setup | bool - tags: - - setup-all - - setup-sygnal +- block: + - when: matrix_sygnal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: run_setup | bool and matrix_sygnal_enabled | bool - tags: - - setup-all - - setup-sygnal + - when: matrix_sygnal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: run_setup | bool and not matrix_sygnal_enabled | bool + - when: not matrix_sygnal_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-sygnal diff --git a/roles/custom/matrix-synapse-admin/tasks/main.yml b/roles/custom/matrix-synapse-admin/tasks/main.yml index fed3dec64..632ec7836 100644 --- a/roles/custom/matrix-synapse-admin/tasks/main.yml +++ b/roles/custom/matrix-synapse-admin/tasks/main.yml @@ -1,18 +1,21 @@ --- -- when: matrix_synapse_admin_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_synapse_admin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-nginx-proxy -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: run_setup | bool - tags: - - setup-all - - setup-synapse-admin +- block: + - when: matrix_synapse_admin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml" + - when: matrix_synapse_admin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + + - when: not matrix_synapse_admin_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-synapse-admin diff --git a/roles/custom/matrix-synapse-admin/tasks/setup.yml b/roles/custom/matrix-synapse-admin/tasks/setup_install.yml similarity index 50% rename from roles/custom/matrix-synapse-admin/tasks/setup.yml rename to roles/custom/matrix-synapse-admin/tasks/setup_install.yml index 56cee4987..57e591486 100644 --- a/roles/custom/matrix-synapse-admin/tasks/setup.yml +++ b/roles/custom/matrix-synapse-admin/tasks/setup_install.yml @@ -1,16 +1,12 @@ --- -# -# Tasks related to setting up matrix-synapse-admin -# - - name: Ensure matrix-synapse-admin image is pulled community.docker.docker_image: name: "{{ matrix_synapse_admin_docker_image }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_synapse_admin_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_synapse_admin_docker_image_force_pull }}" - when: "matrix_synapse_admin_enabled | bool and not matrix_synapse_admin_container_image_self_build | bool" + when: not matrix_synapse_admin_container_image_self_build | bool register: result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" @@ -25,7 +21,7 @@ become: true become_user: "{{ matrix_user_username }}" register: matrix_synapse_admin_git_pull_results - when: "matrix_synapse_admin_enabled | bool and matrix_synapse_admin_container_image_self_build | bool" + when: matrix_synapse_admin_container_image_self_build | bool - name: Ensure matrix-synapse-admin Docker image is built community.docker.docker_image: @@ -37,7 +33,7 @@ dockerfile: Dockerfile path: "{{ matrix_synapse_admin_docker_src_files_path }}" pull: true - when: "matrix_synapse_admin_enabled | bool and matrix_synapse_admin_container_image_self_build | bool" + when: matrix_synapse_admin_container_image_self_build | bool - name: Ensure matrix-synapse-admin.service installed ansible.builtin.template: @@ -45,44 +41,3 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-admin.service" mode: 0644 register: matrix_synapse_admin_systemd_service_result - when: matrix_synapse_admin_enabled | bool - -- name: Ensure systemd reloaded after matrix-synapse-admin.service installation - ansible.builtin.service: - daemon_reload: true - when: "matrix_synapse_admin_enabled | bool and matrix_synapse_admin_systemd_service_result.changed" - -# -# Tasks related to getting rid of matrix-synapse-admin (if it was previously enabled) -# - -- name: Check existence of matrix-synapse-admin service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-admin.service" - register: matrix_synapse_admin_service_stat - -- name: Ensure matrix-synapse-admin is stopped - ansible.builtin.service: - name: matrix-synapse-admin - state: stopped - enabled: false - daemon_reload: true - register: stopping_result - when: "not matrix_synapse_admin_enabled | bool and matrix_synapse_admin_service_stat.stat.exists" - -- name: Ensure matrix-synapse-admin.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-admin.service" - state: absent - when: "not matrix_synapse_admin_enabled | bool and matrix_synapse_admin_service_stat.stat.exists" - -- name: Ensure systemd reloaded after matrix-synapse-admin.service removal - ansible.builtin.service: - daemon_reload: true - when: "not matrix_synapse_admin_enabled | bool and matrix_synapse_admin_service_stat.stat.exists" - -- name: Ensure matrix-synapse-admin Docker image doesn't exist - community.docker.docker_image: - name: "{{ matrix_synapse_admin_docker_image }}" - state: absent - when: "not matrix_synapse_admin_enabled | bool" diff --git a/roles/custom/matrix-synapse-admin/tasks/setup_uninstall.yml b/roles/custom/matrix-synapse-admin/tasks/setup_uninstall.yml new file mode 100644 index 000000000..96509874a --- /dev/null +++ b/roles/custom/matrix-synapse-admin/tasks/setup_uninstall.yml @@ -0,0 +1,27 @@ +--- + +- name: Check existence of matrix-synapse-admin service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-admin.service" + register: matrix_synapse_admin_service_stat + +- when: matrix_synapse_admin_service_stat.stat.exists | bool + block: + - name: Ensure matrix-synapse-admin is stopped + ansible.builtin.service: + name: matrix-synapse-admin + state: stopped + enabled: false + daemon_reload: true + register: stopping_result + + - name: Ensure matrix-synapse-admin.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-admin.service" + state: absent + + - name: Ensure matrix-synapse-admin Docker image doesn't exist + community.docker.docker_image: + name: "{{ matrix_synapse_admin_docker_image }}" + state: absent + when: "not matrix_synapse_admin_enabled | bool" diff --git a/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/main.yml b/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/main.yml index 65b2c0195..e07869d21 100644 --- a/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/main.yml +++ b/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/main.yml @@ -1,14 +1,11 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml" - when: run_setup | bool and matrix_synapse_reverse_proxy_companion_enabled | bool - tags: - - setup-all - - setup-synapse-reverse-proxy-companion - - setup-synapse +- block: + - when: matrix_synapse_reverse_proxy_companion_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - when: run_setup | bool and not matrix_synapse_reverse_proxy_companion_enabled | bool + - when: not matrix_synapse_reverse_proxy_companion_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-synapse-reverse-proxy-companion diff --git a/roles/custom/matrix-synapse/tasks/main.yml b/roles/custom/matrix-synapse/tasks/main.yml index 87c76ab79..1e9122167 100644 --- a/roles/custom/matrix-synapse/tasks/main.yml +++ b/roles/custom/matrix-synapse/tasks/main.yml @@ -1,7 +1,8 @@ --- -- when: matrix_synapse_enabled | bool - ansible.builtin.import_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml" tags: - setup-all - setup-synapse @@ -15,48 +16,48 @@ - stop-all - stop-group -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" - when: run_setup | bool and matrix_synapse_enabled | bool +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_synapse.yml" + + - when: not matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" tags: - setup-all - setup-synapse -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_synapse.yml" - when: run_setup | bool - tags: - - setup-all - - setup-synapse - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/import_media_store.yml" - when: run_synapse_import_media_store | bool +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/import_media_store.yml" tags: - import-synapse-media-store -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/register_user.yml" - when: run_synapse_register_user | bool and matrix_synapse_enabled | bool +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/register_user.yml" tags: - register-user -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_client_api.yml" - delegate_to: 127.0.0.1 - become: false - when: run_self_check | bool +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/update_user_password.yml" tags: - - self-check + - rust-synapse-compress-state -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_federation_api.yml" - delegate_to: 127.0.0.1 - become: false - when: run_self_check | bool - tags: - - self-check - -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/update_user_password.yml" - when: run_synapse_update_user_password | bool and matrix_synapse_enabled | bool +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/rust-synapse-compress-state/main.yml" tags: - update-user-password -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/rust-synapse-compress-state/main.yml" - when: run_synapse_rust_synapse_compress_state | bool +- block: + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_client_api.yml" + + - when: matrix_synapse_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_federation_api.yml" tags: - - rust-synapse-compress-state + - self-check diff --git a/roles/custom/matrix-synapse/tasks/self_check_client_api.yml b/roles/custom/matrix-synapse/tasks/self_check_client_api.yml index 1c03ba5b0..7ec3fb09b 100644 --- a/roles/custom/matrix-synapse/tasks/self_check_client_api.yml +++ b/roles/custom/matrix-synapse/tasks/self_check_client_api.yml @@ -9,6 +9,8 @@ ignore_errors: true check_mode: false when: matrix_synapse_enabled | bool + delegate_to: 127.0.0.1 + become: false - name: Fail if Matrix Client API not working ansible.builtin.fail: diff --git a/roles/custom/matrix-synapse/tasks/self_check_federation_api.yml b/roles/custom/matrix-synapse/tasks/self_check_federation_api.yml index 80ec4fc21..fde73dae0 100644 --- a/roles/custom/matrix-synapse/tasks/self_check_federation_api.yml +++ b/roles/custom/matrix-synapse/tasks/self_check_federation_api.yml @@ -9,6 +9,8 @@ ignore_errors: true check_mode: false when: matrix_synapse_enabled | bool + delegate_to: 127.0.0.1 + become: false - name: Fail if Matrix Federation API not working ansible.builtin.fail: diff --git a/roles/custom/matrix-user-creator/tasks/main.yml b/roles/custom/matrix-user-creator/tasks/main.yml index ba20504f7..2198b3ebf 100644 --- a/roles/custom/matrix-user-creator/tasks/main.yml +++ b/roles/custom/matrix-user-creator/tasks/main.yml @@ -1,7 +1,8 @@ --- -- when: matrix_user_creator_users | length > 0 - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml" +- block: + - when: matrix_user_creator_users | length > 0 + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup.yml" tags: # This role intentionally doesn't do work on a `setup-all` tag. # If it did, the initial installation (`--tags=setup-all`) would also potentially polute the database with data, diff --git a/roles/custom/matrix_playbook_migration/tasks/main.yml b/roles/custom/matrix_playbook_migration/tasks/main.yml index c346a759b..caa42bfdb 100644 --- a/roles/custom/matrix_playbook_migration/tasks/main.yml +++ b/roles/custom/matrix_playbook_migration/tasks/main.yml @@ -1,5 +1,6 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml" +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" tags: - setup-all