From 34cdaade08de7ea84ab62a44e82968b932f98f29 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 18 Jul 2022 10:39:08 +0300 Subject: [PATCH] Use fully-qualified module names for builtin Ansible modules Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/1939 --- roles/matrix-aux/tasks/setup.yml | 4 +- roles/matrix-backup-borg/tasks/init.yml | 2 +- .../tasks/setup_install.yml | 24 ++--- .../tasks/setup_uninstall.yml | 10 +-- .../tasks/validate_config.yml | 4 +- .../matrix-base/tasks/clean_up_old_files.yml | 2 +- roles/matrix-base/tasks/sanity_check.yml | 20 ++--- roles/matrix-base/tasks/server_base/setup.yml | 6 +- .../tasks/server_base/setup_debian.yml | 6 +- .../tasks/server_base/setup_fedora.yml | 6 +- .../tasks/server_base/setup_raspbian.yml | 6 +- .../tasks/server_base/setup_redhat.yml | 6 +- .../tasks/server_base/setup_redhat8.yml | 8 +- roles/matrix-base/tasks/setup_matrix_base.yml | 6 +- roles/matrix-base/tasks/setup_matrix_user.yml | 8 +- roles/matrix-base/tasks/setup_well_known.yml | 8 +- .../tasks/util/ensure_fuse_installed.yml | 4 +- .../tasks/util/ensure_openssl_installed.yml | 4 +- roles/matrix-bot-buscarron/tasks/init.yml | 2 +- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- roles/matrix-bot-go-neb/tasks/init.yml | 2 +- .../matrix-bot-go-neb/tasks/setup_install.yml | 12 +-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 4 +- roles/matrix-bot-honoroit/tasks/init.yml | 2 +- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 2 +- .../tasks/setup_install.yml | 12 +-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 2 +- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 4 +- roles/matrix-bot-mjolnir/tasks/init.yml | 4 +- .../tasks/setup_install.yml | 14 +-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 24 ++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 6 +- .../tasks/init.yml | 8 +- .../tasks/migrate_nedb_to_postgres.yml | 14 +-- .../tasks/setup_install.yml | 38 ++++---- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 6 +- .../tasks/init.yml | 18 ++-- .../tasks/migrate_nedb_to_postgres.yml | 14 +-- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 16 ++-- .../tasks/setup_install.yml | 16 ++-- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 4 +- .../tasks/setup_install.yml | 16 ++-- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 4 +- .../tasks/setup_install.yml | 28 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../matrix-bridge-heisenbridge/tasks/init.yml | 6 +- .../tasks/setup_install.yml | 8 +- .../tasks/setup_uninstall.yml | 6 +- roles/matrix-bridge-hookshot/tasks/init.yml | 18 ++-- .../tasks/setup_install.yml | 20 ++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 16 ++-- .../tasks/init.yml | 14 +-- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 14 +-- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 14 +-- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 14 +-- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 4 +- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 10 +-- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 14 +-- .../tasks/setup_install.yml | 28 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 4 +- .../tasks/setup_install.yml | 28 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 22 ++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 14 +-- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 6 +- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- .../tasks/init.yml | 14 +-- .../tasks/setup_install.yml | 26 +++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- roles/matrix-bridge-sms/tasks/init.yml | 6 +- .../matrix-bridge-sms/tasks/setup_install.yml | 12 +-- .../tasks/setup_uninstall.yml | 4 +- .../tasks/validate_config.yml | 2 +- roles/matrix-client-cinny/tasks/init.yml | 4 +- .../matrix-client-cinny/tasks/self_check.yml | 8 +- .../tasks/setup_install.yml | 12 +-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- roles/matrix-client-element/tasks/init.yml | 4 +- .../tasks/migrate_riot_web.yml | 8 +- .../tasks/prepare_themes.yml | 8 +- .../tasks/self_check.yml | 8 +- .../tasks/setup_install.yml | 18 ++-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 4 +- roles/matrix-client-hydrogen/tasks/init.yml | 4 +- .../tasks/self_check.yml | 8 +- .../tasks/setup_install.yml | 12 +-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- .../tasks/dump_runtime_results.yml | 2 +- .../tasks/run_docker_prune.yml | 2 +- roles/matrix-common-after/tasks/start.yml | 14 +-- roles/matrix-common-after/tasks/stop.yml | 2 +- roles/matrix-corporal/tasks/init.yml | 4 +- .../tasks/self_check_corporal.yml | 8 +- .../matrix-corporal/tasks/setup_corporal.yml | 18 ++-- .../matrix-corporal/tasks/validate_config.yml | 6 +- roles/matrix-coturn/tasks/init.yml | 6 +- roles/matrix-coturn/tasks/setup_install.yml | 18 ++-- roles/matrix-coturn/tasks/setup_uninstall.yml | 10 +-- roles/matrix-coturn/tasks/validate_config.yml | 2 +- .../tasks/dendrite/setup_install.yml | 14 +-- .../tasks/dendrite/setup_uninstall.yml | 6 +- roles/matrix-dendrite/tasks/init.yml | 2 +- roles/matrix-dendrite/tasks/main.yml | 2 +- roles/matrix-dendrite/tasks/register_user.yml | 8 +- .../tasks/self_check_client_api.yml | 6 +- .../tasks/self_check_federation_api.yml | 8 +- .../matrix-dendrite/tasks/setup_dendrite.yml | 2 +- .../matrix-dendrite/tasks/validate_config.yml | 4 +- roles/matrix-dimension/tasks/init.yml | 2 +- .../matrix-dimension/tasks/setup_install.yml | 22 ++--- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 4 +- roles/matrix-dynamic-dns/tasks/init.yml | 4 +- roles/matrix-dynamic-dns/tasks/install.yml | 10 +-- roles/matrix-dynamic-dns/tasks/uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- roles/matrix-email2matrix/tasks/init.yml | 2 +- .../tasks/setup_install.yml | 10 +-- .../tasks/setup_uninstall.yml | 8 +- .../tasks/validate_config.yml | 2 +- roles/matrix-etherpad/tasks/init.yml | 10 +-- roles/matrix-etherpad/tasks/setup_install.yml | 8 +- .../matrix-etherpad/tasks/setup_uninstall.yml | 8 +- .../matrix-etherpad/tasks/validate_config.yml | 4 +- roles/matrix-grafana/tasks/init.yml | 2 +- roles/matrix-grafana/tasks/setup.yml | 20 ++--- .../matrix-grafana/tasks/validate_config.yml | 2 +- roles/matrix-jitsi/tasks/init.yml | 4 +- roles/matrix-jitsi/tasks/setup_jitsi_base.yml | 2 +- .../matrix-jitsi/tasks/setup_jitsi_jicofo.yml | 18 ++-- roles/matrix-jitsi/tasks/setup_jitsi_jvb.yml | 18 ++-- .../tasks/setup_jitsi_prosody.yml | 18 ++-- roles/matrix-jitsi/tasks/setup_jitsi_web.yml | 18 ++-- .../tasks/util/setup_jitsi_auth.yml | 6 +- roles/matrix-jitsi/tasks/validate_config.yml | 6 +- roles/matrix-ma1sd/tasks/init.yml | 4 +- roles/matrix-ma1sd/tasks/migrate_mxisd.yml | 16 ++-- roles/matrix-ma1sd/tasks/self_check_ma1sd.yml | 8 +- roles/matrix-ma1sd/tasks/setup_install.yml | 30 +++---- roles/matrix-ma1sd/tasks/setup_uninstall.yml | 8 +- roles/matrix-ma1sd/tasks/validate_config.yml | 10 +-- roles/matrix-mailer/tasks/init.yml | 4 +- roles/matrix-mailer/tasks/setup_mailer.yml | 18 ++-- roles/matrix-nginx-proxy/tasks/init.yml | 4 +- roles/matrix-nginx-proxy/tasks/main.yml | 2 +- .../tasks/nginx-proxy/setup_metrics_auth.yml | 8 +- .../tasks/self_check_well_known.yml | 6 +- .../tasks/self_check_well_known_file.yml | 24 ++--- .../tasks/setup_nginx_proxy.yml | 88 +++++++++---------- .../tasks/setup_well_known.yml | 6 +- roles/matrix-nginx-proxy/tasks/ssl/main.yml | 6 +- .../tasks/ssl/setup_ssl_lets_encrypt.yml | 10 +-- ...tup_ssl_lets_encrypt_obtain_for_domain.yml | 14 +-- ...ssl_manually_managed_verify_for_domain.yml | 6 +- ...etup_ssl_self_signed_obtain_for_domain.yml | 8 +- .../tasks/validate_config.yml | 14 +-- roles/matrix-ntfy/tasks/init.yml | 2 +- roles/matrix-ntfy/tasks/self_check.yml | 8 +- roles/matrix-ntfy/tasks/setup_install.yml | 8 +- roles/matrix-ntfy/tasks/setup_uninstall.yml | 8 +- roles/matrix-postgres-backup/tasks/init.yml | 2 +- .../tasks/setup_postgres_backup.yml | 18 ++-- .../util/detect_existing_postgres_version.yml | 20 ++--- .../tasks/validate_config.yml | 2 +- .../tasks/import_generic_sqlite_db.yml | 22 ++--- .../matrix-postgres/tasks/import_postgres.yml | 22 ++--- .../tasks/import_synapse_sqlite_db.yml | 18 ++-- roles/matrix-postgres/tasks/init.yml | 2 +- .../tasks/migrate_postgres_data_directory.yml | 12 +-- roles/matrix-postgres/tasks/run_vacuum.yml | 26 +++--- .../matrix-postgres/tasks/setup_postgres.yml | 40 ++++----- .../tasks/upgrade_postgres.yml | 46 +++++----- .../tasks/util/create_additional_database.yml | 8 +- .../util/create_additional_databases.yml | 2 +- .../util/detect_existing_postgres_version.yml | 20 ++--- .../tasks/util/migrate_db_to_postgres.yml | 28 +++--- .../matrix-postgres/tasks/validate_config.yml | 8 +- .../tasks/init.yml | 8 +- .../tasks/setup.yml | 10 +-- .../tasks/init.yml | 8 +- .../tasks/setup.yml | 10 +-- roles/matrix-prometheus/tasks/init.yml | 2 +- .../matrix-prometheus/tasks/setup_install.yml | 10 +-- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 2 +- roles/matrix-redis/tasks/init.yml | 2 +- roles/matrix-redis/tasks/setup_redis.yml | 18 ++-- .../tasks/generate_token.yml | 10 +-- roles/matrix-registration/tasks/init.yml | 12 +-- .../matrix-registration/tasks/list_tokens.yml | 6 +- .../tasks/setup_install.yml | 20 ++--- .../tasks/setup_uninstall.yml | 6 +- .../tasks/validate_config.yml | 4 +- roles/matrix-sygnal/tasks/init.yml | 2 +- roles/matrix-sygnal/tasks/setup_install.yml | 8 +- roles/matrix-sygnal/tasks/setup_uninstall.yml | 8 +- roles/matrix-sygnal/tasks/validate_config.yml | 2 +- roles/matrix-synapse-admin/tasks/init.yml | 12 +-- roles/matrix-synapse-admin/tasks/setup.yml | 12 +-- .../tasks/validate_config.yml | 2 +- .../ext/encryption-disabler/setup_install.yml | 4 +- .../encryption-disabler/setup_uninstall.yml | 2 +- .../tasks/ext/ldap-auth/setup.yml | 2 +- .../ext/mjolnir-antispam/setup_install.yml | 8 +- .../ext/mjolnir-antispam/setup_uninstall.yml | 2 +- .../tasks/ext/rest-auth/setup_install.yml | 6 +- .../tasks/ext/rest-auth/setup_uninstall.yml | 2 +- .../ext/shared-secret-auth/setup_install.yml | 8 +- .../shared-secret-auth/setup_uninstall.yml | 2 +- .../synapse-simple-antispam/setup_install.yml | 10 +-- .../setup_uninstall.yml | 2 +- .../tasks/goofys/setup_install.yml | 8 +- .../tasks/goofys/setup_uninstall.yml | 8 +- .../tasks/import_media_store.yml | 16 ++-- roles/matrix-synapse/tasks/init.yml | 16 ++-- roles/matrix-synapse/tasks/main.yml | 2 +- roles/matrix-synapse/tasks/register_user.yml | 10 +-- .../compress_room.yml | 14 +-- .../rust-synapse-compress-state/main.yml | 26 +++--- .../tasks/self_check_client_api.yml | 6 +- .../tasks/self_check_federation_api.yml | 8 +- roles/matrix-synapse/tasks/setup_synapse.yml | 2 +- .../tasks/synapse/setup_install.yml | 22 ++--- .../tasks/synapse/setup_uninstall.yml | 8 +- .../tasks/synapse/workers/init.yml | 16 ++-- .../tasks/synapse/workers/setup.yml | 4 +- .../tasks/synapse/workers/setup_install.yml | 6 +- .../tasks/synapse/workers/setup_uninstall.yml | 6 +- .../inject_systemd_services_for_worker.yml | 6 +- .../workers/util/setup_files_for_worker.yml | 10 +-- .../tasks/update_user_password.yml | 14 +-- .../matrix-synapse/tasks/validate_config.yml | 10 +-- 297 files changed, 1420 insertions(+), 1420 deletions(-) diff --git a/roles/matrix-aux/tasks/setup.yml b/roles/matrix-aux/tasks/setup.yml index 949c0b4a..87c67d6d 100644 --- a/roles/matrix-aux/tasks/setup.yml +++ b/roles/matrix-aux/tasks/setup.yml @@ -1,7 +1,7 @@ --- - name: Ensure AUX directories are created - file: + ansible.builtin.file: dest: "{{ item.dest }}" state: directory owner: "{{ item.owner|default(matrix_user_username) }}" @@ -10,7 +10,7 @@ with_items: "{{ matrix_aux_directory_definitions }}" - name: Ensure AUX files are created - copy: + ansible.builtin.copy: dest: "{{ item.dest }}" content: "{{ item.content }}" owner: "{{ item.owner|default(matrix_user_username) }}" diff --git a/roles/matrix-backup-borg/tasks/init.yml b/roles/matrix-backup-borg/tasks/init.yml index a82fb7b8..4d853a82 100644 --- a/roles/matrix-backup-borg/tasks/init.yml +++ b/roles/matrix-backup-borg/tasks/init.yml @@ -1,4 +1,4 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-backup-borg.timer'] }}" when: matrix_backup_borg_enabled|bool diff --git a/roles/matrix-backup-borg/tasks/setup_install.yml b/roles/matrix-backup-borg/tasks/setup_install.yml index 6ef39863..c8cf7f24 100644 --- a/roles/matrix-backup-borg/tasks/setup_install.yml +++ b/roles/matrix-backup-borg/tasks/setup_install.yml @@ -3,17 +3,17 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/detect_existing_postgres_version.yml" - name: Fail if detected Postgres version is unsupported - fail: + ansible.builtin.fail: msg: "You cannot use borg backup with such an old version ({{ matrix_postgres_detected_version }}) of Postgres. Consider upgrading - link to docs for upgrading Postgres: docs/maintenance-postgres.md#upgrading-postgresql" when: "matrix_postgres_detected_version not in matrix_backup_borg_supported_postgres_versions" - name: Set the correct borg backup version to use - set_fact: + ansible.builtin.set_fact: matrix_backup_borg_version: "{{ matrix_postgres_detected_version }}" when: matrix_backup_borg_postgresql_enabled|bool and matrix_backup_borg_version == '' - name: Ensure borg paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -25,7 +25,7 @@ when: "item.when|bool" - name: Ensure borgmatic config is created - copy: + ansible.builtin.copy: content: "{{ matrix_backup_borg_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_backup_borg_config_path }}/config.yaml" owner: "{{ matrix_user_username }}" @@ -33,7 +33,7 @@ mode: 0640 - name: Ensure borg passwd is created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/passwd.j2" dest: "{{ matrix_backup_borg_config_path }}/passwd" owner: "{{ matrix_user_username }}" @@ -41,7 +41,7 @@ mode: 0640 - name: Ensure borg ssh key is created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/sshkey.j2" dest: "{{ matrix_backup_borg_config_path }}/sshkey" owner: "{{ matrix_user_username }}" @@ -61,7 +61,7 @@ until: result is not failed - name: Ensure borg repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_backup_borg_docker_repo }}" dest: "{{ matrix_backup_borg_docker_src_files_path }}" force: "yes" @@ -83,30 +83,30 @@ when: "matrix_backup_borg_container_image_self_build|bool" - name: Ensure matrix-backup-borg.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-backup-borg.service.j2" dest: "{{ matrix_systemd_path }}/matrix-backup-borg.service" mode: 0644 register: matrix_backup_borg_systemd_service_result - name: Ensure matrix-backup-borg.timer installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-backup-borg.timer.j2" dest: "{{ matrix_systemd_path }}/matrix-backup-borg.timer" mode: 0644 register: matrix_backup_borg_systemd_timer_result - name: Ensure systemd reloaded after matrix-backup-borg.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_backup_borg_systemd_service_result.changed|bool" - name: Ensure matrix-backup-borg.service enabled - service: + ansible.builtin.service: enabled: true name: matrix-backup-borg.service - name: Ensure matrix-backup-borg.timer enabled - service: + ansible.builtin.service: enabled: true name: matrix-backup-borg.timer diff --git a/roles/matrix-backup-borg/tasks/setup_uninstall.yml b/roles/matrix-backup-borg/tasks/setup_uninstall.yml index faad44f7..faed21f8 100644 --- a/roles/matrix-backup-borg/tasks/setup_uninstall.yml +++ b/roles/matrix-backup-borg/tasks/setup_uninstall.yml @@ -5,7 +5,7 @@ register: matrix_backup_borg_service_stat - name: Ensure matrix-backup-borg is stopped - service: + ansible.builtin.service: name: matrix-backup-borg state: stopped enabled: false @@ -14,24 +14,24 @@ when: "matrix_backup_borg_service_stat.stat.exists|bool" - name: Ensure matrix-backup-borg.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-backup-borg.service" state: absent when: "matrix_backup_borg_service_stat.stat.exists|bool" - name: Ensure matrix-backup-borg.timer doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-backup-borg.timer" state: absent when: "matrix_backup_borg_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-backup-borg.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_backup_borg_service_stat.stat.exists|bool" - name: Ensure Matrix borg paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_backup_borg_base_path }}" state: absent diff --git a/roles/matrix-backup-borg/tasks/validate_config.yml b/roles/matrix-backup-borg/tasks/validate_config.yml index 84b78d1e..66e487dd 100644 --- a/roles/matrix-backup-borg/tasks/validate_config.yml +++ b/roles/matrix-backup-borg/tasks/validate_config.yml @@ -1,6 +1,6 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -9,7 +9,7 @@ - "matrix_backup_borg_location_repositories" - name: Fail if encryption passphrase is undefined unless repository is unencrypted - fail: + ansible.builtin.fail: msg: >- You need to define a required passphrase using the `matrix_backup_borg_storage_encryption_passphrase` variable. when: "matrix_backup_borg_storage_encryption_passphrase == '' and matrix_backup_borg_encryption != 'none'" diff --git a/roles/matrix-base/tasks/clean_up_old_files.yml b/roles/matrix-base/tasks/clean_up_old_files.yml index 03eb8bcc..b79c01b3 100644 --- a/roles/matrix-base/tasks/clean_up_old_files.yml +++ b/roles/matrix-base/tasks/clean_up_old_files.yml @@ -1,7 +1,7 @@ --- - name: Get rid of old files and directories - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: diff --git a/roles/matrix-base/tasks/sanity_check.yml b/roles/matrix-base/tasks/sanity_check.yml index 98fa2738..29ae8419 100644 --- a/roles/matrix-base/tasks/sanity_check.yml +++ b/roles/matrix-base/tasks/sanity_check.yml @@ -1,27 +1,27 @@ --- - name: Fail if invalid homeserver implementation - fail: + ansible.builtin.fail: msg: "You need to set a valid homeserver implementation in `matrix_homeserver_implementation`" when: "matrix_homeserver_implementation not in ['synapse', 'dendrite']" # We generally support Ansible 2.7.1 and above. - name: Fail if running on Ansible < 2.7.1 - fail: + ansible.builtin.fail: msg: "You are running on Ansible {{ ansible_version.string }}, which is not supported. See our guide about Ansible: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/ansible.md" when: - "(ansible_version.major < 2) or (ansible_version.major == 2 and ansible_version.minor < 7) or (ansible_version.major == 2 and ansible_version.minor == 7 and ansible_version.revision < 1)" # Though we do not support Ansible 2.9.6 which is buggy - name: Fail if running on Ansible 2.9.6 on Ubuntu - fail: + ansible.builtin.fail: msg: "You are running on Ansible {{ ansible_version.string }}, which is not supported. See our guide about Ansible: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/ansible.md" when: - ansible_distribution == 'Ubuntu' - "ansible_version.major == 2 and ansible_version.minor == 9 and ansible_version.revision == 6" - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). @@ -35,7 +35,7 @@ # We have a dedicated check for this variable, because we'd like to have a custom (friendlier) message. - name: Fail if matrix_homeserver_generic_secret_key is undefined - fail: + ansible.builtin.fail: msg: | The `matrix_homeserver_generic_secret_key` variable must be defined and have a non-null and non-empty value. @@ -47,7 +47,7 @@ when: "matrix_homeserver_generic_secret_key is none or matrix_homeserver_generic_secret_key == ''" - name: Fail if required variables are undefined - fail: + ansible.builtin.fail: msg: "The `{{ item.var }}` variable must be defined and have a non-null and non-empty value" with_items: - {'var': matrix_domain, 'value': "{{ matrix_domain|default('') }}"} @@ -58,7 +58,7 @@ when: "item.value is none or item.value == ''" - name: Fail if uppercase domain used - fail: + ansible.builtin.fail: msg: "Detected that you're using an uppercase domain name - `{{ item }}`. This will cause trouble. Please use all-lowercase!" with_items: - "{{ matrix_domain }}" @@ -67,21 +67,21 @@ when: "item != item|lower" - name: Fail if using python2 on Archlinux - fail: + ansible.builtin.fail: msg: "Detected that you're using python2 when installing onto Archlinux. Archlinux by default only supports python3." when: - ansible_distribution == 'Archlinux' - ansible_python.version.major != 3 - name: Fail if architecture is set incorrectly - fail: + ansible.builtin.fail: msg: "Detected that variable matrix_architecture {{ matrix_architecture }} appears to be set incorrectly. See docs/alternative-architectures.md. Server appears to be {{ ansible_architecture }}." when: (ansible_architecture == "x86_64" and matrix_architecture != "amd64") or (ansible_architecture == "aarch64" and matrix_architecture != "arm64") or (ansible_architecture.startswith("armv") and matrix_architecture != "arm32") - name: Fail if encountering usage of removed role (mx-puppet-skype) - fail: + ansible.builtin.fail: msg: >- Your configuration seems to include a reference to `matrix_mx_puppet_skype_enabled`. Are you trying to install the mx-puppet-skype bridge? The playbook no longer includes a role for installing mx-puppet-skype, because the mx-puppet-bridge is unmaintained and has been reported as broken for a long time. diff --git a/roles/matrix-base/tasks/server_base/setup.yml b/roles/matrix-base/tasks/server_base/setup.yml index bbfa077c..c5145e55 100644 --- a/roles/matrix-base/tasks/server_base/setup.yml +++ b/roles/matrix-base/tasks/server_base/setup.yml @@ -12,7 +12,7 @@ - block: # ansible_lsb is only available if lsb-release is installed. - name: Ensure lsb-release installed - apt: + ansible.builtin.apt: name: - lsb-release state: present @@ -34,13 +34,13 @@ when: ansible_distribution == 'Archlinux' - name: Ensure Docker is started and autoruns - service: + ansible.builtin.service: name: docker state: started enabled: true - name: "Ensure {{ matrix_ntpd_service }} is started and autoruns" - service: + ansible.builtin.service: name: "{{ matrix_ntpd_service }}" state: started enabled: true diff --git a/roles/matrix-base/tasks/server_base/setup_debian.yml b/roles/matrix-base/tasks/server_base/setup_debian.yml index 5b169df7..a45cd377 100644 --- a/roles/matrix-base/tasks/server_base/setup_debian.yml +++ b/roles/matrix-base/tasks/server_base/setup_debian.yml @@ -1,7 +1,7 @@ --- - name: Ensure APT usage dependencies are installed - apt: + ansible.builtin.apt: name: - apt-transport-https - ca-certificates @@ -26,14 +26,14 @@ when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce' - name: Ensure APT packages are installed - apt: + ansible.builtin.apt: name: - "{{ matrix_ntpd_package }}" state: latest update_cache: true - name: Ensure Docker is installed - apt: + ansible.builtin.apt: name: - "{{ matrix_docker_package_name }}" - "python{{'3' if ansible_python.version.major == 3 else ''}}-docker" diff --git a/roles/matrix-base/tasks/server_base/setup_fedora.yml b/roles/matrix-base/tasks/server_base/setup_fedora.yml index 7369b6ad..c83d8844 100644 --- a/roles/matrix-base/tasks/server_base/setup_fedora.yml +++ b/roles/matrix-base/tasks/server_base/setup_fedora.yml @@ -1,7 +1,7 @@ --- - name: Ensure Docker repository is enabled - template: + ansible.builtin.template: src: "{{ role_path }}/files/yum.repos.d/{{ item }}" dest: "/etc/yum.repos.d/docker-ce.repo" owner: "root" @@ -18,14 +18,14 @@ when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce' - name: Ensure yum packages are installed - yum: + ansible.builtin.yum: name: - "{{ matrix_ntpd_package }}" state: latest update_cache: true - name: Ensure Docker is installed - yum: + ansible.builtin.yum: name: - "{{ matrix_docker_package_name }}" - python3-pip diff --git a/roles/matrix-base/tasks/server_base/setup_raspbian.yml b/roles/matrix-base/tasks/server_base/setup_raspbian.yml index 6a09f2fe..e3406ed5 100644 --- a/roles/matrix-base/tasks/server_base/setup_raspbian.yml +++ b/roles/matrix-base/tasks/server_base/setup_raspbian.yml @@ -1,7 +1,7 @@ --- - name: Ensure APT usage dependencies are installed - apt: + ansible.builtin.apt: name: - apt-transport-https - ca-certificates @@ -26,14 +26,14 @@ when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce' - name: Ensure APT packages are installed - apt: + ansible.builtin.apt: name: - "{{ matrix_ntpd_package }}" state: latest update_cache: true - name: Ensure Docker is installed - apt: + ansible.builtin.apt: name: - "{{ matrix_docker_package_name }}" - "python{{'3' if ansible_python.version.major == 3 else ''}}-docker" diff --git a/roles/matrix-base/tasks/server_base/setup_redhat.yml b/roles/matrix-base/tasks/server_base/setup_redhat.yml index b4be1d08..88061c71 100644 --- a/roles/matrix-base/tasks/server_base/setup_redhat.yml +++ b/roles/matrix-base/tasks/server_base/setup_redhat.yml @@ -1,7 +1,7 @@ --- - name: Ensure Docker repository is enabled - template: + ansible.builtin.template: src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo" dest: "/etc/yum.repos.d/docker-ce.repo" owner: "root" @@ -16,14 +16,14 @@ when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce' - name: Ensure yum packages are installed - yum: + ansible.builtin.yum: name: - "{{ matrix_ntpd_package }}" state: latest update_cache: true - name: Ensure Docker is installed - yum: + ansible.builtin.yum: name: - "{{ matrix_docker_package_name }}" - docker-python diff --git a/roles/matrix-base/tasks/server_base/setup_redhat8.yml b/roles/matrix-base/tasks/server_base/setup_redhat8.yml index d9dd6e23..d2eca681 100644 --- a/roles/matrix-base/tasks/server_base/setup_redhat8.yml +++ b/roles/matrix-base/tasks/server_base/setup_redhat8.yml @@ -1,7 +1,7 @@ --- - name: Ensure Docker repository is enabled - template: + ansible.builtin.template: src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo" dest: "/etc/yum.repos.d/docker-ce.repo" owner: "root" @@ -16,21 +16,21 @@ when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce' - name: Ensure EPEL is installed - yum: + ansible.builtin.yum: name: - epel-release state: latest update_cache: true - name: Ensure yum packages are installed - yum: + ansible.builtin.yum: name: - "{{ matrix_ntpd_package }}" state: latest update_cache: true - name: Ensure Docker is installed - yum: + ansible.builtin.yum: name: - "{{ matrix_docker_package_name }}" - python3-pip diff --git a/roles/matrix-base/tasks/setup_matrix_base.yml b/roles/matrix-base/tasks/setup_matrix_base.yml index 0fad2b3d..100b7e7c 100644 --- a/roles/matrix-base/tasks/setup_matrix_base.yml +++ b/roles/matrix-base/tasks/setup_matrix_base.yml @@ -1,7 +1,7 @@ --- - name: Ensure Matrix base path exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: "{{ matrix_base_data_path_mode }}" @@ -11,7 +11,7 @@ - "{{ matrix_base_data_path }}" - name: Preserve vars.yml on the server for easily restoring if it gets lost later on - copy: + ansible.builtin.copy: src: "{{ matrix_vars_yml_snapshotting_src }}" dest: "{{ matrix_base_data_path }}/vars.yml" owner: "{{ matrix_user_username }}" @@ -25,7 +25,7 @@ driver: bridge - name: Ensure matrix-remove-all script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2" dest: "{{ matrix_local_bin_path }}/matrix-remove-all" mode: 0750 diff --git a/roles/matrix-base/tasks/setup_matrix_user.yml b/roles/matrix-base/tasks/setup_matrix_user.yml index 41604f87..0435b7a3 100644 --- a/roles/matrix-base/tasks/setup_matrix_user.yml +++ b/roles/matrix-base/tasks/setup_matrix_user.yml @@ -1,18 +1,18 @@ --- - name: Ensure Matrix group is created - group: + ansible.builtin.group: name: "{{ matrix_user_groupname }}" gid: "{{ omit if matrix_user_gid is none else matrix_user_gid }}" state: present register: matrix_group - name: Set Matrix Group GID Variable - set_fact: + ansible.builtin.set_fact: matrix_user_gid: "{{ matrix_group.gid }}" - name: Ensure Matrix user is created - user: + ansible.builtin.user: name: "{{ matrix_user_username }}" uid: "{{ omit if matrix_user_uid is none else matrix_user_uid }}" state: present @@ -23,5 +23,5 @@ register: matrix_user - name: Set Matrix Group UID Variable - set_fact: + ansible.builtin.set_fact: matrix_user_uid: "{{ matrix_user.uid }}" diff --git a/roles/matrix-base/tasks/setup_well_known.yml b/roles/matrix-base/tasks/setup_well_known.yml index da9b534f..c4a5c236 100644 --- a/roles/matrix-base/tasks/setup_well_known.yml +++ b/roles/matrix-base/tasks/setup_well_known.yml @@ -4,7 +4,7 @@ # # For running with another webserver, we recommend being part of the `matrix` group. - name: Ensure Matrix static-files path exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0755 @@ -14,7 +14,7 @@ - "{{ matrix_static_files_base_path }}/.well-known/matrix" - name: Ensure Matrix /.well-known/matrix/client file configured - copy: + ansible.builtin.copy: content: "{{ matrix_well_known_matrix_client_configuration|to_nice_json }}" dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/client" mode: 0644 @@ -22,7 +22,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure Matrix /.well-known/matrix/server file configured - copy: + ansible.builtin.copy: content: "{{ matrix_well_known_matrix_server_configuration|to_nice_json }}" dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/server" mode: 0644 @@ -31,7 +31,7 @@ when: matrix_well_known_matrix_server_enabled|bool - name: Ensure Matrix /.well-known/matrix/server file deleted - file: + ansible.builtin.file: path: "{{ matrix_static_files_base_path }}/.well-known/matrix/server" state: absent when: "not matrix_well_known_matrix_server_enabled|bool" diff --git a/roles/matrix-base/tasks/util/ensure_fuse_installed.yml b/roles/matrix-base/tasks/util/ensure_fuse_installed.yml index 7a3fde41..dfb1ddc8 100644 --- a/roles/matrix-base/tasks/util/ensure_fuse_installed.yml +++ b/roles/matrix-base/tasks/util/ensure_fuse_installed.yml @@ -1,7 +1,7 @@ --- # This is for both RedHat 7 and 8 - name: Ensure fuse installed (RedHat) - yum: + ansible.builtin.yum: name: - fuse state: latest @@ -9,7 +9,7 @@ # This is for both Debian and Raspbian - name: Ensure fuse installed (Debian/Raspbian) - apt: + ansible.builtin.apt: name: - fuse state: latest diff --git a/roles/matrix-base/tasks/util/ensure_openssl_installed.yml b/roles/matrix-base/tasks/util/ensure_openssl_installed.yml index 53fc9b03..909c0f1c 100644 --- a/roles/matrix-base/tasks/util/ensure_openssl_installed.yml +++ b/roles/matrix-base/tasks/util/ensure_openssl_installed.yml @@ -1,7 +1,7 @@ --- # This is for both RedHat 7 and 8 - name: Ensure openssl installed (RedHat) - yum: + ansible.builtin.yum: name: - openssl state: latest @@ -9,7 +9,7 @@ # This is for both Debian and Raspbian - name: Ensure openssl installed (Debian/Raspbian) - apt: + ansible.builtin.apt: name: - openssl state: latest diff --git a/roles/matrix-bot-buscarron/tasks/init.yml b/roles/matrix-bot-buscarron/tasks/init.yml index 3da32948..37c0932e 100644 --- a/roles/matrix-bot-buscarron/tasks/init.yml +++ b/roles/matrix-bot-buscarron/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-buscarron.service'] }}" when: matrix_bot_buscarron_enabled|bool diff --git a/roles/matrix-bot-buscarron/tasks/setup_install.yml b/roles/matrix-bot-buscarron/tasks/setup_install.yml index 0ebe7e42..6559a95a 100644 --- a/roles/matrix-bot-buscarron/tasks/setup_install.yml +++ b/roles/matrix-bot-buscarron/tasks/setup_install.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_bot_buscarron_requires_restart: false - block: @@ -9,7 +9,7 @@ register: matrix_bot_buscarron_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_bot_buscarron_sqlite_database_path_local }}" dst: "{{ matrix_bot_buscarron_database_connection_string }}" @@ -20,13 +20,13 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_bot_buscarron_requires_restart: true when: "matrix_bot_buscarron_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_bot_buscarron_database_engine == 'postgres'" - name: Ensure buscarron paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -40,7 +40,7 @@ when: "item.when|bool" - name: Ensure buscarron environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/env.j2" dest: "{{ matrix_bot_buscarron_config_path }}/env" owner: "{{ matrix_user_username }}" @@ -60,7 +60,7 @@ until: result is not failed - name: Ensure buscarron repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_bot_buscarron_docker_repo }}" dest: "{{ matrix_bot_buscarron_docker_src_files_path }}" force: "yes" @@ -82,19 +82,19 @@ when: "matrix_bot_buscarron_container_image_self_build|bool" - name: Ensure matrix-bot-buscarron.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-bot-buscarron.service.j2" dest: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service" mode: 0644 register: matrix_bot_buscarron_systemd_service_result - name: Ensure systemd reloaded after matrix-bot-buscarron.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_buscarron_systemd_service_result.changed|bool" - name: Ensure matrix-bot-buscarron.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-bot-buscarron.service" state: restarted when: "matrix_bot_buscarron_requires_restart|bool" diff --git a/roles/matrix-bot-buscarron/tasks/setup_uninstall.yml b/roles/matrix-bot-buscarron/tasks/setup_uninstall.yml index cc70e79a..5dd26653 100644 --- a/roles/matrix-bot-buscarron/tasks/setup_uninstall.yml +++ b/roles/matrix-bot-buscarron/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_bot_buscarron_service_stat - name: Ensure matrix-buscarron is stopped - service: + ansible.builtin.service: name: matrix-bot-buscarron state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_bot_buscarron_service_stat.stat.exists|bool" - name: Ensure matrix-bot-buscarron.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service" state: absent when: "matrix_bot_buscarron_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-bot-buscarron.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_buscarron_service_stat.stat.exists|bool" - name: Ensure Matrix buscarron paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_bot_buscarron_base_path }}" state: absent diff --git a/roles/matrix-bot-buscarron/tasks/validate_config.yml b/roles/matrix-bot-buscarron/tasks/validate_config.yml index 5a517d39..04238012 100644 --- a/roles/matrix-bot-buscarron/tasks/validate_config.yml +++ b/roles/matrix-bot-buscarron/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bot-go-neb/tasks/init.yml b/roles/matrix-bot-go-neb/tasks/init.yml index b046d494..a1b57ec6 100644 --- a/roles/matrix-bot-go-neb/tasks/init.yml +++ b/roles/matrix-bot-go-neb/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-go-neb.service'] }}" when: matrix_bot_go_neb_enabled|bool diff --git a/roles/matrix-bot-go-neb/tasks/setup_install.yml b/roles/matrix-bot-go-neb/tasks/setup_install.yml index ef2dfbb0..71d5168a 100644 --- a/roles/matrix-bot-go-neb/tasks/setup_install.yml +++ b/roles/matrix-bot-go-neb/tasks/setup_install.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_bot_go_neb_requires_restart: false - name: Ensure go-neb paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ until: result is not failed - name: Ensure go-neb config installed - copy: + ansible.builtin.copy: content: "{{ matrix_bot_go_neb_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_bot_go_neb_config_path }}/config.yaml" mode: 0644 @@ -36,19 +36,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-bot-go-neb.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-bot-go-neb.service.j2" dest: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service" mode: 0644 register: matrix_bot_go_neb_systemd_service_result - name: Ensure systemd reloaded after matrix-bot-go-neb.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_go_neb_systemd_service_result.changed|bool" - name: Ensure matrix-bot-go-neb.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-bot-go-neb.service" state: restarted when: "matrix_bot_go_neb_requires_restart|bool" diff --git a/roles/matrix-bot-go-neb/tasks/setup_uninstall.yml b/roles/matrix-bot-go-neb/tasks/setup_uninstall.yml index a009badf..d27377c1 100644 --- a/roles/matrix-bot-go-neb/tasks/setup_uninstall.yml +++ b/roles/matrix-bot-go-neb/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_bot_go_neb_service_stat - name: Ensure matrix-go-neb is stopped - service: + ansible.builtin.service: name: matrix-bot-go-neb state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_bot_go_neb_service_stat.stat.exists|bool" - name: Ensure matrix-bot-go-neb.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service" state: absent when: "matrix_bot_go_neb_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-bot-go-neb.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_go_neb_service_stat.stat.exists|bool" - name: Ensure Matrix go-neb paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_bot_go_neb_base_path }}" state: absent diff --git a/roles/matrix-bot-go-neb/tasks/validate_config.yml b/roles/matrix-bot-go-neb/tasks/validate_config.yml index 7b292250..72bc3cb4 100644 --- a/roles/matrix-bot-go-neb/tasks/validate_config.yml +++ b/roles/matrix-bot-go-neb/tasks/validate_config.yml @@ -1,13 +1,13 @@ --- - name: Fail if there's not at least 1 client - fail: + ansible.builtin.fail: msg: >- You need at least 1 client in the matrix_bot_go_neb_clients block. when: matrix_bot_go_neb_clients is not defined or matrix_bot_go_neb_clients[0] is not defined - name: Fail if there's not at least 1 service - fail: + ansible.builtin.fail: msg: >- You need at least 1 service in the matrix_bot_go_neb_services block. when: matrix_bot_go_neb_services is not defined or matrix_bot_go_neb_services[0] is not defined diff --git a/roles/matrix-bot-honoroit/tasks/init.yml b/roles/matrix-bot-honoroit/tasks/init.yml index 5ace015b..2a5ea4d7 100644 --- a/roles/matrix-bot-honoroit/tasks/init.yml +++ b/roles/matrix-bot-honoroit/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-honoroit.service'] }}" when: matrix_bot_honoroit_enabled|bool diff --git a/roles/matrix-bot-honoroit/tasks/setup_install.yml b/roles/matrix-bot-honoroit/tasks/setup_install.yml index 584df9b7..2f7bb9a4 100644 --- a/roles/matrix-bot-honoroit/tasks/setup_install.yml +++ b/roles/matrix-bot-honoroit/tasks/setup_install.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_bot_honoroit_requires_restart: false - block: @@ -9,7 +9,7 @@ register: matrix_bot_honoroit_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}" dst: "{{ matrix_bot_honoroit_database_connection_string }}" @@ -20,13 +20,13 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_bot_honoroit_requires_restart: true when: "matrix_bot_honoroit_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_bot_honoroit_database_engine == 'postgres'" - name: Ensure honoroit paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -40,7 +40,7 @@ when: "item.when|bool" - name: Ensure honoroit environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/env.j2" dest: "{{ matrix_bot_honoroit_config_path }}/env" owner: "{{ matrix_user_username }}" @@ -60,7 +60,7 @@ until: result is not failed - name: Ensure honoroit repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_bot_honoroit_docker_repo }}" dest: "{{ matrix_bot_honoroit_docker_src_files_path }}" force: "yes" @@ -82,19 +82,19 @@ when: "matrix_bot_honoroit_container_image_self_build|bool" - name: Ensure matrix-bot-honoroit.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2" dest: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service" mode: 0644 register: matrix_bot_honoroit_systemd_service_result - name: Ensure systemd reloaded after matrix-bot-honoroit.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_honoroit_systemd_service_result.changed|bool" - name: Ensure matrix-bot-honoroit.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-bot-honoroit.service" state: restarted when: "matrix_bot_honoroit_requires_restart|bool" diff --git a/roles/matrix-bot-honoroit/tasks/setup_uninstall.yml b/roles/matrix-bot-honoroit/tasks/setup_uninstall.yml index 45bccabd..7bb6b8f1 100644 --- a/roles/matrix-bot-honoroit/tasks/setup_uninstall.yml +++ b/roles/matrix-bot-honoroit/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_bot_honoroit_service_stat - name: Ensure matrix-honoroit is stopped - service: + ansible.builtin.service: name: matrix-bot-honoroit state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_bot_honoroit_service_stat.stat.exists|bool" - name: Ensure matrix-bot-honoroit.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service" state: absent when: "matrix_bot_honoroit_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-bot-honoroit.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_honoroit_service_stat.stat.exists|bool" - name: Ensure Matrix honoroit paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_bot_honoroit_base_path }}" state: absent diff --git a/roles/matrix-bot-honoroit/tasks/validate_config.yml b/roles/matrix-bot-honoroit/tasks/validate_config.yml index 562bf9fb..0057e3c2 100644 --- a/roles/matrix-bot-honoroit/tasks/validate_config.yml +++ b/roles/matrix-bot-honoroit/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bot-matrix-registration-bot/tasks/init.yml b/roles/matrix-bot-matrix-registration-bot/tasks/init.yml index 03235b80..c3988eb2 100644 --- a/roles/matrix-bot-matrix-registration-bot/tasks/init.yml +++ b/roles/matrix-bot-matrix-registration-bot/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-registration-bot.service'] }}" when: matrix_bot_matrix_registration_bot_enabled|bool diff --git a/roles/matrix-bot-matrix-registration-bot/tasks/setup_install.yml b/roles/matrix-bot-matrix-registration-bot/tasks/setup_install.yml index 716d67bc..6fd17ee8 100644 --- a/roles/matrix-bot-matrix-registration-bot/tasks/setup_install.yml +++ b/roles/matrix-bot-matrix-registration-bot/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure matrix-registration-bot paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -14,7 +14,7 @@ when: "item.when|bool" - name: Ensure matrix-registration-bot configuration file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/config/config.yml.j2" dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/config.yml" owner: "{{ matrix_user_username }}" @@ -34,7 +34,7 @@ until: result is not failed - name: Ensure matrix-registration-bot repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_bot_matrix_registration_bot_docker_repo }}" dest: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}" force: "yes" @@ -56,18 +56,18 @@ when: "matrix_bot_matrix_registration_bot_container_image_self_build|bool" - name: Ensure matrix-bot-matrix-registration-bot.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2" dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service" mode: 0644 register: matrix_bot_matrix_registration_bot_systemd_service_result - name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_matrix_registration_bot_systemd_service_result.changed|bool" - name: Ensure matrix-bot-matrix-registration-bot.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-bot-matrix-registration-bot.service" state: restarted diff --git a/roles/matrix-bot-matrix-registration-bot/tasks/setup_uninstall.yml b/roles/matrix-bot-matrix-registration-bot/tasks/setup_uninstall.yml index 9881592f..5a2dbc26 100644 --- a/roles/matrix-bot-matrix-registration-bot/tasks/setup_uninstall.yml +++ b/roles/matrix-bot-matrix-registration-bot/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_bot_matrix_registration_bot_service_stat - name: Ensure matrix-matrix-registration-bot is stopped - service: + ansible.builtin.service: name: matrix-bot-matrix-registration-bot state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists|bool" - name: Ensure matrix-bot-matrix-registration-bot.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service" state: absent when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists|bool" - name: Ensure Matrix matrix-registration-bot paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_bot_matrix_registration_bot_base_path }}" state: absent diff --git a/roles/matrix-bot-matrix-registration-bot/tasks/validate_config.yml b/roles/matrix-bot-matrix-registration-bot/tasks/validate_config.yml index d5db028d..39e97cde 100644 --- a/roles/matrix-bot-matrix-registration-bot/tasks/validate_config.yml +++ b/roles/matrix-bot-matrix-registration-bot/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bot-matrix-reminder-bot/tasks/init.yml b/roles/matrix-bot-matrix-reminder-bot/tasks/init.yml index 41496955..cae7074c 100644 --- a/roles/matrix-bot-matrix-reminder-bot/tasks/init.yml +++ b/roles/matrix-bot-matrix-reminder-bot/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-reminder-bot.service'] }}" when: matrix_bot_matrix_reminder_bot_enabled|bool diff --git a/roles/matrix-bot-matrix-reminder-bot/tasks/setup_install.yml b/roles/matrix-bot-matrix-reminder-bot/tasks/setup_install.yml index d7f4706f..3abda733 100644 --- a/roles/matrix-bot-matrix-reminder-bot/tasks/setup_install.yml +++ b/roles/matrix-bot-matrix-reminder-bot/tasks/setup_install.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_bot_matrix_reminder_bot_requires_restart: false - block: @@ -10,7 +10,7 @@ register: matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}" dst: "{{ matrix_bot_matrix_reminder_bot_database_connection_string }}" @@ -21,13 +21,13 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_bot_matrix_reminder_bot_requires_restart: true when: "matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_bot_matrix_reminder_bot_database_engine == 'postgres'" - name: Ensure matrix-reminder-bot paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -53,7 +53,7 @@ until: result is not failed - name: Ensure matrix-reminder-bot repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_bot_matrix_reminder_bot_docker_repo }}" dest: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}" force: "yes" @@ -75,7 +75,7 @@ when: "matrix_bot_matrix_reminder_bot_container_image_self_build|bool" - name: Ensure matrix-reminder-bot config installed - copy: + ansible.builtin.copy: content: "{{ matrix_bot_matrix_reminder_bot_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_bot_matrix_reminder_bot_config_path }}/config.yaml" mode: 0644 @@ -83,19 +83,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-bot-matrix-reminder-bot.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-reminder-bot.service.j2" dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service" mode: 0644 register: matrix_bot_matrix_reminder_bot_systemd_service_result - name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_matrix_reminder_bot_systemd_service_result.changed|bool" - name: Ensure matrix-bot-matrix-reminder-bot.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-bot-matrix-reminder-bot.service" state: restarted when: "matrix_bot_matrix_reminder_bot_requires_restart|bool" diff --git a/roles/matrix-bot-matrix-reminder-bot/tasks/setup_uninstall.yml b/roles/matrix-bot-matrix-reminder-bot/tasks/setup_uninstall.yml index eb7543c5..1b5201e7 100644 --- a/roles/matrix-bot-matrix-reminder-bot/tasks/setup_uninstall.yml +++ b/roles/matrix-bot-matrix-reminder-bot/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_bot_matrix_reminder_bot_service_stat - name: Ensure matrix-matrix-reminder-bot is stopped - service: + ansible.builtin.service: name: matrix-bot-matrix-reminder-bot state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists|bool" - name: Ensure matrix-bot-matrix-reminder-bot.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service" state: absent when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists|bool" - name: Ensure Matrix matrix-reminder-bot paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_bot_matrix_reminder_bot_base_path }}" state: absent diff --git a/roles/matrix-bot-matrix-reminder-bot/tasks/validate_config.yml b/roles/matrix-bot-matrix-reminder-bot/tasks/validate_config.yml index 8963a312..54f38dd5 100644 --- a/roles/matrix-bot-matrix-reminder-bot/tasks/validate_config.yml +++ b/roles/matrix-bot-matrix-reminder-bot/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -10,7 +10,7 @@ - "matrix_bot_matrix_reminder_bot_reminders_timezone" - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-bot-mjolnir/tasks/init.yml b/roles/matrix-bot-mjolnir/tasks/init.yml index e09964ec..5955a6f4 100644 --- a/roles/matrix-bot-mjolnir/tasks/init.yml +++ b/roles/matrix-bot-mjolnir/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Mjolnir image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_bot_mjolnir_container_image_self_build and matrix_bot_mjolnir_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-mjolnir.service'] }}" when: matrix_bot_mjolnir_enabled|bool diff --git a/roles/matrix-bot-mjolnir/tasks/setup_install.yml b/roles/matrix-bot-mjolnir/tasks/setup_install.yml index 66f2806a..f9e73964 100644 --- a/roles/matrix-bot-mjolnir/tasks/setup_install.yml +++ b/roles/matrix-bot-mjolnir/tasks/setup_install.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_bot_mjolnir_requires_restart: false - name: Ensure matrix-bot-mjolnir paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -30,7 +30,7 @@ until: result is not failed - name: Ensure mjolnir repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_bot_mjolnir_container_image_self_build_repo }}" dest: "{{ matrix_bot_mjolnir_docker_src_files_path }}" version: "{{ matrix_bot_mjolnir_docker_image.split(':')[1] }}" @@ -52,7 +52,7 @@ when: "matrix_bot_mjolnir_container_image_self_build|bool" - name: Ensure matrix-bot-mjolnir config installed - copy: + ansible.builtin.copy: content: "{{ matrix_bot_mjolnir_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_bot_mjolnir_config_path }}/production.yaml" mode: 0644 @@ -60,19 +60,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-bot-mjolnir.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-bot-mjolnir.service.j2" dest: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service" mode: 0644 register: matrix_bot_mjolnir_systemd_service_result - name: Ensure systemd reloaded after matrix-bot-mjolnir.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_mjolnir_systemd_service_result.changed|bool" - name: Ensure matrix-bot-mjolnir.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-bot-mjolnir.service" state: restarted when: "matrix_bot_mjolnir_requires_restart|bool" diff --git a/roles/matrix-bot-mjolnir/tasks/setup_uninstall.yml b/roles/matrix-bot-mjolnir/tasks/setup_uninstall.yml index 93585977..d7a240e7 100644 --- a/roles/matrix-bot-mjolnir/tasks/setup_uninstall.yml +++ b/roles/matrix-bot-mjolnir/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_bot_mjolnir_service_stat - name: Ensure matrix-bot-mjolnir is stopped - service: + ansible.builtin.service: name: matrix-bot-mjolnir state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_bot_mjolnir_service_stat.stat.exists|bool" - name: Ensure matrix-bot-mjolnir.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service" state: absent when: "matrix_bot_mjolnir_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-bot-mjolnir.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_bot_mjolnir_service_stat.stat.exists|bool" - name: Ensure matrix-bot-mjolnir paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_bot_mjolnir_base_path }}" state: absent diff --git a/roles/matrix-bot-mjolnir/tasks/validate_config.yml b/roles/matrix-bot-mjolnir/tasks/validate_config.yml index cb961baf..63289d7b 100644 --- a/roles/matrix-bot-mjolnir/tasks/validate_config.yml +++ b/roles/matrix-bot-mjolnir/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required variables are undefined - fail: + ansible.builtin.fail: msg: "The `{{ item }}` variable must be defined and have a non-null value." with_items: - "matrix_bot_mjolnir_access_token" diff --git a/roles/matrix-bridge-appservice-discord/tasks/init.yml b/roles/matrix-bridge-appservice-discord/tasks/init.yml index a53112ad..df3c927b 100644 --- a/roles/matrix-bridge-appservice-discord/tasks/init.yml +++ b/roles/matrix-bridge-appservice-discord/tasks/init.yml @@ -2,17 +2,17 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-appservice-discord role needs to execute before the matrix-synapse role. when: "matrix_appservice_discord_enabled and matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-discord.service'] }}" when: matrix_appservice_discord_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-appservice-discord/tasks/setup_install.yml b/roles/matrix-bridge-appservice-discord/tasks/setup_install.yml index a06d38ac..5e9bf969 100644 --- a/roles/matrix-bridge-appservice-discord/tasks/setup_install.yml +++ b/roles/matrix-bridge-appservice-discord/tasks/setup_install.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_appservice_discord_requires_restart: false - block: @@ -10,7 +10,7 @@ register: matrix_appservice_discord_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_appservice_discord_sqlite_database_path_local }}" dst: "{{ matrix_appservice_discord_database_connString }}" @@ -21,7 +21,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_appservice_discord_requires_restart: true when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_appservice_discord_database_engine == 'postgres'" @@ -38,7 +38,7 @@ until: result is not failed - name: Ensure AppService Discord paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -55,7 +55,7 @@ register: matrix_appservice_discord_stat_db - name: (Data relocation) Ensure matrix-appservice-discord.service is stopped - service: + ansible.builtin.service: name: matrix-appservice-discord state: stopped enabled: false @@ -64,7 +64,7 @@ when: "matrix_appservice_discord_stat_db.stat.exists" - name: (Data relocation) Move AppService Discord discord.db file to ./data directory - command: "mv {{ matrix_appservice_discord_base_path }}/{{ item }} {{ matrix_appservice_discord_data_path }}/{{ item }}" + ansible.builtin.command: "mv {{ matrix_appservice_discord_base_path }}/{{ item }} {{ matrix_appservice_discord_data_path }}/{{ item }}" with_items: - discord.db - user-store.db @@ -72,7 +72,7 @@ when: "matrix_appservice_discord_stat_db.stat.exists" - name: Ensure AppService Discord config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_discord_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_discord_config_path }}/config.yaml" mode: 0644 @@ -80,7 +80,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure AppService Discord registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_discord_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_discord_config_path }}/registration.yaml" mode: 0644 @@ -90,7 +90,7 @@ # If `matrix_appservice_discord_client_id` hasn't changed, the same invite link would be generated. # We intentionally suppress Ansible changes. - name: Generate AppService Discord invite link - shell: >- + ansible.builtin.shell: >- {{ matrix_host_command_docker }} run --rm --name matrix-appservice-discord-link-gen --user={{ matrix_user_uid }}:{{ matrix_user_gid }} --cap-drop=ALL @@ -101,19 +101,19 @@ changed_when: false - name: Ensure matrix-appservice-discord.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2" dest: "{{ matrix_systemd_path }}/matrix-appservice-discord.service" mode: 0644 register: matrix_appservice_discord_systemd_service_result - name: Ensure systemd reloaded after matrix-appservice-discord.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_discord_systemd_service_result.changed" - name: Ensure matrix-appservice-discord.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-appservice-discord.service" state: restarted when: "matrix_appservice_discord_requires_restart|bool" diff --git a/roles/matrix-bridge-appservice-discord/tasks/setup_uninstall.yml b/roles/matrix-bridge-appservice-discord/tasks/setup_uninstall.yml index ab56c26b..b844fa7c 100644 --- a/roles/matrix-bridge-appservice-discord/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-appservice-discord/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_appservice_discord_service_stat - name: Ensure matrix-appservice-discord is stopped - service: + ansible.builtin.service: name: matrix-appservice-discord state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_appservice_discord_service_stat.stat.exists" - name: Ensure matrix-appservice-discord.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service" state: absent when: "matrix_appservice_discord_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-appservice-discord.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_discord_service_stat.stat.exists" diff --git a/roles/matrix-bridge-appservice-discord/tasks/validate_config.yml b/roles/matrix-bridge-appservice-discord/tasks/validate_config.yml index 73253ba0..901b760b 100644 --- a/roles/matrix-bridge-appservice-discord/tasks/validate_config.yml +++ b/roles/matrix-bridge-appservice-discord/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -13,7 +13,7 @@ - "matrix_appservice_discord_homeserver_domain" - name: (Deprecation) Catch and report renamed appservice-discord variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). @@ -22,5 +22,5 @@ - {'old': 'matrix_appservice_discord_container_expose_client_server_api_port', 'new': ''} - name: Require a valid database engine - fail: msg="`matrix_appservice_discord_database_engine` needs to be either 'sqlite' or 'postgres'" + ansible.builtin.fail: msg="`matrix_appservice_discord_database_engine` needs to be either 'sqlite' or 'postgres'" when: "matrix_appservice_discord_database_engine not in ['sqlite', 'postgres']" diff --git a/roles/matrix-bridge-appservice-irc/tasks/init.yml b/roles/matrix-bridge-appservice-irc/tasks/init.yml index a35144f0..b318f23f 100644 --- a/roles/matrix-bridge-appservice-irc/tasks/init.yml +++ b/roles/matrix-bridge-appservice-irc/tasks/init.yml @@ -2,24 +2,24 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_appservice_irc_container_image_self_build and matrix_appservice_irc_enabled" # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-appservice-irc role needs to execute before the matrix-synapse role. when: "matrix_appservice_irc_enabled|bool and matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-irc.service'] }}" when: matrix_appservice_irc_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-appservice-irc/tasks/migrate_nedb_to_postgres.yml b/roles/matrix-bridge-appservice-irc/tasks/migrate_nedb_to_postgres.yml index d7fcaa07..486b093b 100644 --- a/roles/matrix-bridge-appservice-irc/tasks/migrate_nedb_to_postgres.yml +++ b/roles/matrix-bridge-appservice-irc/tasks/migrate_nedb_to_postgres.yml @@ -1,21 +1,21 @@ --- - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot migrate." when: "not matrix_postgres_enabled|bool" # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" # Actual import work - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -34,13 +34,13 @@ register: matrix_appservice_irc_service_stat - name: Ensure matrix-appservice-irc is stopped - service: + ansible.builtin.service: name: matrix-appservice-irc state: stopped when: "matrix_appservice_irc_service_stat.stat.exists" - name: Import appservice-irc NeDB database into Postgres - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -54,14 +54,14 @@ '/usr/local/bin/node /app/lib/scripts/migrate-db-to-pgres.js --dbdir /data --privateKey /data/passkey.pem --connectionString {{ matrix_appservice_irc_database_connection_string }}' - name: Archive NeDB database files - command: + ansible.builtin.command: cmd: "mv {{ matrix_appservice_irc_data_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}.backup" with_items: - rooms.db - users.db - name: Inject result - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-bridge-appservice-irc/tasks/setup_install.yml b/roles/matrix-bridge-appservice-irc/tasks/setup_install.yml index 1ae0b3fa..d24de340 100644 --- a/roles/matrix-bridge-appservice-irc/tasks/setup_install.yml +++ b/roles/matrix-bridge-appservice-irc/tasks/setup_install.yml @@ -3,7 +3,7 @@ - import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" - name: Ensure Appservice IRC paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -23,24 +23,24 @@ - block: - name: (Data relocation) Ensure matrix-appservice-irc.service is stopped - service: + ansible.builtin.service: name: matrix-appservice-irc state: stopped daemon_reload: true failed_when: false - name: (Data relocation) Move AppService IRC passkey.pem file to ./data directory - command: "mv {{ matrix_appservice_irc_base_path }}/passkey.pem {{ matrix_appservice_irc_data_path }}/passkey.pem" + ansible.builtin.command: "mv {{ matrix_appservice_irc_base_path }}/passkey.pem {{ matrix_appservice_irc_data_path }}/passkey.pem" - name: (Data relocation) Move AppService IRC database files to ./data directory - command: "mv {{ matrix_appservice_irc_base_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}" + ansible.builtin.command: "mv {{ matrix_appservice_irc_base_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}" with_items: - rooms.db - users.db failed_when: false when: "matrix_appservice_irc_stat_passkey.stat.exists" -- set_fact: +- ansible.builtin.set_fact: matrix_appservice_irc_requires_restart: false - block: @@ -52,7 +52,7 @@ - block: - import_tasks: "{{ role_path }}/tasks/migrate_nedb_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_appservice_irc_requires_restart: true when: "matrix_appservice_irc_nedb_database_path_local_stat_result.stat.exists|bool" when: "matrix_appservice_irc_database_engine == 'postgres'" @@ -70,7 +70,7 @@ until: result is not failed - name: Ensure matrix-appservice-irc repository is present when self-building - git: + ansible.builtin.git: repo: "{{ matrix_appservice_irc_docker_repo }}" dest: "{{ matrix_appservice_irc_docker_src_files_path }}" force: "yes" @@ -92,7 +92,7 @@ when: "matrix_appservice_irc_enabled|bool and matrix_appservice_irc_container_image_self_build|bool and matrix_appservice_irc_git_pull_results.changed" - name: Ensure Matrix Appservice IRC config installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_irc_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_irc_config_path }}/config.yaml" mode: 0644 @@ -105,7 +105,7 @@ register: irc_passkey_file - name: Generate Appservice IRC passkey if it doesn't exist - shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_appservice_irc_data_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048" + ansible.builtin.shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_appservice_irc_data_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048" become: true become_user: "{{ matrix_user_username }}" when: "not irc_passkey_file.stat.exists" @@ -113,7 +113,7 @@ # In the past, we used to generate the passkey.pem file with root, so permissions may not be okay. # Fix it. - name: (Migration) Ensure Appservice IRC passkey permissions are okay - file: + ansible.builtin.file: path: "{{ matrix_appservice_irc_data_path }}/passkey.pem" mode: 0644 owner: "{{ matrix_user_username }}" @@ -139,7 +139,7 @@ # an up-to-date file, and we fix it up with some static values later on, # to produce a final registration.yaml file, as we desire. - name: Generate Appservice IRC registration-template.yaml - shell: >- + ansible.builtin.shell: >- {{ matrix_host_command_docker }} run --rm --name matrix-appservice-irc-gen --user={{ matrix_user_uid }}:{{ matrix_user_gid }} --cap-drop=ALL @@ -157,26 +157,26 @@ changed_when: false - name: Read Appservice IRC registration-template.yaml - slurp: + ansible.builtin.slurp: src: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml" register: matrix_appservice_irc_registration_template_slurp - name: Remove unnecessary Appservice IRC registration-template.yaml - file: + ansible.builtin.file: path: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml" state: absent changed_when: false - name: Parse registration-template.yaml - set_fact: + ansible.builtin.set_fact: matrix_appservice_irc_registration_template: "{{ matrix_appservice_irc_registration_template_slurp['content'] | b64decode | from_yaml }}" - name: Combine registration-template.yaml and own registration override config - set_fact: + ansible.builtin.set_fact: matrix_appservice_irc_registration: "{{ matrix_appservice_irc_registration_template|combine(matrix_appservice_irc_registration_override, recursive=True) }}" - name: Ensure Appservice IRC registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_irc_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_irc_config_path }}/registration.yaml" mode: 0644 @@ -184,19 +184,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-appservice-irc.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-appservice-irc.service.j2" dest: "{{ matrix_systemd_path }}/matrix-appservice-irc.service" mode: 0644 register: matrix_appservice_irc_systemd_service_result - name: Ensure systemd reloaded after matrix-appservice-irc.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_irc_systemd_service_result.changed" - name: Ensure matrix-appservice-irc.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-appservice-irc.service" state: restarted when: "matrix_appservice_irc_requires_restart|bool" diff --git a/roles/matrix-bridge-appservice-irc/tasks/setup_uninstall.yml b/roles/matrix-bridge-appservice-irc/tasks/setup_uninstall.yml index a4d95df5..216ec682 100644 --- a/roles/matrix-bridge-appservice-irc/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-appservice-irc/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_appservice_irc_service_stat - name: Ensure matrix-appservice-irc is stopped - service: + ansible.builtin.service: name: matrix-appservice-irc state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_appservice_irc_service_stat.stat.exists" - name: Ensure matrix-appservice-irc.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service" state: absent when: "matrix_appservice_irc_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-appservice-irc.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_irc_service_stat.stat.exists" diff --git a/roles/matrix-bridge-appservice-irc/tasks/validate_config.yml b/roles/matrix-bridge-appservice-irc/tasks/validate_config.yml index 303f2640..f101e6fe 100644 --- a/roles/matrix-bridge-appservice-irc/tasks/validate_config.yml +++ b/roles/matrix-bridge-appservice-irc/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -17,7 +17,7 @@ # # This is a safety check to ensure we fail earlier and in a nicer way. - name: Fail if no additional configuration provided - fail: + ansible.builtin.fail: msg: >- Your Appservice IRC configuration is incomplete (lacking an `ircService.servers` configuration). You need to define one or more servers by either using `matrix_appservice_irc_ircService_servers` @@ -26,7 +26,7 @@ when: "matrix_appservice_irc_configuration.ircService.servers|length == 0" - name: (Deprecation) Catch and report renamed appservice-irc variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-bridge-appservice-slack/tasks/init.yml b/roles/matrix-bridge-appservice-slack/tasks/init.yml index c8331817..21fee674 100644 --- a/roles/matrix-bridge-appservice-slack/tasks/init.yml +++ b/roles/matrix-bridge-appservice-slack/tasks/init.yml @@ -2,24 +2,24 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_appservice_slack_container_image_self_build and matrix_appservice_slack_enabled" # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-slack.service'] }}" when: matrix_appservice_slack_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -38,14 +38,14 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Slack Appservice's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -54,7 +54,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Matrix Appservice Slack proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_appservice_slack_matrix_nginx_proxy_configuration: | location {{ matrix_appservice_slack_public_endpoint }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -69,7 +69,7 @@ } - name: Register Slack Appservice proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -81,7 +81,7 @@ when: matrix_appservice_slack_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Matrix Slack bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-appservice-slack/tasks/migrate_nedb_to_postgres.yml b/roles/matrix-bridge-appservice-slack/tasks/migrate_nedb_to_postgres.yml index 0bea65bc..6c0dd278 100644 --- a/roles/matrix-bridge-appservice-slack/tasks/migrate_nedb_to_postgres.yml +++ b/roles/matrix-bridge-appservice-slack/tasks/migrate_nedb_to_postgres.yml @@ -1,21 +1,21 @@ --- - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot migrate." when: "not matrix_postgres_enabled|bool" # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" # Actual import work - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -29,12 +29,12 @@ when: "matrix_postgres_service_start_result.changed|bool" - name: Ensure matrix-appservice-slack is stopped - service: + ansible.builtin.service: name: matrix-appservice-slack state: stopped - name: Import appservice-slack NeDB database into Postgres - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -48,7 +48,7 @@ '/usr/local/bin/node /usr/src/app/lib/scripts/migrateToPostgres.js --dbdir /data --connectionString {{ matrix_appservice_slack_database_connection_string }}' - name: Archive NeDB database files - command: + ansible.builtin.command: cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup" with_items: - teams.db @@ -57,7 +57,7 @@ - event-store.db - name: Inject result - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-bridge-appservice-slack/tasks/setup_install.yml b/roles/matrix-bridge-appservice-slack/tasks/setup_install.yml index 42aa020c..5eb860ee 100644 --- a/roles/matrix-bridge-appservice-slack/tasks/setup_install.yml +++ b/roles/matrix-bridge-appservice-slack/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure AppService Slack paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -14,7 +14,7 @@ - {path: "{{ matrix_appservice_slack_docker_src_files_path }}", when: "{{ matrix_appservice_slack_container_image_self_build }}"} when: item.when|bool -- set_fact: +- ansible.builtin.set_fact: matrix_appservice_slack_requires_restart: false - block: @@ -26,7 +26,7 @@ - block: - import_tasks: "{{ role_path }}/tasks/migrate_nedb_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_appservice_slack_requires_restart: true when: "matrix_appservice_slack_nedb_database_path_local_stat_result.stat.exists|bool" when: "matrix_appservice_slack_database_engine == 'postgres'" @@ -44,7 +44,7 @@ until: result is not failed - name: Ensure matrix-appservice-slack repository is present when self-building - git: + ansible.builtin.git: repo: "{{ matrix_appservice_slack_docker_repo }}" dest: "{{ matrix_appservice_slack_docker_src_files_path }}" force: "yes" @@ -66,7 +66,7 @@ when: "matrix_appservice_slack_container_image_self_build|bool and matrix_appservice_slack_git_pull_results.changed" - name: Ensure Matrix Appservice Slack config installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_slack_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_slack_config_path }}/config.yaml" mode: 0644 @@ -74,7 +74,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure appservice-slack registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_slack_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_slack_config_path }}/slack-registration.yaml" mode: 0644 @@ -82,19 +82,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-appservice-slack.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-appservice-slack.service.j2" dest: "{{ matrix_systemd_path }}/matrix-appservice-slack.service" mode: 0644 register: matrix_appservice_slack_systemd_service_result - name: Ensure systemd reloaded after matrix-appservice-slack.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_slack_systemd_service_result.changed" - name: Ensure matrix-appservice-slack.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-appservice-slack.service" state: restarted when: "matrix_appservice_slack_requires_restart|bool" diff --git a/roles/matrix-bridge-appservice-slack/tasks/setup_uninstall.yml b/roles/matrix-bridge-appservice-slack/tasks/setup_uninstall.yml index dffe78b3..fefa9aba 100644 --- a/roles/matrix-bridge-appservice-slack/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-appservice-slack/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_appservice_slack_service_stat - name: Ensure matrix-appservice-slack is stopped - service: + ansible.builtin.service: name: matrix-appservice-slack state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_appservice_slack_service_stat.stat.exists" - name: Ensure matrix-appservice-slack.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-appservice-slack.service" state: absent when: "matrix_appservice_slack_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-appservice-slack.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_slack_service_stat.stat.exists" diff --git a/roles/matrix-bridge-appservice-slack/tasks/validate_config.yml b/roles/matrix-bridge-appservice-slack/tasks/validate_config.yml index 1866c312..e00eb6d4 100644 --- a/roles/matrix-bridge-appservice-slack/tasks/validate_config.yml +++ b/roles/matrix-bridge-appservice-slack/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -13,7 +13,7 @@ - "matrix_appservice_slack_id_token" - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-bridge-appservice-webhooks/tasks/init.yml b/roles/matrix-bridge-appservice-webhooks/tasks/init.yml index 370b835d..6b9fa87e 100644 --- a/roles/matrix-bridge-appservice-webhooks/tasks/init.yml +++ b/roles/matrix-bridge-appservice-webhooks/tasks/init.yml @@ -2,17 +2,17 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-webhooks.service'] }}" when: matrix_appservice_webhooks_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -31,14 +31,14 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append webhooks Appservice's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -47,7 +47,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Matrix Appservice webhooks proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_appservice_webhooks_matrix_nginx_proxy_configuration: | {% if matrix_nginx_proxy_enabled|default(False) %} {# Use the embedded DNS resolver in Docker containers to discover the service #} @@ -64,7 +64,7 @@ {% endif %} - name: Register webhooks Appservice proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -76,7 +76,7 @@ when: matrix_appservice_webhooks_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Matrix webhooks bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-appservice-webhooks/tasks/setup_install.yml b/roles/matrix-bridge-appservice-webhooks/tasks/setup_install.yml index 274f54c5..9228b617 100644 --- a/roles/matrix-bridge-appservice-webhooks/tasks/setup_install.yml +++ b/roles/matrix-bridge-appservice-webhooks/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure AppService webhooks paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ - block: - name: Ensure Appservice webhooks repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_appservice_webhooks_container_image_self_build_repo }}" dest: "{{ matrix_appservice_webhooks_docker_src_files_path }}" version: "{{ matrix_appservice_webhooks_container_image_self_build_repo_version }}" @@ -50,7 +50,7 @@ when: "matrix_appservice_webhooks_container_image_self_build|bool" - name: Ensure Matrix Appservice webhooks config is installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_webhooks_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_webhooks_config_path }}/config.yaml" mode: 0644 @@ -58,7 +58,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure Matrix Appservice webhooks schema.yml template exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/schema.yml.j2" dest: "{{ matrix_appservice_webhooks_config_path }}/schema.yml" mode: 0644 @@ -66,7 +66,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure Matrix Appservice webhooks database.json template exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/database.json.j2" dest: "{{ matrix_appservice_webhooks_data_path }}/database.json" mode: 0644 @@ -74,7 +74,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure appservice-webhooks registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_appservice_webhooks_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_appservice_webhooks_config_path }}/webhooks-registration.yaml" mode: 0644 @@ -82,13 +82,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-appservice-webhooks.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-appservice-webhooks.service.j2" dest: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service" mode: 0644 register: matrix_appservice_webhooks_systemd_service_result - name: Ensure systemd reloaded after matrix-appservice-webhooks.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_webhooks_systemd_service_result.changed" diff --git a/roles/matrix-bridge-appservice-webhooks/tasks/setup_uninstall.yml b/roles/matrix-bridge-appservice-webhooks/tasks/setup_uninstall.yml index 38235652..8da6f8c2 100644 --- a/roles/matrix-bridge-appservice-webhooks/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-appservice-webhooks/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_appservice_webhooks_service_stat - name: Ensure matrix-appservice-webhooks is stopped - service: + ansible.builtin.service: name: matrix-appservice-webhooks state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_appservice_webhooks_service_stat.stat.exists" - name: Ensure matrix-appservice-webhooks.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service" state: absent when: "matrix_appservice_webhooks_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-appservice-webhooks.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_appservice_webhooks_service_stat.stat.exists" diff --git a/roles/matrix-bridge-appservice-webhooks/tasks/validate_config.yml b/roles/matrix-bridge-appservice-webhooks/tasks/validate_config.yml index 48f63e68..d7f45c6f 100644 --- a/roles/matrix-bridge-appservice-webhooks/tasks/validate_config.yml +++ b/roles/matrix-bridge-appservice-webhooks/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-beeper-linkedin/tasks/init.yml b/roles/matrix-bridge-beeper-linkedin/tasks/init.yml index 64057301..6de40974 100644 --- a/roles/matrix-bridge-beeper-linkedin/tasks/init.yml +++ b/roles/matrix-bridge-beeper-linkedin/tasks/init.yml @@ -1,11 +1,11 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-beeper-linkedin.service'] }}" when: matrix_beeper_linkedin_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-beeper-linkedin/tasks/setup_install.yml b/roles/matrix-bridge-beeper-linkedin/tasks/setup_install.yml index 74f80314..73794efe 100644 --- a/roles/matrix-bridge-beeper-linkedin/tasks/setup_install.yml +++ b/roles/matrix-bridge-beeper-linkedin/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-beeper-linkedin role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - name: Ensure Beeper LinkedIn paths exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -36,7 +36,7 @@ - block: - name: Ensure Beeper LinkedIn repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_beeper_linkedin_container_image_self_build_repo }}" dest: "{{ matrix_beeper_linkedin_docker_src_files_path }}" version: "{{ matrix_beeper_linkedin_container_image_self_build_branch }}" @@ -48,7 +48,7 @@ # Building the container image (using the default Dockerfile) requires that a docker-requirements.txt file be generated. # See: https://gitlab.com/beeper/linkedin/-/blob/94442db17ccb9769b377cdb8e4bf1cb3955781d7/.gitlab-ci.yml#L30-40 - name: Ensure docker-requirements.txt is generated before building Beeper LinkedIn Docker Image - command: | + ansible.builtin.command: | {{ matrix_host_command_docker }} run \ --rm \ --entrypoint=/bin/sh \ @@ -72,7 +72,7 @@ when: "matrix_beeper_linkedin_container_image_self_build|bool" - name: Ensure beeper-linkedin config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_beeper_linkedin_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_beeper_linkedin_config_path }}/config.yaml" mode: 0644 @@ -80,7 +80,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure beeper-linkedin registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_beeper_linkedin_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_beeper_linkedin_config_path }}/registration.yaml" mode: 0644 @@ -88,13 +88,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-beeper-linkedin.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-beeper-linkedin.service.j2" dest: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service" mode: 0644 register: matrix_beeper_linkedin_systemd_service_result - name: Ensure systemd reloaded after matrix-beeper-linkedin.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_beeper_linkedin_systemd_service_result.changed" diff --git a/roles/matrix-bridge-beeper-linkedin/tasks/setup_uninstall.yml b/roles/matrix-bridge-beeper-linkedin/tasks/setup_uninstall.yml index befa2f61..be2b198f 100644 --- a/roles/matrix-bridge-beeper-linkedin/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-beeper-linkedin/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_beeper_linkedin_service_stat - name: Ensure matrix-beeper-linkedin is stopped - service: + ansible.builtin.service: name: matrix-beeper-linkedin state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_beeper_linkedin_service_stat.stat.exists" - name: Ensure matrix-beeper-linkedin.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service" state: absent when: "matrix_beeper_linkedin_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-beeper-linkedin.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_beeper_linkedin_service_stat.stat.exists" diff --git a/roles/matrix-bridge-beeper-linkedin/tasks/validate_config.yml b/roles/matrix-bridge-beeper-linkedin/tasks/validate_config.yml index d808de08..61489b7c 100644 --- a/roles/matrix-bridge-beeper-linkedin/tasks/validate_config.yml +++ b/roles/matrix-bridge-beeper-linkedin/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-go-skype-bridge/tasks/init.yml b/roles/matrix-bridge-go-skype-bridge/tasks/init.yml index 452d835b..81baaa24 100644 --- a/roles/matrix-bridge-go-skype-bridge/tasks/init.yml +++ b/roles/matrix-bridge-go-skype-bridge/tasks/init.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-go-skype-bridge.service'] }}" when: matrix_go_skype_bridge_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-go-skype-bridge/tasks/setup_install.yml b/roles/matrix-bridge-go-skype-bridge/tasks/setup_install.yml index c884625b..d43941d4 100644 --- a/roles/matrix-bridge-go-skype-bridge/tasks/setup_install.yml +++ b/roles/matrix-bridge-go-skype-bridge/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-go-skype-bridge role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_go_skype_bridge_requires_restart: false - block: @@ -18,7 +18,7 @@ register: matrix_go_skype_bridge_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_go_skype_bridge_sqlite_database_path_local }}" dst: "{{ matrix_go_skype_bridge_database_connection_string }}" @@ -30,14 +30,14 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_go_skype_bridge_requires_restart: true when: "matrix_go_skype_bridge_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_go_skype_bridge_database_engine == 'postgres'" - name: Ensure Go Skype Bridge paths exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -63,7 +63,7 @@ until: result is not failed - name: Ensure Go Skype Bridge repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_go_skype_bridge_container_image_self_build_repo }}" dest: "{{ matrix_go_skype_bridge_docker_src_files_path }}" version: "{{ matrix_go_skype_bridge_container_image_self_build_branch }}" @@ -96,7 +96,7 @@ register: matrix_go_skype_bridge_stat_mx_state - name: (Data relocation) Ensure matrix-go-skype-bridge.service is stopped - service: + ansible.builtin.service: name: matrix-go-skype-bridge state: stopped enabled: false @@ -105,15 +105,15 @@ when: "matrix_go_skype_bridge_stat_database.stat.exists" - name: (Data relocation) Move go-skype-bridge database file to ./data directory - command: "mv {{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db {{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db" + ansible.builtin.command: "mv {{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db {{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db" when: "matrix_go_skype_bridge_stat_database.stat.exists" - name: (Data relocation) Move go-skype-bridge mx-state file to ./data directory - command: "mv {{ matrix_go_skype_bridge_base_path }}/mx-state.json {{ matrix_go_skype_bridge_data_path }}/mx-state.json" + ansible.builtin.command: "mv {{ matrix_go_skype_bridge_base_path }}/mx-state.json {{ matrix_go_skype_bridge_data_path }}/mx-state.json" when: "matrix_go_skype_bridge_stat_mx_state.stat.exists" - name: Ensure go-skype-bridge config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_go_skype_bridge_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_go_skype_bridge_config_path }}/config.yaml" mode: 0644 @@ -121,7 +121,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure go-skype-bridge registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_go_skype_bridge_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_go_skype_bridge_config_path }}/registration.yaml" mode: 0644 @@ -129,19 +129,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-go-skype-bridge.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-go-skype-bridge.service.j2" dest: "{{ matrix_systemd_path }}/matrix-go-skype-bridge.service" mode: 0644 register: matrix_go_skype_bridge_systemd_service_result - name: Ensure systemd reloaded after matrix-go-skype-bridge.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_go_skype_bridge_systemd_service_result.changed" - name: Ensure matrix-go-skype-bridge.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-go-skype-bridge.service" state: restarted when: "matrix_go_skype_bridge_requires_restart|bool" diff --git a/roles/matrix-bridge-go-skype-bridge/tasks/setup_uninstall.yml b/roles/matrix-bridge-go-skype-bridge/tasks/setup_uninstall.yml index 19acff85..138cdbf1 100644 --- a/roles/matrix-bridge-go-skype-bridge/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-go-skype-bridge/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_go_skype_bridge_service_stat - name: Ensure matrix-go-skype-bridge is stopped - service: + ansible.builtin.service: name: matrix-go-skype-bridge state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_go_skype_bridge_service_stat.stat.exists" - name: Ensure matrix-go-skype-bridge.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-go-skype-bridge.service" state: absent when: "matrix_go_skype_bridge_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-go-skype-bridge.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_go_skype_bridge_service_stat.stat.exists" diff --git a/roles/matrix-bridge-go-skype-bridge/tasks/validate_config.yml b/roles/matrix-bridge-go-skype-bridge/tasks/validate_config.yml index 7e9f3daf..d681299f 100644 --- a/roles/matrix-bridge-go-skype-bridge/tasks/validate_config.yml +++ b/roles/matrix-bridge-go-skype-bridge/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-heisenbridge/tasks/init.yml b/roles/matrix-bridge-heisenbridge/tasks/init.yml index ef3efb76..dd08beb5 100644 --- a/roles/matrix-bridge-heisenbridge/tasks/init.yml +++ b/roles/matrix-bridge-heisenbridge/tasks/init.yml @@ -2,17 +2,17 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-heisenbridge role needs to execute before the matrix-synapse role. when: "matrix_heisenbridge_enabled and matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-heisenbridge.service'] }}" when: matrix_heisenbridge_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-heisenbridge/tasks/setup_install.yml b/roles/matrix-bridge-heisenbridge/tasks/setup_install.yml index f24bf926..4112f047 100644 --- a/roles/matrix-bridge-heisenbridge/tasks/setup_install.yml +++ b/roles/matrix-bridge-heisenbridge/tasks/setup_install.yml @@ -12,7 +12,7 @@ until: result is not failed - name: Ensure heisenbridge paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -22,7 +22,7 @@ - "{{ matrix_heisenbridge_base_path }}" - name: Ensure heisenbridge registration.yaml installed if provided - copy: + ansible.builtin.copy: content: "{{ matrix_heisenbridge_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_heisenbridge_base_path }}/registration.yaml" mode: 0644 @@ -30,13 +30,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-heisenbridge.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-heisenbridge.service.j2" dest: "{{ matrix_systemd_path }}/matrix-heisenbridge.service" mode: 0644 register: matrix_heisenbridge_systemd_service_result - name: Ensure systemd reloaded after matrix-heisenbridge.service installation - service: + ansible.builtin.service: daemon_reload: true when: matrix_heisenbridge_systemd_service_result.changed diff --git a/roles/matrix-bridge-heisenbridge/tasks/setup_uninstall.yml b/roles/matrix-bridge-heisenbridge/tasks/setup_uninstall.yml index 54d5bd67..c3bf7950 100644 --- a/roles/matrix-bridge-heisenbridge/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-heisenbridge/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_heisenbridge_service_stat - name: Ensure matrix-heisenbridge is stopped - service: + ansible.builtin.service: name: matrix-heisenbridge state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_heisenbridge_service_stat.stat.exists" - name: Ensure matrix-heisenbridge.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-heisenbridge.service" state: absent when: "matrix_heisenbridge_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-heisenbridge.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_heisenbridge_service_stat.stat.exists" diff --git a/roles/matrix-bridge-hookshot/tasks/init.yml b/roles/matrix-bridge-hookshot/tasks/init.yml index 96d5740a..5ac8c4f2 100644 --- a/roles/matrix-bridge-hookshot/tasks/init.yml +++ b/roles/matrix-bridge-hookshot/tasks/init.yml @@ -2,17 +2,17 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-hookshot role needs to execute before the matrix-synapse role. when: "matrix_hookshot_enabled and matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-hookshot.service'] }}" when: matrix_hookshot_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -30,7 +30,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append hookshot's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -39,7 +39,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Matrix hookshot proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_hookshot_matrix_nginx_proxy_configuration: | location ~ ^{{ matrix_hookshot_appservice_endpoint }}/(.*)$ { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -95,7 +95,7 @@ } - name: Register hookshot proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -104,7 +104,7 @@ }} - name: Generate hookshot metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/hookshot) - set_fact: + ansible.builtin.set_fact: matrix_hookshot_matrix_nginx_proxy_metrics_configuration_matrix_domain: | location /metrics/hookshot { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -120,7 +120,7 @@ when: matrix_hookshot_metrics_enabled|bool and matrix_hookshot_metrics_proxying_enabled|bool - name: Register hookshot metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/hookshot) - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([]) @@ -131,7 +131,7 @@ when: matrix_hookshot_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the hookshot bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-hookshot/tasks/setup_install.yml b/roles/matrix-bridge-hookshot/tasks/setup_install.yml index 25f2978c..eb5e9a98 100644 --- a/roles/matrix-bridge-hookshot/tasks/setup_install.yml +++ b/roles/matrix-bridge-hookshot/tasks/setup_install.yml @@ -3,7 +3,7 @@ - import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" - name: Ensure hookshot paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -27,7 +27,7 @@ until: result is not failed - name: Ensure hookshot repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_hookshot_container_image_self_build_repo }}" dest: "{{ matrix_hookshot_docker_src_files_path }}" version: "{{ matrix_hookshot_container_image_self_build_branch }}" @@ -55,13 +55,13 @@ register: hookshot_passkey_file - name: Generate hookshot passkey if it doesn't exist - shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_hookshot_base_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:4096" + ansible.builtin.shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_hookshot_base_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:4096" become: true become_user: "{{ matrix_user_username }}" when: "not hookshot_passkey_file.stat.exists" - name: Ensure hookshot config.yml installed if provided - copy: + ansible.builtin.copy: content: "{{ matrix_hookshot_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_hookshot_base_path }}/config.yml" mode: 0644 @@ -69,7 +69,7 @@ group: "{{ matrix_user_groupname }}" - name: Validate hookshot config.yml - command: | + ansible.builtin.command: | {{ matrix_host_command_docker }} run --rm --name={{ matrix_hookshot_container_url }}-validate @@ -80,12 +80,12 @@ register: hookshot_config_validation_result - name: Fail if hookshot config.yml invalid - fail: + ansible.builtin.fail: msg: "Your hookshot configuration did not pass validation:\n{{ hookshot_config_validation_result.stdout }}\n{{ hookshot_config_validation_result.stderr }}" when: "hookshot_config_validation_result.rc > 0" - name: Ensure hookshot registration.yml installed if provided - copy: + ansible.builtin.copy: content: "{{ matrix_hookshot_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_hookshot_base_path }}/registration.yml" mode: 0644 @@ -93,7 +93,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure hookshot github private key file installed if github is enabled - copy: + ansible.builtin.copy: content: "{{ matrix_hookshot_github_private_key }}" dest: "{{ matrix_hookshot_base_path }}/{{ matrix_hookshot_github_private_key_file }}" mode: 0400 @@ -102,13 +102,13 @@ when: matrix_hookshot_github_enabled|bool and matrix_hookshot_github_private_key|length > 0 - name: Ensure matrix-hookshot.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-hookshot.service.j2" dest: "{{ matrix_systemd_path }}/matrix-hookshot.service" mode: 0644 register: matrix_hookshot_systemd_service_result - name: Ensure systemd reloaded after matrix-hookshot.service installation - service: + ansible.builtin.service: daemon_reload: true when: matrix_hookshot_systemd_service_result.changed diff --git a/roles/matrix-bridge-hookshot/tasks/setup_uninstall.yml b/roles/matrix-bridge-hookshot/tasks/setup_uninstall.yml index d8efbb02..903f46e6 100644 --- a/roles/matrix-bridge-hookshot/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-hookshot/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_hookshot_service_stat - name: Ensure matrix-hookshot is stopped - service: + ansible.builtin.service: name: matrix-hookshot state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_hookshot_service_stat.stat.exists" - name: Ensure matrix-hookshot.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-hookshot.service" state: absent when: "matrix_hookshot_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-hookshot.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_hookshot_service_stat.stat.exists" diff --git a/roles/matrix-bridge-hookshot/tasks/validate_config.yml b/roles/matrix-bridge-hookshot/tasks/validate_config.yml index b9622332..0fbcf53c 100644 --- a/roles/matrix-bridge-hookshot/tasks/validate_config.yml +++ b/roles/matrix-bridge-hookshot/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -10,7 +10,7 @@ - "matrix_hookshot_homeserver_token" - name: Fail if required GitHub settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) to enable GitHub. when: "matrix_hookshot_github_enabled and vars[item] == ''" @@ -19,7 +19,7 @@ - "matrix_hookshot_github_secret" - name: Fail if required GitHub OAuth settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) to enable GitHub OAuth. when: "matrix_hookshot_github_oauth_enabled and vars[item] == ''" @@ -28,7 +28,7 @@ - "matrix_hookshot_github_oauth_secret" - name: Fail if required Jira settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) to enable Jira. when: "matrix_hookshot_jira_enabled and vars[item] == ''" @@ -36,7 +36,7 @@ - "matrix_hookshot_jira_secret" - name: Fail if required Jira OAuth settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) to enable Jira OAuth. when: "matrix_hookshot_jira_oauth_enabled and vars[item] == ''" @@ -45,13 +45,13 @@ - "matrix_hookshot_jira_oauth_secret" - name: Fail if required Figma settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define at least one Figma instance to enable Figma. when: "matrix_hookshot_figma_enabled and matrix_hookshot_figma_instances is undefined" - name: Fail if required provisioning settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) to enable provisioning. when: "matrix_hookshot_provisioning_enabled and vars[item] == ''" @@ -59,7 +59,7 @@ - "matrix_hookshot_provisioning_secret" - name: (Deprecation) Catch and report old metrics usage - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable (`{{ item }}`), which refers to the old metrics collection system for Hookshot, which exposed metrics on `https://stats.DOMAIN/hookshot/metrics`. diff --git a/roles/matrix-bridge-mautrix-facebook/tasks/init.yml b/roles/matrix-bridge-mautrix-facebook/tasks/init.yml index f2cd5963..3bad6fb2 100644 --- a/roles/matrix-bridge-mautrix-facebook/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-facebook/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mautrix_facebook_container_image_self_build and matrix_mautrix_facebook_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-facebook.service'] }}" when: matrix_mautrix_facebook_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -29,7 +29,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Mautrix Facebook's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -38,7 +38,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Mautrix Facebook proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_mautrix_facebook_matrix_nginx_proxy_configuration: | location {{ matrix_mautrix_facebook_public_endpoint }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -53,7 +53,7 @@ } - name: Register Mautrix Facebook proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -62,7 +62,7 @@ }} - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Mautrix Facebook bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-mautrix-facebook/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-facebook/tasks/setup_install.yml index 699ed88a..eaf2f139 100644 --- a/roles/matrix-bridge-mautrix-facebook/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-facebook/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-facebook role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mautrix_facebook_requires_restart: false - block: @@ -18,7 +18,7 @@ register: matrix_mautrix_facebook_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mautrix_facebook_sqlite_database_path_local }}" dst: "{{ matrix_mautrix_facebook_database_connection_string }}" @@ -29,7 +29,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mautrix_facebook_requires_restart: true when: "matrix_mautrix_facebook_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mautrix_facebook_database_engine == 'postgres'" @@ -47,7 +47,7 @@ until: result is not failed - name: Ensure Mautrix Facebook paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -61,7 +61,7 @@ when: item.when|bool - name: Ensure Mautrix Facebook repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_facebook_container_image_self_build_repo }}" dest: "{{ matrix_mautrix_facebook_docker_src_files_path }}" version: "{{ matrix_mautrix_facebook_docker_image.split(':')[1] }}" @@ -89,7 +89,7 @@ register: matrix_mautrix_facebook_stat_database - name: (Data relocation) Ensure matrix-mautrix-facebook.service is stopped - service: + ansible.builtin.service: name: matrix-mautrix-facebook state: stopped enabled: false @@ -98,11 +98,11 @@ when: "matrix_mautrix_facebook_stat_database.stat.exists" - name: (Data relocation) Move mautrix-facebook database file to ./data directory - command: "mv {{ matrix_mautrix_facebook_base_path }}/mautrix-facebook.db {{ matrix_mautrix_facebook_data_path }}/mautrix-facebook.db" + ansible.builtin.command: "mv {{ matrix_mautrix_facebook_base_path }}/mautrix-facebook.db {{ matrix_mautrix_facebook_data_path }}/mautrix-facebook.db" when: "matrix_mautrix_facebook_stat_database.stat.exists" - name: Ensure mautrix-facebook config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_facebook_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_facebook_config_path }}/config.yaml" mode: 0644 @@ -110,7 +110,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-facebook registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_facebook_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_facebook_config_path }}/registration.yaml" mode: 0644 @@ -118,19 +118,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-facebook.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-facebook.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-facebook.service" mode: 0644 register: matrix_mautrix_facebook_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-facebook.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_facebook_systemd_service_result.changed" - name: Ensure matrix-mautrix-facebook.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mautrix-facebook.service" state: restarted when: "matrix_mautrix_facebook_requires_restart|bool" diff --git a/roles/matrix-bridge-mautrix-facebook/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-facebook/tasks/setup_uninstall.yml index 1c8fbd3b..cebdcdab 100644 --- a/roles/matrix-bridge-mautrix-facebook/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-facebook/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mautrix_facebook_service_stat - name: Ensure matrix-mautrix-facebook is stopped - service: + ansible.builtin.service: name: matrix-mautrix-facebook state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mautrix_facebook_service_stat.stat.exists" - name: Ensure matrix-mautrix-facebook.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-facebook.service" state: absent when: "matrix_mautrix_facebook_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-facebook.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_facebook_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-facebook/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-facebook/tasks/validate_config.yml index 7fcd6bea..986fbc63 100644 --- a/roles/matrix-bridge-mautrix-facebook/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-facebook/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -12,7 +12,7 @@ - block: - name: Inject warning if on an old SQLite-supporting version - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-bridge-mautrix-googlechat/tasks/init.yml b/roles/matrix-bridge-mautrix-googlechat/tasks/init.yml index 27845148..67cdd4a5 100644 --- a/roles/matrix-bridge-mautrix-googlechat/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-googlechat/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mautrix_googlechat_container_image_self_build and matrix_mautrix_googlechat_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-googlechat.service'] }}" when: matrix_mautrix_googlechat_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -29,7 +29,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Mautrix googlechat's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -38,7 +38,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Mautrix googlechat proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_mautrix_googlechat_matrix_nginx_proxy_configuration: | location {{ matrix_mautrix_googlechat_public_endpoint }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -52,7 +52,7 @@ {% endif %} } - name: Register Mautrix googlechat proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -64,7 +64,7 @@ when: matrix_mautrix_googlechat_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Mautrix googlechat bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-mautrix-googlechat/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-googlechat/tasks/setup_install.yml index bf04e834..a2544c57 100644 --- a/roles/matrix-bridge-mautrix-googlechat/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-googlechat/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-googlechat role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mautrix_googlechat_requires_restart: false - block: @@ -18,7 +18,7 @@ register: matrix_mautrix_googlechat_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mautrix_googlechat_sqlite_database_path_local }}" dst: "{{ matrix_mautrix_googlechat_database_connection_string }}" @@ -29,7 +29,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mautrix_googlechat_requires_restart: true when: "matrix_mautrix_googlechat_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mautrix_googlechat_database_engine == 'postgres'" @@ -47,7 +47,7 @@ until: result is not failed - name: Ensure Mautrix googlechat paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -61,7 +61,7 @@ when: "item.when|bool" - name: Ensure Mautrix Hangots repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_googlechat_container_image_self_build_repo }}" dest: "{{ matrix_mautrix_googlechat_docker_src_files_path }}" force: "yes" @@ -88,7 +88,7 @@ register: matrix_mautrix_googlechat_stat_database - name: (Data relocation) Ensure matrix-mautrix-googlechat.service is stopped - service: + ansible.builtin.service: name: matrix-mautrix-googlechat state: stopped enabled: false @@ -97,11 +97,11 @@ when: "matrix_mautrix_googlechat_stat_database.stat.exists" - name: (Data relocation) Move mautrix-googlechat database file to ./data directory - command: "mv {{ matrix_mautrix_googlechat_base_path }}/mautrix-googlechat.db {{ matrix_mautrix_googlechat_data_path }}/mautrix-googlechat.db" + ansible.builtin.command: "mv {{ matrix_mautrix_googlechat_base_path }}/mautrix-googlechat.db {{ matrix_mautrix_googlechat_data_path }}/mautrix-googlechat.db" when: "matrix_mautrix_googlechat_stat_database.stat.exists" - name: Ensure mautrix-googlechat config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_googlechat_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_googlechat_config_path }}/config.yaml" mode: 0644 @@ -109,7 +109,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-googlechat registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_googlechat_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_googlechat_config_path }}/registration.yaml" mode: 0644 @@ -117,19 +117,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-googlechat.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-googlechat.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-googlechat.service" mode: 0644 register: matrix_mautrix_googlechat_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-googlechat.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_googlechat_systemd_service_result.changed" - name: Ensure matrix-mautrix-googlechat.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mautrix-googlechat.service" state: restarted when: "matrix_mautrix_googlechat_requires_restart|bool" diff --git a/roles/matrix-bridge-mautrix-googlechat/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-googlechat/tasks/setup_uninstall.yml index a315c0c8..88955868 100644 --- a/roles/matrix-bridge-mautrix-googlechat/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-googlechat/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mautrix_googlechat_service_stat - name: Ensure matrix-mautrix-googlechat is stopped - service: + ansible.builtin.service: name: matrix-mautrix-googlechat state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mautrix_googlechat_service_stat.stat.exists" - name: Ensure matrix-mautrix-googlechat.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-googlechat.service" state: absent when: "matrix_mautrix_googlechat_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-googlechat.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_googlechat_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-googlechat/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-googlechat/tasks/validate_config.yml index 083e8d34..fc36472e 100644 --- a/roles/matrix-bridge-mautrix-googlechat/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-googlechat/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -9,6 +9,6 @@ - "matrix_mautrix_googlechat_public_endpoint" - "matrix_mautrix_googlechat_appservice_token" - "matrix_mautrix_googlechat_homeserver_token" -- debug: +- ansible.builtin.debug: msg: - '`matrix_mautrix_googlechat_homeserver_domain` == {{ matrix_mautrix_googlechat_homeserver_domain }}' diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml index d00e5252..6f7374ee 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mautrix_hangouts_container_image_self_build and matrix_mautrix_hangouts_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-hangouts.service'] }}" when: matrix_mautrix_hangouts_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -29,7 +29,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Mautrix Hangouts's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -38,7 +38,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Mautrix Hangouts proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_mautrix_hangouts_matrix_nginx_proxy_configuration: | location {{ matrix_mautrix_hangouts_public_endpoint }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -52,7 +52,7 @@ {% endif %} } - name: Register Mautrix Hangouts proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -64,7 +64,7 @@ when: matrix_mautrix_hangouts_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Mautrix Hangouts bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml index 6a880815..11456cc4 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-hangouts role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mautrix_hangouts_requires_restart: false - block: @@ -18,7 +18,7 @@ register: matrix_mautrix_hangouts_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mautrix_hangouts_sqlite_database_path_local }}" dst: "{{ matrix_mautrix_hangouts_database_connection_string }}" @@ -29,7 +29,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mautrix_hangouts_requires_restart: true when: "matrix_mautrix_hangouts_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mautrix_hangouts_database_engine == 'postgres'" @@ -47,7 +47,7 @@ until: result is not failed - name: Ensure Mautrix Hangouts paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -61,7 +61,7 @@ when: "item.when|bool" - name: Ensure Mautrix Hangots repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_hangouts_container_image_self_build_repo }}" dest: "{{ matrix_mautrix_hangouts_docker_src_files_path }}" force: "yes" @@ -88,7 +88,7 @@ register: matrix_mautrix_hangouts_stat_database - name: (Data relocation) Ensure matrix-mautrix-hangouts.service is stopped - service: + ansible.builtin.service: name: matrix-mautrix-hangouts state: stopped enabled: false @@ -97,11 +97,11 @@ when: "matrix_mautrix_hangouts_stat_database.stat.exists" - name: (Data relocation) Move mautrix-hangouts database file to ./data directory - command: "mv {{ matrix_mautrix_hangouts_base_path }}/mautrix-hangouts.db {{ matrix_mautrix_hangouts_data_path }}/mautrix-hangouts.db" + ansible.builtin.command: "mv {{ matrix_mautrix_hangouts_base_path }}/mautrix-hangouts.db {{ matrix_mautrix_hangouts_data_path }}/mautrix-hangouts.db" when: "matrix_mautrix_hangouts_stat_database.stat.exists" - name: Ensure mautrix-hangouts config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_hangouts_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_hangouts_config_path }}/config.yaml" mode: 0644 @@ -109,7 +109,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-hangouts registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_hangouts_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_hangouts_config_path }}/registration.yaml" mode: 0644 @@ -117,19 +117,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-hangouts.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-hangouts.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-hangouts.service" mode: 0644 register: matrix_mautrix_hangouts_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-hangouts.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_hangouts_systemd_service_result.changed" - name: Ensure matrix-mautrix-hangouts.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mautrix-hangouts.service" state: restarted when: "matrix_mautrix_hangouts_requires_restart|bool" diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml index 8ce859c8..f3234a2e 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mautrix_hangouts_service_stat - name: Ensure matrix-mautrix-hangouts is stopped - service: + ansible.builtin.service: name: matrix-mautrix-hangouts state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mautrix_hangouts_service_stat.stat.exists" - name: Ensure matrix-mautrix-hangouts.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-hangouts.service" state: absent when: "matrix_mautrix_hangouts_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-hangouts.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_hangouts_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml index 0242ef16..c80586e0 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -9,6 +9,6 @@ - "matrix_mautrix_hangouts_public_endpoint" - "matrix_mautrix_hangouts_appservice_token" - "matrix_mautrix_hangouts_homeserver_token" -- debug: +- ansible.builtin.debug: msg: - '`matrix_mautrix_hangouts_homeserver_domain` == {{ matrix_mautrix_hangouts_homeserver_domain }}' diff --git a/roles/matrix-bridge-mautrix-instagram/tasks/init.yml b/roles/matrix-bridge-mautrix-instagram/tasks/init.yml index 86713380..e3b4c58c 100644 --- a/roles/matrix-bridge-mautrix-instagram/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-instagram/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mautrix_instagram_container_image_self_build and matrix_mautrix_instagram_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-instagram.service'] }}" when: matrix_mautrix_instagram_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mautrix-instagram/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-instagram/tasks/setup_install.yml index 5e30adbe..98fa1157 100644 --- a/roles/matrix-bridge-mautrix-instagram/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-instagram/tasks/setup_install.yml @@ -2,7 +2,7 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-instagram role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" @@ -20,7 +20,7 @@ until: result is not failed - name: Ensure Mautrix instagram paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -34,7 +34,7 @@ when: item.when|bool - name: Ensure Mautrix instagram repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_instagram_container_image_self_build_repo }}" dest: "{{ matrix_mautrix_instagram_docker_src_files_path }}" force: "yes" @@ -56,7 +56,7 @@ when: "matrix_mautrix_instagram_container_image_self_build|bool" - name: Ensure mautrix-instagram config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_instagram_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_instagram_config_path }}/config.yaml" mode: 0644 @@ -64,7 +64,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-instagram registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_instagram_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_instagram_config_path }}/registration.yaml" mode: 0644 @@ -72,13 +72,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-instagram.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-instagram.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-instagram.service" mode: 0644 register: matrix_mautrix_instagram_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-instagram.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_instagram_systemd_service_result.changed" diff --git a/roles/matrix-bridge-mautrix-instagram/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-instagram/tasks/setup_uninstall.yml index 2cc0e0e9..ef90f01f 100644 --- a/roles/matrix-bridge-mautrix-instagram/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-instagram/tasks/setup_uninstall.yml @@ -5,7 +5,7 @@ register: matrix_mautrix_instagram_service_stat - name: Ensure matrix-mautrix-instagram is stopped - service: + ansible.builtin.service: name: matrix-mautrix-instagram state: stopped enabled: false @@ -13,12 +13,12 @@ when: "matrix_mautrix_instagram_service_stat.stat.exists" - name: Ensure matrix-mautrix-instagram.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-instagram.service" state: absent when: "matrix_mautrix_instagram_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-instagram.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_instagram_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-instagram/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-instagram/tasks/validate_config.yml index 24992ff5..99f7b015 100644 --- a/roles/matrix-bridge-mautrix-instagram/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-instagram/tasks/validate_config.yml @@ -1,6 +1,6 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mautrix-signal/tasks/init.yml b/roles/matrix-bridge-mautrix-signal/tasks/init.yml index b9b698c5..4d9a2448 100644 --- a/roles/matrix-bridge-mautrix-signal/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-signal/tasks/init.yml @@ -1,11 +1,11 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-signal.service', 'matrix-mautrix-signal-daemon.service'] }}" when: matrix_mautrix_signal_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mautrix-signal/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-signal/tasks/setup_install.yml index 06f77348..b7afb351 100644 --- a/roles/matrix-bridge-mautrix-signal/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-signal/tasks/setup_install.yml @@ -3,7 +3,7 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-signal role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" @@ -22,7 +22,7 @@ - name: Ensure Mautrix Signal repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_signal_docker_repo }}" dest: "{{ matrix_mautrix_signal_docker_src_files_path }}" force: "yes" @@ -54,7 +54,7 @@ register: matrix_mautrix_signal_daemon_pull_results - name: Ensure Mautrix Signal Daemon repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_signal_daemon_docker_repo }}" dest: "{{ matrix_mautrix_signal_daemon_docker_src_files_path }}" force: "yes" @@ -76,7 +76,7 @@ when: "matrix_mautrix_signal_daemon_container_image_self_build|bool" - name: Ensure Mautrix Signal paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -91,7 +91,7 @@ - "{{ matrix_mautrix_signal_daemon_path }}/data" - name: Ensure mautrix-signal config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_signal_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_signal_config_path }}/config.yaml" mode: 0644 @@ -99,7 +99,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-signal registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_signal_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_signal_config_path }}/registration.yaml" mode: 0644 @@ -107,20 +107,20 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-signal-daemon.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-signal-daemon.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-signal-daemon.service" mode: 0644 register: matrix_mautrix_signal_daemon_systemd_service_result - name: Ensure matrix-mautrix-signal.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-signal.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-signal.service" mode: 0644 register: matrix_mautrix_signal_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-signal.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_signal_systemd_service_result.changed or matrix_mautrix_signal_daemon_systemd_service_result.changed" diff --git a/roles/matrix-bridge-mautrix-signal/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-signal/tasks/setup_uninstall.yml index 8ca2be3f..33f1b9f5 100644 --- a/roles/matrix-bridge-mautrix-signal/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-signal/tasks/setup_uninstall.yml @@ -7,7 +7,7 @@ register: matrix_mautrix_signal_daemon_service_stat - name: Ensure matrix-mautrix-signal-daemon is stopped - service: + ansible.builtin.service: name: matrix-mautrix-signal-daemon state: stopped enabled: false @@ -15,7 +15,7 @@ when: "matrix_mautrix_signal_daemon_service_stat.stat.exists" - name: Ensure matrix-mautrix-signal-daemon.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-signal-daemon.service" state: absent when: "matrix_mautrix_signal_daemon_service_stat.stat.exists" @@ -27,7 +27,7 @@ register: matrix_mautrix_signal_service_stat - name: Ensure matrix-mautrix-signal is stopped - service: + ansible.builtin.service: name: matrix-mautrix-signal state: stopped enabled: false @@ -35,13 +35,13 @@ when: "matrix_mautrix_signal_service_stat.stat.exists" - name: Ensure matrix-mautrix-signal.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-signal.service" state: absent when: "matrix_mautrix_signal_service_stat.stat.exists" # All services - name: Ensure systemd reloaded after matrix-mautrix-signal_X.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_signal_service_stat.stat.exists or matrix_mautrix_signal_daemon_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-signal/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-signal/tasks/validate_config.yml index 108ac044..01a02c2f 100644 --- a/roles/matrix-bridge-mautrix-signal/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-signal/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -12,7 +12,7 @@ - "matrix_mautrix_signal_appservice_token" - name: (Deprecation) Catch and report renamed Signal variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-bridge-mautrix-telegram/tasks/init.yml b/roles/matrix-bridge-mautrix-telegram/tasks/init.yml index 93b4d9f8..a9cc0425 100644 --- a/roles/matrix-bridge-mautrix-telegram/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-telegram/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mautrix_telegram_container_image_self_build and matrix_mautrix_telegram_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-telegram.service'] }}" when: matrix_mautrix_telegram_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -29,7 +29,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Mautrix Telegram's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -38,7 +38,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Mautrix Telegram proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_mautrix_telegram_matrix_nginx_proxy_configuration: | location {{ matrix_mautrix_telegram_public_endpoint }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -53,7 +53,7 @@ } - name: Register Mautrix Telegram proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -61,7 +61,7 @@ [matrix_mautrix_telegram_matrix_nginx_proxy_configuration] }} - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Mautrix Telegram bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-mautrix-telegram/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-telegram/tasks/setup_install.yml index 55e7d016..d530d2b9 100644 --- a/roles/matrix-bridge-mautrix-telegram/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-telegram/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-telegram role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mautrix_telegram_requires_restart: false - block: @@ -18,7 +18,7 @@ register: matrix_mautrix_telegram_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mautrix_telegram_sqlite_database_path_local }}" dst: "{{ matrix_mautrix_telegram_database_connection_string }}" @@ -29,13 +29,13 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mautrix_telegram_requires_restart: true when: "matrix_mautrix_telegram_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mautrix_telegram_database_engine == 'postgres'" - name: Ensure Mautrix Telegram paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -61,7 +61,7 @@ until: result is not failed - name: Ensure lottieconverter is present when self-building - git: + ansible.builtin.git: repo: "{{ matrix_telegram_lottieconverter_docker_repo }}" dest: "{{ matrix_telegram_lottieconverter_docker_src_files_path }}" force: "yes" @@ -83,7 +83,7 @@ when: "matrix_telegram_lottieconverter_container_image_self_build|bool and matrix_telegram_lottieconverter_git_pull_results.changed and matrix_mautrix_telegram_container_image_self_build|bool" - name: Ensure matrix-mautrix-telegram repository is present when self-building - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_telegram_docker_repo }}" dest: "{{ matrix_mautrix_telegram_docker_src_files_path }}" force: "yes" @@ -112,7 +112,7 @@ register: matrix_mautrix_telegram_stat_database - name: (Data relocation) Ensure matrix-mautrix-telegram.service is stopped - service: + ansible.builtin.service: name: matrix-mautrix-telegram state: stopped enabled: false @@ -121,11 +121,11 @@ when: "matrix_mautrix_telegram_stat_database.stat.exists" - name: (Data relocation) Move mautrix-telegram database file to ./data directory - command: "mv {{ matrix_mautrix_telegram_base_path }}/mautrix-telegram.db {{ matrix_mautrix_telegram_data_path }}/mautrix-telegram.db" + ansible.builtin.command: "mv {{ matrix_mautrix_telegram_base_path }}/mautrix-telegram.db {{ matrix_mautrix_telegram_data_path }}/mautrix-telegram.db" when: "matrix_mautrix_telegram_stat_database.stat.exists" - name: Ensure mautrix-telegram config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_telegram_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_telegram_config_path }}/config.yaml" mode: 0644 @@ -133,7 +133,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-telegram registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_telegram_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_telegram_config_path }}/registration.yaml" mode: 0644 @@ -141,19 +141,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-telegram.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-telegram.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-telegram.service" mode: 0644 register: matrix_mautrix_telegram_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-telegram.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_telegram_systemd_service_result.changed" - name: Ensure matrix-mautrix-telegram.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mautrix-telegram.service" state: restarted when: "matrix_mautrix_telegram_requires_restart|bool" diff --git a/roles/matrix-bridge-mautrix-telegram/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-telegram/tasks/setup_uninstall.yml index a713898b..01b58313 100644 --- a/roles/matrix-bridge-mautrix-telegram/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-telegram/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mautrix_telegram_service_stat - name: Ensure matrix-mautrix-telegram is stopped - service: + ansible.builtin.service: name: matrix-mautrix-telegram state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mautrix_telegram_service_stat.stat.exists" - name: Ensure matrix-mautrix-telegram.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-telegram.service" state: absent when: "matrix_mautrix_telegram_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-telegram.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_telegram_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-telegram/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-telegram/tasks/validate_config.yml index 2067b97b..9711448b 100644 --- a/roles/matrix-bridge-mautrix-telegram/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-telegram/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -13,7 +13,7 @@ - "matrix_mautrix_telegram_homeserver_token" - name: (Deprecation) Catch and report renamed Telegram variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-bridge-mautrix-twitter/tasks/init.yml b/roles/matrix-bridge-mautrix-twitter/tasks/init.yml index 34f4ebde..3fdd66d8 100644 --- a/roles/matrix-bridge-mautrix-twitter/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-twitter/tasks/init.yml @@ -1,11 +1,11 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-twitter.service'] }}" when: matrix_mautrix_twitter_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -24,6 +24,6 @@ # ansible lower than 2.8, does not support docker_image build parameters # for self buildig it is explicitly needed, so we rather fail here - name: Fail if running on Ansible lower than 2.8 and trying self building - fail: + ansible.builtin.fail: msg: "To self build Mautrix Twitter image, you should usa ansible 2.8 or higher. E.g. pip contains such packages." when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mautrix_twitter_container_image_self_build" diff --git a/roles/matrix-bridge-mautrix-twitter/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-twitter/tasks/setup_install.yml index 552c9d52..167176a8 100644 --- a/roles/matrix-bridge-mautrix-twitter/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-twitter/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-twitter role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mautrix_twitter_requires_restart: false - name: Ensure Mautrix Twitter image is pulled @@ -24,7 +24,7 @@ until: result is not failed - name: Ensure Mautrix Twitter paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -38,7 +38,7 @@ when: item.when|bool - name: Ensure Mautrix Twitter repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_twitter_container_image_self_build_repo }}" dest: "{{ matrix_mautrix_twitter_docker_src_files_path }}" # version: "{{ matrix_coturn_docker_image.split(':')[1] }}" @@ -60,7 +60,7 @@ when: "matrix_mautrix_twitter_enabled|bool and matrix_mautrix_twitter_container_image_self_build|bool" - name: Ensure mautrix-twitter config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_twitter_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_twitter_config_path }}/config.yaml" mode: 0644 @@ -68,7 +68,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-twitter registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_twitter_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_twitter_config_path }}/registration.yaml" mode: 0644 @@ -76,19 +76,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-twitter.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-twitter.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-twitter.service" mode: 0644 register: matrix_mautrix_twitter_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-twitter.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_twitter_systemd_service_result.changed" - name: Ensure matrix-mautrix-twitter.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mautrix-twitter.service" state: restarted when: "matrix_mautrix_twitter_requires_restart|bool" diff --git a/roles/matrix-bridge-mautrix-twitter/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-twitter/tasks/setup_uninstall.yml index 024603e7..9c357931 100644 --- a/roles/matrix-bridge-mautrix-twitter/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-twitter/tasks/setup_uninstall.yml @@ -6,19 +6,19 @@ register: matrix_mautrix_twitter_service_stat - name: Ensure matrix-mautrix-twitter is stopped - service: + ansible.builtin.service: name: matrix-mautrix-twitter state: stopped daemon_reload: true when: "matrix_mautrix_twitter_service_stat.stat.exists" - name: Ensure matrix-mautrix-twitter.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-twitter.service" state: absent when: "matrix_mautrix_twitter_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-twitter.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_twitter_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml index 5b6e3d02..326dca83 100644 --- a/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mautrix-whatsapp/tasks/init.yml b/roles/matrix-bridge-mautrix-whatsapp/tasks/init.yml index d4fb8221..75a0134b 100644 --- a/roles/matrix-bridge-mautrix-whatsapp/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-whatsapp/tasks/init.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-whatsapp.service'] }}" when: matrix_mautrix_whatsapp_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_install.yml index f47675b5..59e5fe0e 100644 --- a/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_install.yml @@ -3,12 +3,12 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mautrix-whatsapp role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mautrix_whatsapp_requires_restart: false - block: @@ -18,7 +18,7 @@ register: matrix_mautrix_whatsapp_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mautrix_whatsapp_sqlite_database_path_local }}" dst: "{{ matrix_mautrix_whatsapp_database_connection_string }}" @@ -30,14 +30,14 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mautrix_whatsapp_requires_restart: true when: "matrix_mautrix_whatsapp_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mautrix_whatsapp_database_engine == 'postgres'" - name: Ensure Mautrix Whatsapp paths exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -63,7 +63,7 @@ until: result is not failed - name: Ensure Mautrix Whatsapp repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_mautrix_whatsapp_container_image_self_build_repo }}" dest: "{{ matrix_mautrix_whatsapp_docker_src_files_path }}" version: "{{ matrix_mautrix_whatsapp_container_image_self_build_branch }}" @@ -96,7 +96,7 @@ register: matrix_mautrix_whatsapp_stat_mx_state - name: (Data relocation) Ensure matrix-mautrix-whatsapp.service is stopped - service: + ansible.builtin.service: name: matrix-mautrix-whatsapp state: stopped enabled: false @@ -105,15 +105,15 @@ when: "matrix_mautrix_whatsapp_stat_database.stat.exists" - name: (Data relocation) Move mautrix-whatsapp database file to ./data directory - command: "mv {{ matrix_mautrix_whatsapp_base_path }}/mautrix-whatsapp.db {{ matrix_mautrix_whatsapp_data_path }}/mautrix-whatsapp.db" + ansible.builtin.command: "mv {{ matrix_mautrix_whatsapp_base_path }}/mautrix-whatsapp.db {{ matrix_mautrix_whatsapp_data_path }}/mautrix-whatsapp.db" when: "matrix_mautrix_whatsapp_stat_database.stat.exists" - name: (Data relocation) Move mautrix-whatsapp mx-state file to ./data directory - command: "mv {{ matrix_mautrix_whatsapp_base_path }}/mx-state.json {{ matrix_mautrix_whatsapp_data_path }}/mx-state.json" + ansible.builtin.command: "mv {{ matrix_mautrix_whatsapp_base_path }}/mx-state.json {{ matrix_mautrix_whatsapp_data_path }}/mx-state.json" when: "matrix_mautrix_whatsapp_stat_mx_state.stat.exists" - name: Ensure mautrix-whatsapp config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_whatsapp_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_whatsapp_config_path }}/config.yaml" mode: 0644 @@ -121,7 +121,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mautrix-whatsapp registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mautrix_whatsapp_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mautrix_whatsapp_config_path }}/registration.yaml" mode: 0644 @@ -129,19 +129,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mautrix-whatsapp.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-whatsapp.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mautrix-whatsapp.service" mode: 0644 register: matrix_mautrix_whatsapp_systemd_service_result - name: Ensure systemd reloaded after matrix-mautrix-whatsapp.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_whatsapp_systemd_service_result.changed" - name: Ensure matrix-mautrix-whatsapp.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mautrix-whatsapp.service" state: restarted when: "matrix_mautrix_whatsapp_requires_restart|bool" diff --git a/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_uninstall.yml index 3884f9e7..94f7f30a 100644 --- a/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mautrix-whatsapp/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mautrix_whatsapp_service_stat - name: Ensure matrix-mautrix-whatsapp is stopped - service: + ansible.builtin.service: name: matrix-mautrix-whatsapp state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mautrix_whatsapp_service_stat.stat.exists" - name: Ensure matrix-mautrix-whatsapp.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mautrix-whatsapp.service" state: absent when: "matrix_mautrix_whatsapp_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-whatsapp.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mautrix_whatsapp_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-whatsapp/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-whatsapp/tasks/validate_config.yml index 9b0a725c..863dc926 100644 --- a/roles/matrix-bridge-mautrix-whatsapp/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-whatsapp/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -11,7 +11,7 @@ - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-bridge-mx-puppet-discord/tasks/init.yml b/roles/matrix-bridge-mx-puppet-discord/tasks/init.yml index 115ccf35..ca009028 100644 --- a/roles/matrix-bridge-mx-puppet-discord/tasks/init.yml +++ b/roles/matrix-bridge-mx-puppet-discord/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mx_puppet_discord_container_image_self_build and matrix_mx_puppet_discord_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mx-puppet-discord.service'] }}" when: matrix_mx_puppet_discord_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mx-puppet-discord/tasks/setup_install.yml b/roles/matrix-bridge-mx-puppet-discord/tasks/setup_install.yml index 3ddfa39d..3c3c43a0 100644 --- a/roles/matrix-bridge-mx-puppet-discord/tasks/setup_install.yml +++ b/roles/matrix-bridge-mx-puppet-discord/tasks/setup_install.yml @@ -3,13 +3,13 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mx-puppet-discord role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - name: Ensure MX Puppet Discord paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -29,17 +29,17 @@ - block: - name: (Data relocation) Ensure matrix-mx-puppet-discord.service is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-discord state: stopped daemon_reload: true failed_when: false - name: (Data relocation) Move mx-puppet-discord database file to ./data directory - command: "mv {{ matrix_mx_puppet_discord_base_path }}/database.db {{ matrix_mx_puppet_discord_data_path }}/database.db" + ansible.builtin.command: "mv {{ matrix_mx_puppet_discord_base_path }}/database.db {{ matrix_mx_puppet_discord_data_path }}/database.db" when: "matrix_mx_puppet_discord_stat_database.stat.exists" -- set_fact: +- ansible.builtin.set_fact: matrix_mx_puppet_discord_requires_restart: false - block: @@ -49,7 +49,7 @@ register: matrix_mx_puppet_discord_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mx_puppet_discord_sqlite_database_path_local }}" dst: "{{ matrix_mx_puppet_discord_database_connection_string }}" @@ -60,7 +60,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mx_puppet_discord_requires_restart: true when: "matrix_mx_puppet_discord_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mx_puppet_discord_database_engine == 'postgres'" @@ -78,7 +78,7 @@ until: result is not failed - name: Ensure MX Puppet Discord repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mx_puppet_discord_container_image_self_build_repo }}" dest: "{{ matrix_mx_puppet_discord_docker_src_files_path }}" force: "yes" @@ -101,7 +101,7 @@ when: "matrix_mx_puppet_discord_enabled|bool and matrix_mx_puppet_discord_container_image_self_build|bool" - name: Ensure mx-puppet-discord config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_discord_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_discord_config_path }}/config.yaml" mode: 0644 @@ -109,7 +109,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mx-puppet-discord discord-registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_discord_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_discord_config_path }}/registration.yaml" mode: 0644 @@ -117,19 +117,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mx-puppet-discord.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mx-puppet-discord.service.j2" dest: "/etc/systemd/system/matrix-mx-puppet-discord.service" mode: 0644 register: matrix_mx_puppet_discord_systemd_service_result - name: Ensure systemd reloaded after matrix-mx-puppet-discord.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_discord_systemd_service_result.changed" - name: Ensure matrix-mx-puppet-discord.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mx-puppet-discord.service" state: restarted when: "matrix_mx_puppet_discord_requires_restart|bool" diff --git a/roles/matrix-bridge-mx-puppet-discord/tasks/setup_uninstall.yml b/roles/matrix-bridge-mx-puppet-discord/tasks/setup_uninstall.yml index b3ab8e39..beff6c5d 100644 --- a/roles/matrix-bridge-mx-puppet-discord/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mx-puppet-discord/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mx_puppet_discord_service_stat - name: Ensure matrix-mx-puppet-discord is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-discord state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mx_puppet_discord_service_stat.stat.exists" - name: Ensure matrix-mx-puppet-discord.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-mx-puppet-discord.service" state: absent when: "matrix_mx_puppet_discord_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mx-puppet-discord.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_discord_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mx-puppet-discord/tasks/validate_config.yml b/roles/matrix-bridge-mx-puppet-discord/tasks/validate_config.yml index c253eda2..e73a868a 100644 --- a/roles/matrix-bridge-mx-puppet-discord/tasks/validate_config.yml +++ b/roles/matrix-bridge-mx-puppet-discord/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mx-puppet-groupme/tasks/init.yml b/roles/matrix-bridge-mx-puppet-groupme/tasks/init.yml index 9bada5d8..0791546d 100644 --- a/roles/matrix-bridge-mx-puppet-groupme/tasks/init.yml +++ b/roles/matrix-bridge-mx-puppet-groupme/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mx_puppet_groupme_container_image_self_build and matrix_mx_puppet_groupme_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mx-puppet-groupme.service'] }}" when: matrix_mx_puppet_groupme_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_install.yml b/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_install.yml index 286c5611..9ca9c7ea 100644 --- a/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_install.yml +++ b/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_install.yml @@ -3,13 +3,13 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mx-puppet-groupme role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - name: Ensure MX Puppet Groupme paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ register: matrix_mx_puppet_groupme_stat_database - name: (Data relocation) Ensure matrix-mx-puppet-groupme.service is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-groupme state: stopped enabled: false @@ -37,10 +37,10 @@ when: "matrix_mx_puppet_groupme_stat_database.stat.exists" - name: (Data relocation) Move mx-puppet-groupme database file to ./data directory - command: "mv {{ matrix_mx_puppet_groupme_base_path }}/database.db {{ matrix_mx_puppet_groupme_data_path }}/database.db" + ansible.builtin.command: "mv {{ matrix_mx_puppet_groupme_base_path }}/database.db {{ matrix_mx_puppet_groupme_data_path }}/database.db" when: "matrix_mx_puppet_groupme_stat_database.stat.exists" -- set_fact: +- ansible.builtin.set_fact: matrix_mx_puppet_groupme_requires_restart: false - block: @@ -50,7 +50,7 @@ register: matrix_mx_puppet_groupme_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mx_puppet_groupme_sqlite_database_path_local }}" dst: "{{ matrix_mx_puppet_groupme_database_connection_string }}" @@ -61,7 +61,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mx_puppet_groupme_requires_restart: true when: "matrix_mx_puppet_groupme_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mx_puppet_groupme_database_engine == 'postgres'" @@ -79,7 +79,7 @@ until: result is not failed - name: Ensure MX Puppet Groupme repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mx_puppet_groupme_container_image_self_build_repo }}" dest: "{{ matrix_mx_puppet_groupme_docker_src_files_path }}" force: "yes" @@ -101,7 +101,7 @@ when: "matrix_mx_puppet_groupme_enabled|bool and matrix_mx_puppet_groupme_container_image_self_build" - name: Ensure mx-puppet-groupme config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_groupme_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_groupme_config_path }}/config.yaml" mode: 0644 @@ -109,7 +109,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mx-puppet-groupme groupme-registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_groupme_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_groupme_config_path }}/registration.yaml" mode: 0644 @@ -117,19 +117,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mx-puppet-groupme.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mx-puppet-groupme.service.j2" dest: "/etc/systemd/system/matrix-mx-puppet-groupme.service" mode: 0644 register: matrix_mx_puppet_groupme_systemd_service_result - name: Ensure systemd reloaded after matrix-mx-puppet-groupme.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_groupme_systemd_service_result.changed" - name: Ensure matrix-mx-puppet-groupme.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mx-puppet-groupme.service" state: restarted when: "matrix_mx_puppet_groupme_requires_restart|bool" diff --git a/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_uninstall.yml b/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_uninstall.yml index 24daf7be..faf5ac0a 100644 --- a/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mx-puppet-groupme/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mx_puppet_groupme_service_stat - name: Ensure matrix-mx-puppet-groupme is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-groupme state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mx_puppet_groupme_service_stat.stat.exists" - name: Ensure matrix-mx-puppet-groupme.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-mx-puppet-groupme.service" state: absent when: "matrix_mx_puppet_groupme_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mx-puppet-groupme.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_groupme_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mx-puppet-groupme/tasks/validate_config.yml b/roles/matrix-bridge-mx-puppet-groupme/tasks/validate_config.yml index 5c5463ce..d091de6d 100644 --- a/roles/matrix-bridge-mx-puppet-groupme/tasks/validate_config.yml +++ b/roles/matrix-bridge-mx-puppet-groupme/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mx-puppet-instagram/tasks/init.yml b/roles/matrix-bridge-mx-puppet-instagram/tasks/init.yml index ae6302b3..3f2b98dc 100644 --- a/roles/matrix-bridge-mx-puppet-instagram/tasks/init.yml +++ b/roles/matrix-bridge-mx-puppet-instagram/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mx_puppet_instagram_container_image_self_build and matrix_mx_puppet_instagram_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mx-puppet-instagram.service'] }}" when: matrix_mx_puppet_instagram_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_install.yml b/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_install.yml index 2e74c059..4048e175 100644 --- a/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_install.yml +++ b/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_install.yml @@ -3,13 +3,13 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mx-puppet-instagram role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_mx_puppet_instagram_requires_restart: false - block: @@ -19,7 +19,7 @@ register: matrix_mx_puppet_instagram_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mx_puppet_instagram_sqlite_database_path_local }}" dst: "{{ matrix_mx_puppet_instagram_database_connection_string }}" @@ -30,7 +30,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mx_puppet_instagram_requires_restart: true when: "matrix_mx_puppet_instagram_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mx_puppet_instagram_database_engine == 'postgres'" @@ -48,7 +48,7 @@ until: result is not failed - name: Ensure mx-puppet-instagram paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -62,7 +62,7 @@ when: matrix_mx_puppet_instagram_enabled|bool and item.when|bool - name: Ensure mx-puppet-instagram repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mx_puppet_instagram_container_image_self_build_repo }}" dest: "{{ matrix_mx_puppet_instagram_docker_src_files_path }}" force: "yes" @@ -84,7 +84,7 @@ when: "matrix_mx_puppet_instagram_enabled|bool and matrix_mx_puppet_instagram_container_image_self_build|bool" - name: Ensure mx-puppet-instagram config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_instagram_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_instagram_config_path }}/config.yaml" mode: 0644 @@ -92,7 +92,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mx-puppet-instagram-registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_instagram_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_instagram_config_path }}/registration.yaml" mode: 0644 @@ -100,19 +100,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mx-puppet-instagram.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mx-puppet-instagram.service.j2" dest: "/etc/systemd/system/matrix-mx-puppet-instagram.service" mode: 0644 register: matrix_mx_puppet_instagram_systemd_service_result - name: Ensure systemd reloaded after matrix-mx-puppet-instagram.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_instagram_systemd_service_result.changed" - name: Ensure matrix-mx-puppet-instagram.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mx-puppet-instagram.service" state: restarted when: "matrix_mx_puppet_instagram_requires_restart|bool" diff --git a/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_uninstall.yml b/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_uninstall.yml index e4435a3e..cb876e2a 100644 --- a/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mx-puppet-instagram/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mx_puppet_instagram_service_stat - name: Ensure matrix-mx-puppet-instagram is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-instagram state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mx_puppet_instagram_service_stat.stat.exists" - name: Ensure matrix-mx-puppet-instagram.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-mx-puppet-instagram.service" state: absent when: "matrix_mx_puppet_instagram_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mx-puppet-instagram.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_instagram_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mx-puppet-instagram/tasks/validate_config.yml b/roles/matrix-bridge-mx-puppet-instagram/tasks/validate_config.yml index b6d9d994..383fe502 100644 --- a/roles/matrix-bridge-mx-puppet-instagram/tasks/validate_config.yml +++ b/roles/matrix-bridge-mx-puppet-instagram/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mx-puppet-slack/tasks/init.yml b/roles/matrix-bridge-mx-puppet-slack/tasks/init.yml index ed6753a2..74a6ed44 100644 --- a/roles/matrix-bridge-mx-puppet-slack/tasks/init.yml +++ b/roles/matrix-bridge-mx-puppet-slack/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mx_puppet_slack_container_image_self_build and matrix_mx_puppet_slack_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mx-puppet-slack.service'] }}" when: matrix_mx_puppet_slack_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -29,7 +29,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Slack Appservice's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -38,7 +38,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Matrix MX Puppet Slack proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_mx_puppet_slack_matrix_nginx_proxy_configuration: | location {{ matrix_mx_puppet_slack_redirect_path }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -53,7 +53,7 @@ } - name: Register Slack Appservice proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -65,7 +65,7 @@ when: matrix_mx_puppet_slack_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Matrix Slack bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-mx-puppet-slack/tasks/setup_install.yml b/roles/matrix-bridge-mx-puppet-slack/tasks/setup_install.yml index 3a7dfb40..48408b5a 100644 --- a/roles/matrix-bridge-mx-puppet-slack/tasks/setup_install.yml +++ b/roles/matrix-bridge-mx-puppet-slack/tasks/setup_install.yml @@ -3,13 +3,13 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mx-puppet-slack role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - name: Ensure MX Puppet Slack paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ register: matrix_mx_puppet_slack_stat_database - name: (Data relocation) Ensure matrix-mx-puppet-slack.service is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-slack state: stopped enabled: false @@ -36,7 +36,7 @@ failed_when: false when: "matrix_mx_puppet_slack_stat_database.stat.exists" -- set_fact: +- ansible.builtin.set_fact: matrix_mx_puppet_slack_requires_restart: false - block: @@ -46,7 +46,7 @@ register: matrix_mx_puppet_slack_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mx_puppet_slack_sqlite_database_path_local }}" dst: "{{ matrix_mx_puppet_slack_database_connection_string }}" @@ -57,7 +57,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mx_puppet_slack_requires_restart: true when: "matrix_mx_puppet_slack_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mx_puppet_slack_database_engine == 'postgres'" @@ -75,7 +75,7 @@ until: result is not failed - name: Ensure MX Puppet Slack repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mx_puppet_slack_container_image_self_build_repo }}" dest: "{{ matrix_mx_puppet_slack_docker_src_files_path }}" force: "yes" @@ -98,11 +98,11 @@ when: "matrix_mx_puppet_slack_enabled|bool and matrix_mx_puppet_slack_container_image_self_build" - name: (Data relocation) Move mx-puppet-slack database file to ./data directory - command: "mv {{ matrix_mx_puppet_slack_base_path }}/database.db {{ matrix_mx_puppet_slack_data_path }}/database.db" + ansible.builtin.command: "mv {{ matrix_mx_puppet_slack_base_path }}/database.db {{ matrix_mx_puppet_slack_data_path }}/database.db" when: "matrix_mx_puppet_slack_stat_database.stat.exists" - name: Ensure mx-puppet-slack config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_slack_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_slack_config_path }}/config.yaml" mode: 0644 @@ -110,7 +110,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mx-puppet-slack slack-registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_slack_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_slack_config_path }}/registration.yaml" mode: 0644 @@ -118,19 +118,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mx-puppet-slack.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mx-puppet-slack.service.j2" dest: "/etc/systemd/system/matrix-mx-puppet-slack.service" mode: 0644 register: matrix_mx_puppet_slack_systemd_service_result - name: Ensure systemd reloaded after matrix-mx-puppet-slack.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_slack_systemd_service_result.changed" - name: Ensure matrix-mx-puppet-slack.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mx-puppet-slack.service" state: restarted when: "matrix_mx_puppet_slack_requires_restart|bool" diff --git a/roles/matrix-bridge-mx-puppet-slack/tasks/setup_uninstall.yml b/roles/matrix-bridge-mx-puppet-slack/tasks/setup_uninstall.yml index 3a119267..835e20d7 100644 --- a/roles/matrix-bridge-mx-puppet-slack/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mx-puppet-slack/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mx_puppet_slack_service_stat - name: Ensure matrix-mx-puppet-slack is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-slack state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mx_puppet_slack_service_stat.stat.exists" - name: Ensure matrix-mx-puppet-slack.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-mx-puppet-slack.service" state: absent when: "matrix_mx_puppet_slack_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mx-puppet-slack.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_slack_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mx-puppet-slack/tasks/validate_config.yml b/roles/matrix-bridge-mx-puppet-slack/tasks/validate_config.yml index 3a0bca11..ea917f97 100644 --- a/roles/matrix-bridge-mx-puppet-slack/tasks/validate_config.yml +++ b/roles/matrix-bridge-mx-puppet-slack/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mx-puppet-steam/tasks/init.yml b/roles/matrix-bridge-mx-puppet-steam/tasks/init.yml index 9a171af7..7c5487f4 100644 --- a/roles/matrix-bridge-mx-puppet-steam/tasks/init.yml +++ b/roles/matrix-bridge-mx-puppet-steam/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mx_puppet_steam_container_image_self_build and matrix_mx_puppet_steam_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mx-puppet-steam.service'] }}" when: matrix_mx_puppet_steam_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-mx-puppet-steam/tasks/setup_install.yml b/roles/matrix-bridge-mx-puppet-steam/tasks/setup_install.yml index ac2a2fda..dfb7c6c9 100644 --- a/roles/matrix-bridge-mx-puppet-steam/tasks/setup_install.yml +++ b/roles/matrix-bridge-mx-puppet-steam/tasks/setup_install.yml @@ -3,13 +3,13 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mx-puppet-steam role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - name: Ensure MX Puppet Steam paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ register: matrix_mx_puppet_steam_stat_database - name: (Data relocation) Ensure matrix-mx-puppet-steam.service is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-steam state: stopped enabled: false @@ -37,10 +37,10 @@ when: "matrix_mx_puppet_steam_stat_database.stat.exists" - name: (Data relocation) Move mx-puppet-steam database file to ./data directory - command: "mv {{ matrix_mx_puppet_steam_base_path }}/database.db {{ matrix_mx_puppet_steam_data_path }}/database.db" + ansible.builtin.command: "mv {{ matrix_mx_puppet_steam_base_path }}/database.db {{ matrix_mx_puppet_steam_data_path }}/database.db" when: "matrix_mx_puppet_steam_stat_database.stat.exists" -- set_fact: +- ansible.builtin.set_fact: matrix_mx_puppet_steam_requires_restart: false - block: @@ -50,7 +50,7 @@ register: matrix_mx_puppet_steam_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mx_puppet_steam_sqlite_database_path_local }}" dst: "{{ matrix_mx_puppet_steam_database_connection_string }}" @@ -61,7 +61,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mx_puppet_steam_requires_restart: true when: "matrix_mx_puppet_steam_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mx_puppet_steam_database_engine == 'postgres'" @@ -79,7 +79,7 @@ until: result is not failed - name: Ensure MX Puppet Steam repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mx_puppet_steam_container_image_self_build_repo }}" dest: "{{ matrix_mx_puppet_steam_docker_src_files_path }}" force: "yes" @@ -101,7 +101,7 @@ when: "matrix_mx_puppet_steam_enabled|bool and matrix_mx_puppet_steam_container_image_self_build" - name: Ensure mx-puppet-steam config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_steam_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_steam_config_path }}/config.yaml" mode: 0644 @@ -109,7 +109,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mx-puppet-steam steam-registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_steam_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_steam_config_path }}/registration.yaml" mode: 0644 @@ -117,19 +117,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mx-puppet-steam.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mx-puppet-steam.service.j2" dest: "/etc/systemd/system/matrix-mx-puppet-steam.service" mode: 0644 register: matrix_mx_puppet_steam_systemd_service_result - name: Ensure systemd reloaded after matrix-mx-puppet-steam.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_steam_systemd_service_result.changed" - name: Ensure matrix-mx-puppet-steam.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mx-puppet-steam.service" state: restarted when: "matrix_mx_puppet_steam_requires_restart|bool" diff --git a/roles/matrix-bridge-mx-puppet-steam/tasks/setup_uninstall.yml b/roles/matrix-bridge-mx-puppet-steam/tasks/setup_uninstall.yml index 2e152ef6..7ec8245d 100644 --- a/roles/matrix-bridge-mx-puppet-steam/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mx-puppet-steam/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mx_puppet_steam_service_stat - name: Ensure matrix-mx-puppet-steam is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-steam state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mx_puppet_steam_service_stat.stat.exists" - name: Ensure matrix-mx-puppet-steam.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-mx-puppet-steam.service" state: absent when: "matrix_mx_puppet_steam_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mx-puppet-steam.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_steam_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mx-puppet-steam/tasks/validate_config.yml b/roles/matrix-bridge-mx-puppet-steam/tasks/validate_config.yml index a8bc6a42..2e54d6ff 100644 --- a/roles/matrix-bridge-mx-puppet-steam/tasks/validate_config.yml +++ b/roles/matrix-bridge-mx-puppet-steam/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-mx-puppet-twitter/tasks/init.yml b/roles/matrix-bridge-mx-puppet-twitter/tasks/init.yml index d774de15..53e2f2f5 100644 --- a/roles/matrix-bridge-mx-puppet-twitter/tasks/init.yml +++ b/roles/matrix-bridge-mx-puppet-twitter/tasks/init.yml @@ -2,16 +2,16 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mx_puppet_twitter_container_image_self_build and matrix_mx_puppet_twitter_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mx-puppet-twitter.service'] }}" when: matrix_mx_puppet_twitter_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) @@ -29,7 +29,7 @@ - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Twitter Appservice's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -38,7 +38,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Matrix MX Puppet Twitter proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_mx_puppet_twitter_matrix_nginx_proxy_configuration: | location {{ matrix_mx_puppet_twitter_webhook_path }} { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -53,7 +53,7 @@ } - name: Register Twitter Appservice proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -65,7 +65,7 @@ when: matrix_mx_puppet_twitter_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Matrix Twitter bridge but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_install.yml b/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_install.yml index 6336b0a0..34d522f5 100644 --- a/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_install.yml +++ b/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_install.yml @@ -3,13 +3,13 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-bridge-mx-puppet-twitter role needs to execute before the matrix-synapse role. when: "matrix_synapse_role_executed|default(False)" - name: Ensure MX Puppet Twitter paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ register: matrix_mx_puppet_twitter_stat_database - name: (Data relocation) Ensure matrix-mx-puppet-twitter.service is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-twitter state: stopped enabled: false @@ -37,10 +37,10 @@ when: "matrix_mx_puppet_twitter_stat_database.stat.exists" - name: (Data relocation) Move mx-puppet-twitter database file to ./data directory - command: "mv {{ matrix_mx_puppet_twitter_base_path }}/database.db {{ matrix_mx_puppet_twitter_data_path }}/database.db" + ansible.builtin.command: "mv {{ matrix_mx_puppet_twitter_base_path }}/database.db {{ matrix_mx_puppet_twitter_data_path }}/database.db" when: "matrix_mx_puppet_twitter_stat_database.stat.exists" -- set_fact: +- ansible.builtin.set_fact: matrix_mx_puppet_twitter_requires_restart: false - block: @@ -50,7 +50,7 @@ register: matrix_mx_puppet_twitter_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_mx_puppet_twitter_sqlite_database_path_local }}" dst: "{{ matrix_mx_puppet_twitter_database_connection_string }}" @@ -61,7 +61,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_mx_puppet_twitter_requires_restart: true when: "matrix_mx_puppet_twitter_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_mx_puppet_twitter_database_engine == 'postgres'" @@ -79,7 +79,7 @@ until: result is not failed - name: Ensure MX Puppet Twitter repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_mx_puppet_twitter_container_image_self_build_repo }}" dest: "{{ matrix_mx_puppet_twitter_docker_src_files_path }}" force: "yes" @@ -101,7 +101,7 @@ when: "matrix_mx_puppet_twitter_enabled|bool and matrix_mx_puppet_twitter_container_image_self_build" - name: Ensure mx-puppet-twitter config.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_twitter_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_twitter_config_path }}/config.yaml" mode: 0644 @@ -109,7 +109,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure mx-puppet-twitter twitter-registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_mx_puppet_twitter_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_mx_puppet_twitter_config_path }}/registration.yaml" mode: 0644 @@ -117,19 +117,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-mx-puppet-twitter.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mx-puppet-twitter.service.j2" dest: "/etc/systemd/system/matrix-mx-puppet-twitter.service" mode: 0644 register: matrix_mx_puppet_twitter_systemd_service_result - name: Ensure systemd reloaded after matrix-mx-puppet-twitter.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_twitter_systemd_service_result.changed" - name: Ensure matrix-mx-puppet-twitter.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-mx-puppet-twitter.service" state: restarted when: "matrix_mx_puppet_twitter_requires_restart|bool" diff --git a/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_uninstall.yml b/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_uninstall.yml index 56dcd9ce..2718634d 100644 --- a/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-mx-puppet-twitter/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_mx_puppet_twitter_service_stat - name: Ensure matrix-mx-puppet-twitter is stopped - service: + ansible.builtin.service: name: matrix-mx-puppet-twitter state: stopped enabled: false @@ -14,12 +14,12 @@ when: "matrix_mx_puppet_twitter_service_stat.stat.exists" - name: Ensure matrix-mx-puppet-twitter.service doesn't exist - file: + ansible.builtin.file: path: "/etc/systemd/system/matrix-mx-puppet-twitter.service" state: absent when: "matrix_mx_puppet_twitter_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mx-puppet-twitter.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mx_puppet_twitter_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mx-puppet-twitter/tasks/validate_config.yml b/roles/matrix-bridge-mx-puppet-twitter/tasks/validate_config.yml index d13a39e1..b5b7ef5b 100644 --- a/roles/matrix-bridge-mx-puppet-twitter/tasks/validate_config.yml +++ b/roles/matrix-bridge-mx-puppet-twitter/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-bridge-sms/tasks/init.yml b/roles/matrix-bridge-sms/tasks/init.yml index 9ee96b3e..4a3d1719 100644 --- a/roles/matrix-bridge-sms/tasks/init.yml +++ b/roles/matrix-bridge-sms/tasks/init.yml @@ -3,17 +3,17 @@ # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # We don't want to fail in such cases. - name: Fail if matrix-synapse role already executed - fail: + ansible.builtin.fail: msg: >- The matrix-sms-bridge role needs to execute before the matrix-synapse role. when: "matrix_sms_bridge_enabled and matrix_synapse_role_executed|default(False)" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sms-bridge.service'] }}" when: matrix_sms_bridge_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) diff --git a/roles/matrix-bridge-sms/tasks/setup_install.yml b/roles/matrix-bridge-sms/tasks/setup_install.yml index 412c26fe..ad6a9185 100644 --- a/roles/matrix-bridge-sms/tasks/setup_install.yml +++ b/roles/matrix-bridge-sms/tasks/setup_install.yml @@ -10,7 +10,7 @@ until: result is not failed - name: Ensure matrix-sms-bridge paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -22,7 +22,7 @@ - "{{ matrix_sms_bridge_data_path }}" - name: Ensure matrix-sms-bridge application.yml installed - copy: + ansible.builtin.copy: content: "{{ matrix_sms_bridge_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_sms_bridge_config_path }}/application.yml" mode: 0644 @@ -30,7 +30,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-sms-bridge registration.yaml installed - copy: + ansible.builtin.copy: content: "{{ matrix_sms_bridge_registration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_sms_bridge_config_path }}/registration.yaml" mode: 0644 @@ -38,7 +38,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure android-sms-gateway-server cert installed - copy: + ansible.builtin.copy: src: "{{ matrix_sms_bridge_provider_android_truststore_local_path }}" dest: "{{ matrix_sms_bridge_config_path }}/matrix-sms-gateway-server.p12" mode: 0644 @@ -47,13 +47,13 @@ when: matrix_sms_bridge_provider_android_truststore_local_path != "" - name: Ensure matrix-sms-bridge.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-sms-bridge.service.j2" dest: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" mode: 0644 register: matrix_sms_bridge_systemd_service_result - name: Ensure systemd reloaded after matrix-sms-bridge.service installation - service: + ansible.builtin.service: daemon_reload: true when: matrix_sms_bridge_systemd_service_result.changed diff --git a/roles/matrix-bridge-sms/tasks/setup_uninstall.yml b/roles/matrix-bridge-sms/tasks/setup_uninstall.yml index d74476eb..f0f966b2 100644 --- a/roles/matrix-bridge-sms/tasks/setup_uninstall.yml +++ b/roles/matrix-bridge-sms/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_sms_bridge_service_stat - name: Ensure matrix-sms-bridge is stopped - service: + ansible.builtin.service: name: matrix-sms-bridge state: stopped enabled: false @@ -14,7 +14,7 @@ when: "matrix_sms_bridge_service_stat.stat.exists" - name: Ensure matrix-sms-bridge.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" state: absent when: "matrix_sms_bridge_service_stat.stat.exists" diff --git a/roles/matrix-bridge-sms/tasks/validate_config.yml b/roles/matrix-bridge-sms/tasks/validate_config.yml index 96e41755..fa7dcfbd 100644 --- a/roles/matrix-bridge-sms/tasks/validate_config.yml +++ b/roles/matrix-bridge-sms/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-client-cinny/tasks/init.yml b/roles/matrix-client-cinny/tasks/init.yml index 04fbd8a2..4d1190dc 100644 --- a/roles/matrix-client-cinny/tasks/init.yml +++ b/roles/matrix-client-cinny/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Cinny image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_client_cinny_container_image_self_build and matrix_client_cinny_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-client-cinny.service'] }}" when: matrix_client_cinny_enabled|bool diff --git a/roles/matrix-client-cinny/tasks/self_check.yml b/roles/matrix-client-cinny/tasks/self_check.yml index d00408da..e0f9bfc1 100644 --- a/roles/matrix-client-cinny/tasks/self_check.yml +++ b/roles/matrix-client-cinny/tasks/self_check.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_client_cinny_url_endpoint_public: "https://{{ matrix_server_fqn_cinny }}/config.json" - name: Check Cinny - uri: + ansible.builtin.uri: url: "{{ matrix_client_cinny_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_client_cinny_self_check_validate_certificates }}" @@ -13,10 +13,10 @@ ignore_errors: true - name: Fail if Cinny not working - fail: + ansible.builtin.fail: msg: "Failed checking Cinny is up at `{{ matrix_server_fqn_cinny }}` (checked endpoint: `{{ matrix_client_cinny_url_endpoint_public }}`). Is Cinny running? Is port 443 open in your firewall? Full error: {{ matrix_client_cinny_self_check_result }}" when: "matrix_client_cinny_self_check_result.failed or 'json' not in matrix_client_cinny_self_check_result" - name: Report working Cinny - debug: + ansible.builtin.debug: msg: "Cinny at `{{ matrix_server_fqn_cinny }}` is working (checked endpoint: `{{ matrix_client_cinny_url_endpoint_public }}`)" diff --git a/roles/matrix-client-cinny/tasks/setup_install.yml b/roles/matrix-client-cinny/tasks/setup_install.yml index da979f56..3689586f 100644 --- a/roles/matrix-client-cinny/tasks/setup_install.yml +++ b/roles/matrix-client-cinny/tasks/setup_install.yml @@ -1,6 +1,6 @@ --- - name: Ensure Cinny paths exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -24,7 +24,7 @@ until: result is not failed - name: Ensure Cinny repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_client_cinny_container_image_self_build_repo }}" dest: "{{ matrix_client_cinny_docker_src_files_path }}" version: "{{ matrix_client_cinny_docker_image.split(':')[1] }}" @@ -35,7 +35,7 @@ when: "matrix_client_cinny_container_image_self_build|bool" - name: Ensure Cinny configuration installed - copy: + ansible.builtin.copy: content: "{{ matrix_client_cinny_configuration|to_nice_json }}" dest: "{{ matrix_client_cinny_data_path }}/config.json" mode: 0644 @@ -43,7 +43,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure Cinny additional config files installed - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ matrix_client_cinny_data_path }}/{{ item.name }}" mode: 0644 @@ -65,13 +65,13 @@ when: "matrix_client_cinny_container_image_self_build|bool" - name: Ensure matrix-client-cinny.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-client-cinny.service.j2" dest: "{{ matrix_systemd_path }}/matrix-client-cinny.service" mode: 0644 register: matrix_client_cinny_systemd_service_result - name: Ensure systemd reloaded after matrix-client-cinny.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_cinny_systemd_service_result.changed|bool" diff --git a/roles/matrix-client-cinny/tasks/setup_uninstall.yml b/roles/matrix-client-cinny/tasks/setup_uninstall.yml index 507c5d70..866308dd 100644 --- a/roles/matrix-client-cinny/tasks/setup_uninstall.yml +++ b/roles/matrix-client-cinny/tasks/setup_uninstall.yml @@ -5,7 +5,7 @@ register: matrix_client_cinny_service_stat - name: Ensure matrix-client-cinny is stopped - service: + ansible.builtin.service: name: matrix-client-cinny state: stopped enabled: false @@ -14,18 +14,18 @@ when: "matrix_client_cinny_service_stat.stat.exists|bool" - name: Ensure matrix-client-cinny.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-client-cinny.service" state: absent when: "matrix_client_cinny_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-client-cinny.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_cinny_service_stat.stat.exists|bool" - name: Ensure Cinny paths doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_client_cinny_data_path }}" state: absent diff --git a/roles/matrix-client-cinny/tasks/validate_config.yml b/roles/matrix-client-cinny/tasks/validate_config.yml index d8e804c5..10f64fee 100644 --- a/roles/matrix-client-cinny/tasks/validate_config.yml +++ b/roles/matrix-client-cinny/tasks/validate_config.yml @@ -1,6 +1,6 @@ --- - name: Fail if required Cinny settings not defined - fail: + ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) to use Cinny. when: "vars[item] == '' or vars[item] is none" diff --git a/roles/matrix-client-element/tasks/init.yml b/roles/matrix-client-element/tasks/init.yml index cb1df0b5..65edf53a 100644 --- a/roles/matrix-client-element/tasks/init.yml +++ b/roles/matrix-client-element/tasks/init.yml @@ -1,12 +1,12 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-client-element.service'] }}" when: matrix_client_element_enabled|bool # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_client_element_container_image_self_build and matrix_client_element_enabled" diff --git a/roles/matrix-client-element/tasks/migrate_riot_web.yml b/roles/matrix-client-element/tasks/migrate_riot_web.yml index ee0fd446..b570d892 100644 --- a/roles/matrix-client-element/tasks/migrate_riot_web.yml +++ b/roles/matrix-client-element/tasks/migrate_riot_web.yml @@ -7,7 +7,7 @@ when: "matrix_client_element_enabled|bool" - name: Ensure matrix-riot-web is stopped - service: + ansible.builtin.service: name: matrix-riot-web state: stopped enabled: false @@ -16,13 +16,13 @@ when: "matrix_client_element_enabled|bool and matrix_client_riot_web_service_stat.stat.exists" - name: Ensure matrix-riot-web.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_element_enabled|bool and matrix_client_riot_web_service_stat.stat.exists" @@ -33,5 +33,5 @@ when: "matrix_client_element_enabled|bool" - name: Relocate /matrix/riot-web to /matrix/client-element - command: "mv /matrix/riot-web /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/matrix-client-element/tasks/prepare_themes.yml b/roles/matrix-client-element/tasks/prepare_themes.yml index bfb9837b..7d5c1019 100644 --- a/roles/matrix-client-element/tasks/prepare_themes.yml +++ b/roles/matrix-client-element/tasks/prepare_themes.yml @@ -6,7 +6,7 @@ - block: - name: Ensure Element themes repository is pulled - git: + ansible.builtin.git: repo: "{{ matrix_client_element_themes_repository_url }}" dest: "{{ role_path }}/files/scratchpad/themes" @@ -18,13 +18,13 @@ register: matrix_client_element_theme_file_list - name: Read Element theme - slurp: + ansible.builtin.slurp: path: "{{ item.path }}" register: "matrix_client_element_theme_file_contents" with_items: "{{ matrix_client_element_theme_file_list.files }}" - name: Load Element theme - set_fact: + ansible.builtin.set_fact: matrix_client_element_settingDefaults_custom_themes: "{{ matrix_client_element_settingDefaults_custom_themes + [item['content'] | b64decode | from_json] }}" with_items: "{{ matrix_client_element_theme_file_contents.results }}" @@ -39,7 +39,7 @@ # - name: Ensure Element themes repository is removed - file: + ansible.builtin.file: path: "{{ role_path }}/files/scratchpad/themes" state: absent run_once: true diff --git a/roles/matrix-client-element/tasks/self_check.yml b/roles/matrix-client-element/tasks/self_check.yml index d05644c8..031bb5f9 100644 --- a/roles/matrix-client-element/tasks/self_check.yml +++ b/roles/matrix-client-element/tasks/self_check.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_client_element_url_endpoint_public: "https://{{ matrix_server_fqn_element }}/config.json" - name: Check Element - uri: + ansible.builtin.uri: url: "{{ matrix_client_element_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_client_element_self_check_validate_certificates }}" @@ -13,10 +13,10 @@ ignore_errors: true - name: Fail if Element not working - fail: + ansible.builtin.fail: msg: "Failed checking Element is up at `{{ matrix_server_fqn_element }}` (checked endpoint: `{{ matrix_client_element_url_endpoint_public }}`). Is Element running? Is port 443 open in your firewall? Full error: {{ matrix_client_element_self_check_result }}" when: "matrix_client_element_self_check_result.failed or 'json' not in matrix_client_element_self_check_result" - name: Report working Element - debug: + ansible.builtin.debug: msg: "Element at `{{ matrix_server_fqn_element }}` is working (checked endpoint: `{{ matrix_client_element_url_endpoint_public }}`)" diff --git a/roles/matrix-client-element/tasks/setup_install.yml b/roles/matrix-client-element/tasks/setup_install.yml index 4d0af82d..6a4fe3f3 100644 --- a/roles/matrix-client-element/tasks/setup_install.yml +++ b/roles/matrix-client-element/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure Element paths exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -25,7 +25,7 @@ until: result is not failed - name: Ensure Element repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_client_element_container_image_self_build_repo }}" dest: "{{ matrix_client_element_docker_src_files_path }}" version: "{{ matrix_client_element_docker_image.split(':')[1] }}" @@ -39,13 +39,13 @@ # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357 # - https://github.com/vector-im/element-web/issues/19544 - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices - lineinfile: + ansible.builtin.lineinfile: path: "{{ matrix_client_element_docker_src_files_path }}/webpack.config.js" regexp: '(\s+)splitChunks: \{' line: '\1splitChunks: { maxSize: 100000,' backrefs: true owner: root - group: root + ansible.builtin.group: root mode: '0644' when: "matrix_client_element_container_image_self_build|bool and matrix_client_element_container_image_self_build_low_memory_system_patch_enabled|bool" @@ -62,7 +62,7 @@ when: "matrix_client_element_container_image_self_build|bool" - name: Ensure Element configuration installed - copy: + ansible.builtin.copy: content: "{{ matrix_client_element_configuration|to_nice_json }}" dest: "{{ matrix_client_element_data_path }}/config.json" mode: 0644 @@ -70,7 +70,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure Element config files installed - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ matrix_client_element_data_path }}/{{ item.name }}" mode: 0644 @@ -83,7 +83,7 @@ when: "item.src is not none" - name: Ensure Element config files removed - file: + ansible.builtin.file: path: "{{ matrix_client_element_data_path }}/{{ item.name }}" state: absent with_items: @@ -91,13 +91,13 @@ when: "item.src is none" - name: Ensure matrix-client-element.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-client-element.service.j2" dest: "{{ matrix_systemd_path }}/matrix-client-element.service" mode: 0644 register: matrix_client_element_systemd_service_result - name: Ensure systemd reloaded after matrix-client-element.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_element_systemd_service_result.changed|bool" diff --git a/roles/matrix-client-element/tasks/setup_uninstall.yml b/roles/matrix-client-element/tasks/setup_uninstall.yml index 55bc20d6..83b4a795 100644 --- a/roles/matrix-client-element/tasks/setup_uninstall.yml +++ b/roles/matrix-client-element/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_client_element_service_stat - name: Ensure matrix-client-element is stopped - service: + ansible.builtin.service: name: matrix-client-element state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_client_element_service_stat.stat.exists|bool" - name: Ensure matrix-client-element.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-client-element.service" state: absent when: "matrix_client_element_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-client-element.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_element_service_stat.stat.exists|bool" - name: Ensure Element paths doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_client_element_data_path }}" state: absent diff --git a/roles/matrix-client-element/tasks/validate_config.yml b/roles/matrix-client-element/tasks/validate_config.yml index d246b612..fdf74f07 100644 --- a/roles/matrix-client-element/tasks/validate_config.yml +++ b/roles/matrix-client-element/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required Element settings not defined - fail: + ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) for using Element. when: "vars[item] == ''" @@ -9,7 +9,7 @@ - "matrix_client_element_default_hs_url" - name: (Deprecation) Catch and report riot-web variables - fail: + ansible.builtin.fail: msg: >- Riot has been renamed to Element (https://element.io/blog/welcome-to-element/). The playbook will migrate your existing configuration and data automatically, but you need to adjust variable names. diff --git a/roles/matrix-client-hydrogen/tasks/init.yml b/roles/matrix-client-hydrogen/tasks/init.yml index c6801e51..70454d92 100644 --- a/roles/matrix-client-hydrogen/tasks/init.yml +++ b/roles/matrix-client-hydrogen/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Hydrogen image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_client_hydrogen_container_image_self_build and matrix_client_hydrogen_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-client-hydrogen.service'] }}" when: matrix_client_hydrogen_enabled|bool diff --git a/roles/matrix-client-hydrogen/tasks/self_check.yml b/roles/matrix-client-hydrogen/tasks/self_check.yml index 0c664231..978e531f 100644 --- a/roles/matrix-client-hydrogen/tasks/self_check.yml +++ b/roles/matrix-client-hydrogen/tasks/self_check.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_client_hydrogen_url_endpoint_public: "https://{{ matrix_server_fqn_hydrogen }}/config.json" - name: Check Hydrogen - uri: + ansible.builtin.uri: url: "{{ matrix_client_hydrogen_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_client_hydrogen_self_check_validate_certificates }}" @@ -13,10 +13,10 @@ ignore_errors: true - name: Fail if Hydrogen not working - fail: + ansible.builtin.fail: msg: "Failed checking Hydrogen is up at `{{ matrix_server_fqn_hydrogen }}` (checked endpoint: `{{ matrix_client_hydrogen_url_endpoint_public }}`). Is Hydrogen running? Is port 443 open in your firewall? Full error: {{ matrix_client_hydrogen_self_check_result }}" when: "matrix_client_hydrogen_self_check_result.failed or 'json' not in matrix_client_hydrogen_self_check_result" - name: Report working Hydrogen - debug: + ansible.builtin.debug: msg: "Hydrogen at `{{ matrix_server_fqn_hydrogen }}` is working (checked endpoint: `{{ matrix_client_hydrogen_url_endpoint_public }}`)" diff --git a/roles/matrix-client-hydrogen/tasks/setup_install.yml b/roles/matrix-client-hydrogen/tasks/setup_install.yml index db866178..b7a63fb7 100644 --- a/roles/matrix-client-hydrogen/tasks/setup_install.yml +++ b/roles/matrix-client-hydrogen/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure Hydrogen paths exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -25,7 +25,7 @@ until: result is not failed - name: Ensure Hydrogen repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_client_hydrogen_container_image_self_build_repo }}" dest: "{{ matrix_client_hydrogen_docker_src_files_path }}" version: "{{ matrix_client_hydrogen_docker_image.split(':')[1] }}" @@ -36,7 +36,7 @@ when: "matrix_client_hydrogen_container_image_self_build|bool" - name: Ensure Hydrogen configuration installed - copy: + ansible.builtin.copy: content: "{{ matrix_client_hydrogen_configuration|to_nice_json }}" dest: "{{ matrix_client_hydrogen_docker_src_files_path }}/src/platform/web/assets/config.json" mode: 0644 @@ -45,7 +45,7 @@ when: "matrix_client_hydrogen_container_image_self_build|bool" - name: Ensure Hydrogen additional config files installed - template: + ansible.builtin.template: src: "{{ item.src }}" dest: "{{ matrix_client_hydrogen_data_path }}/{{ item.name }}" mode: 0644 @@ -69,13 +69,13 @@ when: "matrix_client_hydrogen_container_image_self_build|bool" - name: Ensure matrix-client-hydrogen.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-client-hydrogen.service.j2" dest: "{{ matrix_systemd_path }}/matrix-client-hydrogen.service" mode: 0644 register: matrix_client_hydrogen_systemd_service_result - name: Ensure systemd reloaded after matrix-client-hydrogen.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_hydrogen_systemd_service_result.changed|bool" diff --git a/roles/matrix-client-hydrogen/tasks/setup_uninstall.yml b/roles/matrix-client-hydrogen/tasks/setup_uninstall.yml index 7aff2916..ac0c11c7 100644 --- a/roles/matrix-client-hydrogen/tasks/setup_uninstall.yml +++ b/roles/matrix-client-hydrogen/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_client_hydrogen_service_stat - name: Ensure matrix-client-hydrogen is stopped - service: + ansible.builtin.service: name: matrix-client-hydrogen state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_client_hydrogen_service_stat.stat.exists|bool" - name: Ensure matrix-client-hydrogen.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-client-hydrogen.service" state: absent when: "matrix_client_hydrogen_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-client-hydrogen.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_client_hydrogen_service_stat.stat.exists|bool" - name: Ensure Hydrogen paths doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_client_hydrogen_data_path }}" state: absent diff --git a/roles/matrix-client-hydrogen/tasks/validate_config.yml b/roles/matrix-client-hydrogen/tasks/validate_config.yml index d3b9a709..4188acba 100644 --- a/roles/matrix-client-hydrogen/tasks/validate_config.yml +++ b/roles/matrix-client-hydrogen/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required Hydrogen settings not defined - fail: + ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) to use Hydrogen. when: "(vars[item] == '' or vars[item] is none) and matrix_client_hydrogen_container_image_self_build|bool" diff --git a/roles/matrix-common-after/tasks/dump_runtime_results.yml b/roles/matrix-common-after/tasks/dump_runtime_results.yml index 44ae1a30..4074a625 100644 --- a/roles/matrix-common-after/tasks/dump_runtime_results.yml +++ b/roles/matrix-common-after/tasks/dump_runtime_results.yml @@ -1,7 +1,7 @@ --- # Ansible outputs the message in the `item=` field. # It's unnecessary to output it again in the actual message, so we don't. -- debug: +- ansible.builtin.debug: msg: "" with_items: "{{ matrix_playbook_runtime_results }}" when: "matrix_playbook_runtime_results is defined and matrix_playbook_runtime_results|length > 0" diff --git a/roles/matrix-common-after/tasks/run_docker_prune.yml b/roles/matrix-common-after/tasks/run_docker_prune.yml index a7e35a03..27fc1615 100644 --- a/roles/matrix-common-after/tasks/run_docker_prune.yml +++ b/roles/matrix-common-after/tasks/run_docker_prune.yml @@ -1,4 +1,4 @@ --- - name: Run Docker System Prune - command: "{{ matrix_host_command_docker }} system prune -a -f" + ansible.builtin.command: "{{ matrix_host_command_docker }} system prune -a -f" diff --git a/roles/matrix-common-after/tasks/start.yml b/roles/matrix-common-after/tasks/start.yml index 02fa672e..35126fc1 100644 --- a/roles/matrix-common-after/tasks/start.yml +++ b/roles/matrix-common-after/tasks/start.yml @@ -1,22 +1,22 @@ --- - name: Determine whether we should make services autostart - set_fact: + ansible.builtin.set_fact: matrix_services_autostart_enabled_bool: "{{ true if matrix_services_autostart_enabled|default('') == '' else matrix_services_autostart_enabled|bool }}" - name: Ensure systemd is reloaded - service: + ansible.builtin.service: daemon_reload: true - name: Ensure Matrix services are stopped - service: + ansible.builtin.service: name: "{{ item }}" state: stopped with_items: "{{ matrix_systemd_services_list }}" when: not ansible_check_mode - name: Ensure Matrix services are started - service: + ansible.builtin.service: name: "{{ item }}" enabled: "{{ matrix_services_autostart_enabled_bool }}" state: started @@ -39,7 +39,7 @@ service_facts: - name: Fail if service isn't detected to be running - fail: + ansible.builtin.fail: msg: >- {{ item }} was not detected to be running. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.). @@ -57,13 +57,13 @@ # service_facts is not collecting the data successfully. # Therefore iterating here manually - name: Fetch systemd information - systemd: + ansible.builtin.systemd: name: "{{ item }}" register: systemdstatus with_items: "{{ matrix_systemd_services_list }}" - name: Fail if service isn't detected to be running - fail: + ansible.builtin.fail: msg: >- {{ item.item }} was not detected to be running. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.). diff --git a/roles/matrix-common-after/tasks/stop.yml b/roles/matrix-common-after/tasks/stop.yml index 5ae0afbb..a343999c 100644 --- a/roles/matrix-common-after/tasks/stop.yml +++ b/roles/matrix-common-after/tasks/stop.yml @@ -1,7 +1,7 @@ --- - name: Ensure Matrix services stopped - service: + ansible.builtin.service: name: "{{ item }}" state: stopped with_items: "{{ matrix_systemd_services_list }}" diff --git a/roles/matrix-corporal/tasks/init.yml b/roles/matrix-corporal/tasks/init.yml index b2f50e93..08ef7c88 100644 --- a/roles/matrix-corporal/tasks/init.yml +++ b/roles/matrix-corporal/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_corporal_container_image_self_build and matrix_corporal_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-corporal.service'] }}" when: matrix_corporal_enabled|bool diff --git a/roles/matrix-corporal/tasks/self_check_corporal.yml b/roles/matrix-corporal/tasks/self_check_corporal.yml index b702c00f..3ddda8e0 100644 --- a/roles/matrix-corporal/tasks/self_check_corporal.yml +++ b/roles/matrix-corporal/tasks/self_check_corporal.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: corporal_client_api_url_endpoint_public: "https://{{ matrix_server_fqn_matrix }}/_matrix/client/corporal" - name: Check Matrix Corporal HTTP gateway - uri: + ansible.builtin.uri: url: "{{ corporal_client_api_url_endpoint_public }}" follow_redirects: none return_content: true @@ -13,10 +13,10 @@ ignore_errors: true - name: Fail if Matrix Corporal HTTP gateway not working - fail: + ansible.builtin.fail: msg: "Failed checking Matrix Corporal is fronting the Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ corporal_client_api_url_endpoint_public }}`). Is matrix-corporal running? Is port 443 open in your firewall? Full error: {{ result_corporal_client_api }}" when: "result_corporal_client_api.failed or 'Matrix Client-Server API protected by Matrix Corporal' not in result_corporal_client_api.content" - name: Report working Matrix Corporal HTTP gateway - debug: + ansible.builtin.debug: msg: "Matrix Corporal is fronting the Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ corporal_client_api_url_endpoint_public }}`)" diff --git a/roles/matrix-corporal/tasks/setup_corporal.yml b/roles/matrix-corporal/tasks/setup_corporal.yml index a3582592..58039bf4 100644 --- a/roles/matrix-corporal/tasks/setup_corporal.yml +++ b/roles/matrix-corporal/tasks/setup_corporal.yml @@ -5,7 +5,7 @@ # - name: Ensure Matrix Corporal paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -18,7 +18,7 @@ when: matrix_corporal_enabled|bool - name: Ensure Matrix Corporal repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_corporal_container_image_self_build_repo }}" dest: "{{ matrix_corporal_container_src_files_path }}" version: "{{ matrix_corporal_docker_image.split(':')[1] }}" @@ -53,7 +53,7 @@ until: result is not failed - name: Ensure Matrix Corporal config installed - copy: + ansible.builtin.copy: content: "{{ matrix_corporal_configuration|to_nice_json }}" dest: "{{ matrix_corporal_config_dir_path }}/config.json" mode: 0644 @@ -62,7 +62,7 @@ when: matrix_corporal_enabled|bool - name: Ensure matrix-corporal.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-corporal.service.j2" dest: "{{ matrix_systemd_path }}/matrix-corporal.service" mode: 0644 @@ -70,7 +70,7 @@ when: matrix_corporal_enabled|bool - name: Ensure systemd reloaded after matrix-corporal.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_corporal_enabled|bool and matrix_corporal_systemd_service_result.changed" @@ -86,7 +86,7 @@ when: "not matrix_corporal_enabled|bool" - name: Ensure matrix-corporal is stopped - service: + ansible.builtin.service: name: matrix-corporal state: stopped enabled: false @@ -95,18 +95,18 @@ when: "not matrix_corporal_enabled|bool and matrix_corporal_service_stat.stat.exists" - name: Ensure matrix-corporal.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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 - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: diff --git a/roles/matrix-corporal/tasks/validate_config.yml b/roles/matrix-corporal/tasks/validate_config.yml index a8930e7e..50848810 100644 --- a/roles/matrix-corporal/tasks/validate_config.yml +++ b/roles/matrix-corporal/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required matrix-corporal settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) for using matrix-corporal. when: "vars[item] == ''" @@ -12,12 +12,12 @@ - "matrix_corporal_policy_provider_config" - name: Fail if HTTP API enabled, but no token set - fail: + ansible.builtin.fail: msg: "The Matrix Corporal HTTP API is enabled (`matrix_corporal_http_api_enabled`), but no auth token has been set in `matrix_corporal_http_api_auth_token`" when: "matrix_corporal_http_api_enabled|bool and matrix_corporal_http_api_auth_token == ''" - name: (Deprecation) Catch and report renamed corporal variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-coturn/tasks/init.yml b/roles/matrix-coturn/tasks/init.yml index 93e4fa3a..726e3065 100644 --- a/roles/matrix-coturn/tasks/init.yml +++ b/roles/matrix-coturn/tasks/init.yml @@ -2,14 +2,14 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_coturn_container_image_self_build and matrix_coturn_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-coturn.service'] }}" when: matrix_coturn_enabled|bool -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-coturn-reload.timer'] }}" when: "matrix_coturn_enabled|bool and matrix_coturn_tls_enabled|bool" diff --git a/roles/matrix-coturn/tasks/setup_install.yml b/roles/matrix-coturn/tasks/setup_install.yml index a721f186..d24e4313 100644 --- a/roles/matrix-coturn/tasks/setup_install.yml +++ b/roles/matrix-coturn/tasks/setup_install.yml @@ -2,12 +2,12 @@ # This is a cleanup/migration task. It can be removed some time in the future. - name: (Migration) Remove deprecated cronjob - file: + ansible.builtin.file: path: "{{ matrix_cron_path }}/matrix-coturn-ssl-reload" state: absent - name: Ensure Matrix Coturn path exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -31,7 +31,7 @@ - block: - name: Ensure Coturn repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_coturn_container_image_self_build_repo }}" dest: "{{ matrix_coturn_docker_src_files_path }}" version: "{{ matrix_coturn_container_image_self_build_repo_version }}" @@ -53,7 +53,7 @@ when: "matrix_coturn_container_image_self_build|bool" - name: Ensure Coturn configuration path exists - file: + ansible.builtin.file: path: "{{ matrix_coturn_base_path }}" state: directory mode: 0750 @@ -61,7 +61,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure turnserver.conf installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/turnserver.conf.j2" dest: "{{ matrix_coturn_config_path }}" mode: 0644 @@ -74,7 +74,7 @@ driver: bridge - name: Ensure matrix-coturn.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2" dest: "{{ matrix_systemd_path }}/matrix-coturn.service" mode: 0644 @@ -84,7 +84,7 @@ # We optimize for the common use-case though (short-lived Let's Encrypt certificates). # Reloading doesn't hurt anyway, so there's no need to make this more flexible. - name: Ensure reloading systemd units installed, if necessary - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/{{ item }}.j2" dest: "{{ matrix_systemd_path }}/{{ item }}" mode: 0644 @@ -96,7 +96,7 @@ # A similar task exists in `setup_uninstall.yml` - name: Ensure reloading systemd units uninstalled, if unnecessary - file: + ansible.builtin.file: path: "{{ item }}" state: absent register: "matrix_coturn_systemd_service_change_results" @@ -106,6 +106,6 @@ - matrix-coturn-reload.timer - name: Ensure systemd reloaded if systemd units changed - service: + ansible.builtin.service: daemon_reload: true when: "matrix_coturn_systemd_service_change_results.changed" diff --git a/roles/matrix-coturn/tasks/setup_uninstall.yml b/roles/matrix-coturn/tasks/setup_uninstall.yml index 097ba873..b3d77e40 100644 --- a/roles/matrix-coturn/tasks/setup_uninstall.yml +++ b/roles/matrix-coturn/tasks/setup_uninstall.yml @@ -7,7 +7,7 @@ when: "not matrix_coturn_enabled|bool" - name: Ensure matrix-coturn is stopped - service: + ansible.builtin.service: name: matrix-coturn state: stopped enabled: false @@ -15,7 +15,7 @@ when: "matrix_coturn_service_stat.stat.exists|bool" - name: Ensure matrix-coturn-reload.timer is stopped - service: + ansible.builtin.service: name: matrix-coturn state: stopped enabled: false @@ -24,7 +24,7 @@ when: "matrix_coturn_service_stat.stat.exists|bool" - name: Ensure systemd units don't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/{{ item }}" state: absent register: matrix_coturn_systemd_unit_uninstallation_result @@ -34,12 +34,12 @@ - matrix-coturn-reload.timer - name: Ensure systemd reloaded after unit removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_coturn_systemd_unit_uninstallation_result.changed|bool" - name: Ensure Matrix coturn paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_coturn_base_path }}" state: absent diff --git a/roles/matrix-coturn/tasks/validate_config.yml b/roles/matrix-coturn/tasks/validate_config.yml index 637f720d..90e842e1 100644 --- a/roles/matrix-coturn/tasks/validate_config.yml +++ b/roles/matrix-coturn/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required Coturn settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) for using Coturn. when: "vars[item] == ''" diff --git a/roles/matrix-dendrite/tasks/dendrite/setup_install.yml b/roles/matrix-dendrite/tasks/dendrite/setup_install.yml index a18ad065..47cf5513 100644 --- a/roles/matrix-dendrite/tasks/dendrite/setup_install.yml +++ b/roles/matrix-dendrite/tasks/dendrite/setup_install.yml @@ -9,7 +9,7 @@ # This is separate and conditional, to ensure we don't execute it # if the path already exists or we failed to check, because it's mounted using fuse. - name: Ensure Dendrite media store path exists - file: + ansible.builtin.file: path: "{{ matrix_dendrite_media_store_path }}" state: directory mode: 0750 @@ -37,7 +37,7 @@ # We don't use the `docker_container` module, because using it with `cap_drop` requires # a very recent version, which is not available for a lot of people yet. - name: Generate Dendrite signing key - command: | + ansible.builtin.command: | docker run --rm --name=matrix-dendrite-config @@ -48,14 +48,14 @@ when: "not matrix_dendrite_signing_key_stat.stat.exists" - name: Ensure Dendrite server key exists - file: + ansible.builtin.file: path: "{{ matrix_dendrite_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.pem" mode: 0644 owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" - name: Ensure Dendrite configuration installed - copy: + ansible.builtin.copy: content: "{{ matrix_dendrite_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_dendrite_config_dir_path }}/dendrite.yaml" mode: 0644 @@ -63,19 +63,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-dendrite.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/dendrite/systemd/matrix-dendrite.service.j2" dest: "{{ matrix_systemd_path }}/matrix-dendrite.service" mode: 0644 register: matrix_dendrite_systemd_service_result - name: Ensure systemd reloaded after matrix-dendrite.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_dendrite_systemd_service_result.changed|bool" - name: Ensure matrix-dendrite-create-account script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/dendrite/usr-local-bin/matrix-dendrite-create-account.j2" dest: "{{ matrix_local_bin_path }}/matrix-dendrite-create-account" mode: 0750 diff --git a/roles/matrix-dendrite/tasks/dendrite/setup_uninstall.yml b/roles/matrix-dendrite/tasks/dendrite/setup_uninstall.yml index 89d5481c..88122256 100644 --- a/roles/matrix-dendrite/tasks/dendrite/setup_uninstall.yml +++ b/roles/matrix-dendrite/tasks/dendrite/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_dendrite_service_stat - name: Ensure matrix-dendrite is stopped - service: + ansible.builtin.service: name: matrix-dendrite state: stopped daemon_reload: true @@ -14,13 +14,13 @@ when: "matrix_dendrite_service_stat.stat.exists" - name: Ensure matrix-dendrite.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-dendrite.service" state: absent when: "matrix_dendrite_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-dendrite.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_dendrite_service_stat.stat.exists" diff --git a/roles/matrix-dendrite/tasks/init.yml b/roles/matrix-dendrite/tasks/init.yml index 524ef6ee..20e34ef5 100644 --- a/roles/matrix-dendrite/tasks/init.yml +++ b/roles/matrix-dendrite/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-dendrite.service'] }}" when: matrix_dendrite_enabled|bool diff --git a/roles/matrix-dendrite/tasks/main.yml b/roles/matrix-dendrite/tasks/main.yml index 5483adec..a08f45bd 100644 --- a/roles/matrix-dendrite/tasks/main.yml +++ b/roles/matrix-dendrite/tasks/main.yml @@ -36,7 +36,7 @@ - self-check - name: Mark matrix-dendrite role as executed - set_fact: + ansible.builtin.set_fact: matrix_dendrite_role_executed: true tags: - always diff --git a/roles/matrix-dendrite/tasks/register_user.yml b/roles/matrix-dendrite/tasks/register_user.yml index b8e3ae5e..e18af138 100644 --- a/roles/matrix-dendrite/tasks/register_user.yml +++ b/roles/matrix-dendrite/tasks/register_user.yml @@ -1,16 +1,16 @@ --- - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `username` variable needs to be provided to this playbook, via --extra-vars" when: "username is not defined or username == ''" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `password` variable needs to be provided to this playbook, via --extra-vars" when: "password is not defined or password == ''" - name: Ensure matrix-dendrite is started - service: + ansible.builtin.service: name: matrix-dendrite state: started daemon_reload: true @@ -22,4 +22,4 @@ when: "start_result.changed" - name: Register user - command: "{{ matrix_local_bin_path }}/matrix-dendrite-create-account {{ username|quote }} {{ password|quote }}" + ansible.builtin.command: "{{ matrix_local_bin_path }}/matrix-dendrite-create-account {{ username|quote }} {{ password|quote }}" diff --git a/roles/matrix-dendrite/tasks/self_check_client_api.yml b/roles/matrix-dendrite/tasks/self_check_client_api.yml index 2470d818..99b6cb40 100644 --- a/roles/matrix-dendrite/tasks/self_check_client_api.yml +++ b/roles/matrix-dendrite/tasks/self_check_client_api.yml @@ -1,6 +1,6 @@ --- - name: Check Matrix Client API - uri: + ansible.builtin.uri: url: "{{ matrix_dendrite_client_api_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_dendrite_self_check_validate_certificates }}" @@ -9,10 +9,10 @@ check_mode: false - name: Fail if Matrix Client API not working - fail: + ansible.builtin.fail: msg: "Failed checking Matrix Client API is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_dendrite_client_api_url_endpoint_public }}`). Is Dendrite running? Is port 443 open in your firewall? Full error: {{ result_matrix_dendrite_client_api }}" when: "(result_matrix_dendrite_client_api.failed or 'json' not in result_matrix_dendrite_client_api)" - name: Report working Matrix Client API - debug: + ansible.builtin.debug: msg: "The Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_dendrite_client_api_url_endpoint_public }}`) is working" diff --git a/roles/matrix-dendrite/tasks/self_check_federation_api.yml b/roles/matrix-dendrite/tasks/self_check_federation_api.yml index 0afca2cb..0d817afe 100644 --- a/roles/matrix-dendrite/tasks/self_check_federation_api.yml +++ b/roles/matrix-dendrite/tasks/self_check_federation_api.yml @@ -1,6 +1,6 @@ --- - name: Check Matrix Federation API - uri: + ansible.builtin.uri: url: "{{ matrix_dendrite_federation_api_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_dendrite_self_check_validate_certificates }}" @@ -9,16 +9,16 @@ check_mode: false - name: Fail if Matrix Federation API not working - fail: + ansible.builtin.fail: msg: "Failed checking Matrix Federation API is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_dendrite_federation_api_url_endpoint_public }}`). Is Dendrite running? Is port {{ matrix_federation_public_port }} open in your firewall? Full error: {{ result_matrix_dendrite_federation_api }}" when: "matrix_dendrite_federation_enabled|bool and (result_matrix_dendrite_federation_api.failed or 'json' not in result_matrix_dendrite_federation_api)" - name: Fail if Matrix Federation API unexpectedly enabled - fail: + ansible.builtin.fail: msg: "Matrix Federation API is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_dendrite_federation_api_url_endpoint_public }}`) despite being disabled." when: "not matrix_dendrite_federation_enabled|bool and not result_matrix_dendrite_federation_api.failed" - name: Report working Matrix Federation API - debug: + ansible.builtin.debug: msg: "The Matrix Federation API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_dendrite_federation_api_url_endpoint_public }}`) is working" when: "matrix_dendrite_federation_enabled|bool" diff --git a/roles/matrix-dendrite/tasks/setup_dendrite.yml b/roles/matrix-dendrite/tasks/setup_dendrite.yml index fc306759..792e9c4f 100644 --- a/roles/matrix-dendrite/tasks/setup_dendrite.yml +++ b/roles/matrix-dendrite/tasks/setup_dendrite.yml @@ -1,6 +1,6 @@ --- - name: Ensure Dendrite paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 diff --git a/roles/matrix-dendrite/tasks/validate_config.yml b/roles/matrix-dendrite/tasks/validate_config.yml index 2d2cf4c5..390da938 100644 --- a/roles/matrix-dendrite/tasks/validate_config.yml +++ b/roles/matrix-dendrite/tasks/validate_config.yml @@ -1,6 +1,6 @@ --- - name: Fail if required Dendrite settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) for using Dendrite. when: "vars[item] == ''" @@ -8,7 +8,7 @@ - "matrix_dendrite_registration_shared_secret" - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-dimension/tasks/init.yml b/roles/matrix-dimension/tasks/init.yml index 6336cb4d..4ee1bb0e 100644 --- a/roles/matrix-dimension/tasks/init.yml +++ b/roles/matrix-dimension/tasks/init.yml @@ -1,4 +1,4 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-dimension.service'] }}" when: matrix_dimension_enabled|bool diff --git a/roles/matrix-dimension/tasks/setup_install.yml b/roles/matrix-dimension/tasks/setup_install.yml index b999383e..01bab7cf 100644 --- a/roles/matrix-dimension/tasks/setup_install.yml +++ b/roles/matrix-dimension/tasks/setup_install.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_dimension_requires_restart: false - block: @@ -12,10 +12,10 @@ - block: # pgloader makes a few columns `smallint`, instead of `boolean`. # We need to fix them up. - - set_fact: + - ansible.builtin.set_fact: matrix_dimension_pgloader_additional_psql_statements_list: [] - - set_fact: + - ansible.builtin.set_fact: matrix_dimension_pgloader_additional_psql_statements_list: | {{ matrix_dimension_pgloader_additional_psql_statements_list @@ -49,7 +49,7 @@ - {'table': 'dimension_bridges', 'column': 'isEnabled', 'default': ''} - {'table': 'dimension_bridges', 'column': 'isPublic', 'default': ''} - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_dimension_sqlite_database_path_local }}" dst: "{{ matrix_dimension_database_connection_string }}" @@ -63,13 +63,13 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_dimension_requires_restart: true when: "matrix_dimension_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_dimension_database_engine == 'postgres'" - name: Ensure Dimension base path exists - file: + ansible.builtin.file: path: "{{ matrix_dimension_base_path }}" state: directory mode: 0770 @@ -77,7 +77,7 @@ group: "{{ matrix_dimension_user_gid }}" - name: Ensure Dimension config installed - copy: + ansible.builtin.copy: content: "{{ matrix_dimension_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_dimension_base_path }}/config.yaml" mode: 0640 @@ -97,7 +97,7 @@ until: matrix_dimension_pull_results is not failed - name: Ensure dimension repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_dimension_container_image_self_build_repo }}" dest: "{{ matrix_dimension_docker_src_files_path }}" version: "{{ matrix_dimension_container_image_self_build_branch }}" @@ -120,19 +120,19 @@ when: "matrix_dimension_container_image_self_build|bool" - name: Ensure matrix-dimension.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-dimension.service.j2" dest: "{{ matrix_systemd_path }}/matrix-dimension.service" mode: 0644 register: matrix_dimension_systemd_service_result - name: Ensure systemd reloaded after matrix-dimension.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_dimension_systemd_service_result.changed|bool" - name: Ensure matrix-dimension.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-dimension.service" state: restarted when: "matrix_dimension_requires_restart|bool" diff --git a/roles/matrix-dimension/tasks/setup_uninstall.yml b/roles/matrix-dimension/tasks/setup_uninstall.yml index cdfbe07a..5a181893 100644 --- a/roles/matrix-dimension/tasks/setup_uninstall.yml +++ b/roles/matrix-dimension/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_dimension_service_stat - name: Ensure matrix-dimension is stopped - service: + ansible.builtin.service: name: matrix-dimension state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_dimension_service_stat.stat.exists|bool" - name: Ensure matrix-dimension.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-dimension.service" state: absent when: "matrix_dimension_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-dimension.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_dimension_service_stat.stat.exists|bool" - name: Ensure Dimension base directory doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_dimension_base_path }}" state: absent diff --git a/roles/matrix-dimension/tasks/validate_config.yml b/roles/matrix-dimension/tasks/validate_config.yml index 8413c42f..5af0ba6d 100644 --- a/roles/matrix-dimension/tasks/validate_config.yml +++ b/roles/matrix-dimension/tasks/validate_config.yml @@ -1,6 +1,6 @@ --- - name: Fail if required Dimension settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) for using Dimension. with_items: @@ -8,7 +8,7 @@ when: "matrix_dimension_enabled and vars[item] == ''" - name: (Deprecation) Catch and report renamed Dimension variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-dynamic-dns/tasks/init.yml b/roles/matrix-dynamic-dns/tasks/init.yml index 6ea6a60b..2604270e 100644 --- a/roles/matrix-dynamic-dns/tasks/init.yml +++ b/roles/matrix-dynamic-dns/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_dynamic_dns_container_image_self_build and matrix_dynamic_dns_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-dynamic-dns.service'] }}" when: "matrix_dynamic_dns_enabled|bool" diff --git a/roles/matrix-dynamic-dns/tasks/install.yml b/roles/matrix-dynamic-dns/tasks/install.yml index 60f07937..664f1854 100644 --- a/roles/matrix-dynamic-dns/tasks/install.yml +++ b/roles/matrix-dynamic-dns/tasks/install.yml @@ -13,7 +13,7 @@ until: result is not failed - name: Ensure Dynamic DNS paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0751 @@ -26,7 +26,7 @@ when: matrix_dynamic_dns_enabled|bool and item.when|bool - name: Ensure Dynamic DNS repository is present on self build - git: + ansible.builtin.git: repo: "{{ matrix_dynamic_dns_container_image_self_build_repo }}" dest: "{{ matrix_dynamic_dns_docker_src_files_path }}" force: "yes" @@ -48,7 +48,7 @@ when: "matrix_dynamic_dns_enabled|bool and matrix_dynamic_dns_container_image_self_build|bool" - name: Ensure Dynamic DNS ddclient.conf installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/ddclient.conf.j2" dest: "{{ matrix_dynamic_dns_config_path }}/ddclient.conf" mode: 0644 @@ -56,13 +56,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-dynamic-dns.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-dynamic-dns.service.j2" dest: "/etc/systemd/system/matrix-dynamic-dns.service" mode: 0644 register: matrix_dynamic_dns_systemd_service_result - name: Ensure systemd reloaded after matrix-dynamic-dns.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_dynamic_dns_systemd_service_result.changed" diff --git a/roles/matrix-dynamic-dns/tasks/uninstall.yml b/roles/matrix-dynamic-dns/tasks/uninstall.yml index 80842c9c..1583344d 100644 --- a/roles/matrix-dynamic-dns/tasks/uninstall.yml +++ b/roles/matrix-dynamic-dns/tasks/uninstall.yml @@ -6,7 +6,7 @@ register: matrix_dynamic_dns_service_stat - name: Ensure matrix-dynamic-dns is stopped - service: + ansible.builtin.service: name: matrix-dynamic-dns state: stopped enabled: false @@ -14,13 +14,13 @@ when: "matrix_dynamic_dns_service_stat.stat.exists" - name: Ensure matrix-dynamic-dns.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-dynamic-dns.service" state: absent when: "matrix_dynamic_dns_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-dynamic-dns.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_dynamic_dns_service_stat.stat.exists" diff --git a/roles/matrix-dynamic-dns/tasks/validate_config.yml b/roles/matrix-dynamic-dns/tasks/validate_config.yml index 8f0001ea..610dc2f8 100644 --- a/roles/matrix-dynamic-dns/tasks/validate_config.yml +++ b/roles/matrix-dynamic-dns/tasks/validate_config.yml @@ -1,13 +1,13 @@ --- - name: Fail if no configurations specified - fail: + ansible.builtin.fail: msg: >- You need to define at least one configuration in `matrix_dynamic_dns_domain_configurations` for using matrix-dynamic-dns. when: "matrix_dynamic_dns_domain_configurations|length == 0" - name: Fail if required settings not defined in configuration blocks - fail: + ansible.builtin.fail: msg: >- One of the configurations in matrix_dynamic_dns_domain_configurations is missing a required key (domain, provider, protocol). when: "'domain' not in configuration or 'provider' not in configuration or 'protocol' not in configuration" diff --git a/roles/matrix-email2matrix/tasks/init.yml b/roles/matrix-email2matrix/tasks/init.yml index 5f582212..5e81b40a 100644 --- a/roles/matrix-email2matrix/tasks/init.yml +++ b/roles/matrix-email2matrix/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-email2matrix.service'] }}" when: matrix_email2matrix_enabled|bool diff --git a/roles/matrix-email2matrix/tasks/setup_install.yml b/roles/matrix-email2matrix/tasks/setup_install.yml index a2470728..3828e36e 100644 --- a/roles/matrix-email2matrix/tasks/setup_install.yml +++ b/roles/matrix-email2matrix/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure Email2Matrix paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -14,7 +14,7 @@ when: "item.when|bool" - name: Ensure Email2Matrix configuration file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/config.json.j2" dest: "{{ matrix_email2matrix_config_dir_path }}/config.json" owner: "{{ matrix_user_username }}" @@ -34,7 +34,7 @@ until: result is not failed - name: Ensure Email2Matrix repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_email2matrix_container_image_self_build_repo }}" dest: "{{ matrix_email2matrix_docker_src_files_path }}" version: "{{ matrix_email2matrix_container_image_self_build_branch }}" @@ -57,13 +57,13 @@ when: "matrix_email2matrix_container_image_self_build|bool" - name: Ensure matrix-email2matrix.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-email2matrix.service.j2" dest: "{{ matrix_systemd_path }}/matrix-email2matrix.service" mode: 0644 register: matrix_email2matrix_systemd_service_result - name: Ensure systemd reloaded after matrix-email2matrix.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_email2matrix_systemd_service_result.changed|bool" diff --git a/roles/matrix-email2matrix/tasks/setup_uninstall.yml b/roles/matrix-email2matrix/tasks/setup_uninstall.yml index 27d35f2d..4b76adcc 100644 --- a/roles/matrix-email2matrix/tasks/setup_uninstall.yml +++ b/roles/matrix-email2matrix/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_email2matrix_service_stat - name: Ensure matrix-email2matrix is stopped - service: + ansible.builtin.service: name: matrix-email2matrix state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_email2matrix_service_stat.stat.exists|bool" - name: Ensure matrix-email2matrix.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-email2matrix.service" state: absent when: "matrix_email2matrix_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-email2matrix.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_email2matrix_service_stat.stat.exists|bool" - name: Ensure Email2Matrix data path doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_email2matrix_base_path }}" state: absent diff --git a/roles/matrix-email2matrix/tasks/validate_config.yml b/roles/matrix-email2matrix/tasks/validate_config.yml index d8beecf4..59a3581e 100644 --- a/roles/matrix-email2matrix/tasks/validate_config.yml +++ b/roles/matrix-email2matrix/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if no mappings - fail: + ansible.builtin.fail: msg: > You need to define at least one mapping in `matrix_email2matrix_matrix_mappings` for enabling Email2Matrix. when: "matrix_email2matrix_matrix_mappings|length == 0" diff --git a/roles/matrix-etherpad/tasks/init.yml b/roles/matrix-etherpad/tasks/init.yml index 392addd0..a3cda068 100644 --- a/roles/matrix-etherpad/tasks/init.yml +++ b/roles/matrix-etherpad/tasks/init.yml @@ -1,12 +1,12 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-etherpad.service'] }}" when: matrix_etherpad_enabled|bool - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Etherpad's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -15,7 +15,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Etherpad proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_etherpad_matrix_nginx_proxy_configuration: | rewrite ^{{ matrix_etherpad_public_endpoint }}$ {{ matrix_nginx_proxy_x_forwarded_proto_value }}://$server_name{{ matrix_etherpad_public_endpoint }}/ permanent; @@ -42,7 +42,7 @@ } - name: Register Etherpad proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_dimension_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_dimension_additional_server_configuration_blocks|default([]) @@ -54,7 +54,7 @@ when: matrix_etherpad_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Etherpad tool but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-etherpad/tasks/setup_install.yml b/roles/matrix-etherpad/tasks/setup_install.yml index 6f276e05..d11545a5 100644 --- a/roles/matrix-etherpad/tasks/setup_install.yml +++ b/roles/matrix-etherpad/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure Etherpad base path exists - file: + ansible.builtin.file: path: "{{ matrix_etherpad_base_path }}" state: directory mode: 0770 @@ -9,7 +9,7 @@ group: "{{ matrix_etherpad_user_gid }}" - name: Ensure Etherpad config installed - copy: + ansible.builtin.copy: content: "{{ matrix_etherpad_configuration|to_nice_json }}" dest: "{{ matrix_etherpad_base_path }}/settings.json" mode: 0640 @@ -28,13 +28,13 @@ until: result is not failed - name: Ensure matrix-etherpad.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-etherpad.service.j2" dest: "{{ matrix_systemd_path }}/matrix-etherpad.service" mode: 0644 register: matrix_etherpad_systemd_service_result - name: Ensure systemd reloaded after matrix-etherpad.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_etherpad_systemd_service_result.changed|bool" diff --git a/roles/matrix-etherpad/tasks/setup_uninstall.yml b/roles/matrix-etherpad/tasks/setup_uninstall.yml index ae1f2604..b72b70bc 100644 --- a/roles/matrix-etherpad/tasks/setup_uninstall.yml +++ b/roles/matrix-etherpad/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_etherpad_service_stat - name: Ensure matrix-etherpad is stopped - service: + ansible.builtin.service: name: matrix-etherpad state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_etherpad_service_stat.stat.exists|bool" - name: Ensure matrix-etherpad.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-etherpad.service" state: absent when: "matrix_etherpad_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-etherpad.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_etherpad_service_stat.stat.exists|bool" - name: Ensure Etherpad base directory doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_etherpad_base_path }}" state: absent diff --git a/roles/matrix-etherpad/tasks/validate_config.yml b/roles/matrix-etherpad/tasks/validate_config.yml index f9438e7b..07194d65 100644 --- a/roles/matrix-etherpad/tasks/validate_config.yml +++ b/roles/matrix-etherpad/tasks/validate_config.yml @@ -1,13 +1,13 @@ --- - name: Fail if Etherpad is enabled without the Dimension integrations manager - fail: + ansible.builtin.fail: msg: >- To integrate Etherpad notes with Matrix rooms you need to set "matrix_dimension_enabled" to true when: "not matrix_dimension_enabled|bool" - name: Fail if no database is configured for Etherpad - fail: + ansible.builtin.fail: msg: >- Etherpad requires a dedicated Postgres database. Please enable the built in one, or configure an external DB by redefining "matrix_etherpad_database_hostname" when: matrix_etherpad_database_hostname == "matrix-postgres" and not matrix_postgres_enabled diff --git a/roles/matrix-grafana/tasks/init.yml b/roles/matrix-grafana/tasks/init.yml index 4c2cbf06..e01743b7 100644 --- a/roles/matrix-grafana/tasks/init.yml +++ b/roles/matrix-grafana/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-grafana.service'] }}" when: matrix_grafana_enabled|bool diff --git a/roles/matrix-grafana/tasks/setup.yml b/roles/matrix-grafana/tasks/setup.yml index 16b9fa65..da25db59 100644 --- a/roles/matrix-grafana/tasks/setup.yml +++ b/roles/matrix-grafana/tasks/setup.yml @@ -17,7 +17,7 @@ until: result is not failed - name: Ensure grafana paths exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -34,7 +34,7 @@ when: matrix_grafana_enabled|bool - name: Ensure grafana.ini present - template: + ansible.builtin.template: src: "{{ role_path }}/templates/grafana.ini.j2" dest: "{{ matrix_grafana_config_path }}/grafana.ini" mode: 0440 @@ -43,7 +43,7 @@ when: matrix_grafana_enabled|bool - name: Ensure provisioning/datasources/default.yaml present - template: + ansible.builtin.template: src: "{{ role_path }}/templates/datasources.yaml.j2" dest: "{{ matrix_grafana_config_path }}/provisioning/datasources/default.yaml" mode: 0440 @@ -52,7 +52,7 @@ when: matrix_grafana_enabled|bool - name: Ensure provisioning/dashboards/default.yaml present - template: + ansible.builtin.template: src: "{{ role_path }}/templates/dashboards.yaml.j2" dest: "{{ matrix_grafana_config_path }}/provisioning/dashboards/default.yaml" mode: 0440 @@ -61,7 +61,7 @@ when: matrix_grafana_enabled|bool - name: Ensure dashboard(s) downloaded - get_url: + ansible.builtin.get_url: url: "{{ item }}" dest: "{{ matrix_grafana_config_path }}/dashboards/" force: true @@ -76,7 +76,7 @@ until: result is not failed - name: Ensure matrix-grafana.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-grafana.service.j2" dest: "{{ matrix_systemd_path }}/matrix-grafana.service" mode: 0644 @@ -84,7 +84,7 @@ when: matrix_grafana_enabled|bool - name: Ensure systemd reloaded after matrix-grafana.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_grafana_enabled|bool and matrix_grafana_systemd_service_result.changed" @@ -98,7 +98,7 @@ register: matrix_grafana_service_stat - name: Ensure matrix-grafana is stopped - service: + ansible.builtin.service: name: matrix-grafana state: stopped enabled: false @@ -107,12 +107,12 @@ when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists" - name: Ensure matrix-grafana.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + ansible.builtin.service: daemon_reload: true when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists" diff --git a/roles/matrix-grafana/tasks/validate_config.yml b/roles/matrix-grafana/tasks/validate_config.yml index 63d4919a..cc48c559 100644 --- a/roles/matrix-grafana/tasks/validate_config.yml +++ b/roles/matrix-grafana/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if Prometheus not enabled - fail: + ansible.builtin.fail: msg: > You need to enable `matrix_prometheus_enabled` to use Prometheus as data source for Grafana. when: "not matrix_prometheus_enabled" diff --git a/roles/matrix-jitsi/tasks/init.yml b/roles/matrix-jitsi/tasks/init.yml index 58567d92..9a64ac63 100644 --- a/roles/matrix-jitsi/tasks/init.yml +++ b/roles/matrix-jitsi/tasks/init.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-jitsi-web.service', 'matrix-jitsi-prosody.service', 'matrix-jitsi-jicofo.service', 'matrix-jitsi-jvb.service'] }}" when: matrix_jitsi_enabled|bool - name: Fail if on an unsupported architecture - fail: + ansible.builtin.fail: msg: "Jitsi only supports the amd64 architecture right now. See https://github.com/jitsi/docker-jitsi-meet/issues/1069 and https://github.com/jitsi/docker-jitsi-meet/issues/1214" when: matrix_jitsi_enabled|bool and matrix_architecture not in ['amd64', 'arm64'] diff --git a/roles/matrix-jitsi/tasks/setup_jitsi_base.yml b/roles/matrix-jitsi/tasks/setup_jitsi_base.yml index 4b390c18..a945450e 100644 --- a/roles/matrix-jitsi/tasks/setup_jitsi_base.yml +++ b/roles/matrix-jitsi/tasks/setup_jitsi_base.yml @@ -7,7 +7,7 @@ # - name: Ensure Matrix jitsi base path exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 diff --git a/roles/matrix-jitsi/tasks/setup_jitsi_jicofo.yml b/roles/matrix-jitsi/tasks/setup_jitsi_jicofo.yml index 0cb7043f..98569a13 100644 --- a/roles/matrix-jitsi/tasks/setup_jitsi_jicofo.yml +++ b/roles/matrix-jitsi/tasks/setup_jitsi_jicofo.yml @@ -5,7 +5,7 @@ # - name: Ensure Matrix jitsi-jicofo path exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0777 @@ -29,7 +29,7 @@ until: result is not failed - name: Ensure jitsi-jicofo environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/jicofo/env.j2" dest: "{{ matrix_jitsi_jicofo_base_path }}/env" owner: "{{ matrix_user_username }}" @@ -38,7 +38,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure jitsi-jicofo configuration files created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/jicofo/{{ item }}.j2" dest: "{{ matrix_jitsi_jicofo_config_path }}/{{ item }}" owner: "{{ matrix_user_username }}" @@ -50,7 +50,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure matrix-jitsi-jicofo.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/jicofo/matrix-jitsi-jicofo.service.j2" dest: "{{ matrix_systemd_path }}/matrix-jitsi-jicofo.service" mode: 0644 @@ -58,7 +58,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure systemd reloaded after matrix-jitsi-jicofo.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_jitsi_enabled and matrix_jitsi_jicofo_systemd_service_result.changed" @@ -73,7 +73,7 @@ when: "not matrix_jitsi_enabled|bool" - name: Ensure matrix-jitsi-jicofo is stopped - service: + ansible.builtin.service: name: matrix-jitsi-jicofo state: stopped enabled: false @@ -82,18 +82,18 @@ when: "not matrix_jitsi_enabled|bool and matrix_jitsi_jicofo_service_stat.stat.exists" - name: Ensure matrix-jitsi-jicofo.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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 - file: + ansible.builtin.file: path: "{{ matrix_jitsi_jicofo_base_path }}" state: absent when: "not matrix_jitsi_enabled|bool" diff --git a/roles/matrix-jitsi/tasks/setup_jitsi_jvb.yml b/roles/matrix-jitsi/tasks/setup_jitsi_jvb.yml index 90bf4a69..94425dc5 100644 --- a/roles/matrix-jitsi/tasks/setup_jitsi_jvb.yml +++ b/roles/matrix-jitsi/tasks/setup_jitsi_jvb.yml @@ -5,7 +5,7 @@ # - name: Ensure Matrix jitsi-jvb path exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0777 @@ -29,7 +29,7 @@ until: result is not failed - name: Ensure jitsi-jvb configuration files created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/jvb/{{ item }}.j2" dest: "{{ matrix_jitsi_jvb_config_path }}/{{ item }}" owner: "{{ matrix_user_username }}" @@ -41,7 +41,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure jitsi-jvb environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/jvb/env.j2" dest: "{{ matrix_jitsi_jvb_base_path }}/env" owner: "{{ matrix_user_username }}" @@ -50,7 +50,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure matrix-jitsi-jvb.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/jvb/matrix-jitsi-jvb.service.j2" dest: "{{ matrix_systemd_path }}/matrix-jitsi-jvb.service" mode: 0644 @@ -58,7 +58,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure systemd reloaded after matrix-jitsi-jvb.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_jitsi_enabled and matrix_jitsi_jvb_systemd_service_result.changed" @@ -73,7 +73,7 @@ when: "not matrix_jitsi_enabled|bool" - name: Ensure matrix-jitsi-jvb is stopped - service: + ansible.builtin.service: name: matrix-jitsi-jvb state: stopped enabled: false @@ -82,18 +82,18 @@ when: "not matrix_jitsi_enabled|bool and matrix_jitsi_jvb_service_stat.stat.exists" - name: Ensure matrix-jitsi-jvb.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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 - file: + ansible.builtin.file: path: "{{ matrix_jitsi_jvb_base_path }}" state: absent when: "not matrix_jitsi_enabled|bool" diff --git a/roles/matrix-jitsi/tasks/setup_jitsi_prosody.yml b/roles/matrix-jitsi/tasks/setup_jitsi_prosody.yml index 6db954b8..17122231 100644 --- a/roles/matrix-jitsi/tasks/setup_jitsi_prosody.yml +++ b/roles/matrix-jitsi/tasks/setup_jitsi_prosody.yml @@ -5,7 +5,7 @@ # - name: Ensure Matrix jitsi-prosody environment exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0777 @@ -30,7 +30,7 @@ until: result is not failed - name: Ensure jitsi-prosody environment variables file is created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/prosody/env.j2" dest: "{{ matrix_jitsi_prosody_base_path }}/env" owner: "{{ matrix_user_username }}" @@ -39,7 +39,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure matrix-jitsi-prosody.service file is installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/prosody/matrix-jitsi-prosody.service.j2" dest: "{{ matrix_systemd_path }}/matrix-jitsi-prosody.service" mode: 0644 @@ -47,13 +47,13 @@ when: matrix_jitsi_enabled|bool - name: Ensure systemd service is reloaded after matrix-jitsi-prosody.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_jitsi_enabled and matrix_jitsi_prosody_systemd_service_result.changed" - name: Ensure authentication is properly configured include_tasks: - file: "{{ role_path }}/tasks/util/setup_jitsi_auth.yml" + ansible.builtin.file: "{{ role_path }}/tasks/util/setup_jitsi_auth.yml" when: - matrix_jitsi_enabled|bool - matrix_jitsi_enable_auth|bool @@ -70,7 +70,7 @@ when: "not matrix_jitsi_enabled|bool" - name: Ensure matrix-jitsi-prosody is stopped - service: + ansible.builtin.service: name: matrix-jitsi-prosody state: stopped enabled: false @@ -79,18 +79,18 @@ when: "not matrix_jitsi_enabled|bool and matrix_jitsi_prosody_service_stat.stat.exists" - name: Ensure matrix-jitsi-prosody.service file doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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 - file: + ansible.builtin.file: path: "{{ matrix_jitsi_prosody_base_path }}" state: absent when: "not matrix_jitsi_enabled|bool" diff --git a/roles/matrix-jitsi/tasks/setup_jitsi_web.yml b/roles/matrix-jitsi/tasks/setup_jitsi_web.yml index feda4ace..586f703a 100644 --- a/roles/matrix-jitsi/tasks/setup_jitsi_web.yml +++ b/roles/matrix-jitsi/tasks/setup_jitsi_web.yml @@ -5,7 +5,7 @@ # - name: Ensure Matrix jitsi-web path exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0777 @@ -31,7 +31,7 @@ until: result is not failed - name: Ensure jitsi-web environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/web/env.j2" dest: "{{ matrix_jitsi_web_base_path }}/env" owner: "{{ matrix_user_username }}" @@ -40,7 +40,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure jitsi-web configuration files created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/web/{{ item }}.j2" dest: "{{ matrix_jitsi_web_config_path }}/{{ item }}" owner: "{{ matrix_user_username }}" @@ -52,7 +52,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure matrix-jitsi-web.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/web/matrix-jitsi-web.service.j2" dest: "{{ matrix_systemd_path }}/matrix-jitsi-web.service" mode: 0644 @@ -60,7 +60,7 @@ when: matrix_jitsi_enabled|bool - name: Ensure systemd reloaded after matrix-jitsi-web.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_jitsi_enabled and matrix_jitsi_web_systemd_service_result.changed" @@ -75,7 +75,7 @@ when: "not matrix_jitsi_enabled|bool" - name: Ensure matrix-jitsi-web is stopped - service: + ansible.builtin.service: name: matrix-jitsi-web state: stopped enabled: false @@ -84,18 +84,18 @@ when: "not matrix_jitsi_enabled|bool and matrix_jitsi_web_service_stat.stat.exists" - name: Ensure matrix-jitsi-web.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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 - file: + ansible.builtin.file: path: "{{ matrix_jitsi_web_base_path }}" state: absent when: "not matrix_jitsi_enabled|bool" diff --git a/roles/matrix-jitsi/tasks/util/setup_jitsi_auth.yml b/roles/matrix-jitsi/tasks/util/setup_jitsi_auth.yml index 50973acb..5176a7c0 100644 --- a/roles/matrix-jitsi/tasks/util/setup_jitsi_auth.yml +++ b/roles/matrix-jitsi/tasks/util/setup_jitsi_auth.yml @@ -4,7 +4,7 @@ # - name: Ensure matrix-jitsi-prosody container is running - systemd: + ansible.builtin.systemd: state: started name: matrix-jitsi-prosody register: matrix_jitsi_prosody_start_result @@ -15,7 +15,7 @@ # - name: Ensure Jitsi internal authentication users are configured - shell: "docker exec matrix-jitsi-prosody prosodyctl --config /config/prosody.cfg.lua register {{ item.username | quote }} meet.jitsi {{ item.password | quote }}" + ansible.builtin.shell: "docker exec matrix-jitsi-prosody prosodyctl --config /config/prosody.cfg.lua register {{ item.username | quote }} meet.jitsi {{ item.password | quote }}" with_items: "{{ matrix_jitsi_prosody_auth_internal_accounts }}" when: - matrix_jitsi_auth_type == "internal" @@ -33,7 +33,7 @@ # Stop Necessary Services # - name: Ensure matrix-jitsi-prosody container is stopped if necessary - systemd: + ansible.builtin.systemd: state: stopped name: matrix-jitsi-prosody when: matrix_jitsi_prosody_start_result.changed|bool diff --git a/roles/matrix-jitsi/tasks/validate_config.yml b/roles/matrix-jitsi/tasks/validate_config.yml index 5131396d..5655ea45 100644 --- a/roles/matrix-jitsi/tasks/validate_config.yml +++ b/roles/matrix-jitsi/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required Jitsi settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) to properly configure Jitsi. @@ -21,7 +21,7 @@ - name: Fail if a Jitsi internal authentication account is not defined - fail: + ansible.builtin.fail: msg: >- At least one Jitsi user needs to be defined in `matrix_jitsi_prosody_auth_internal_accounts` when using internal authentication. If you're setting up Jitsi for the first time, you may have missed a step. @@ -33,7 +33,7 @@ - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-ma1sd/tasks/init.yml b/roles/matrix-ma1sd/tasks/init.yml index a7c914db..f3059bb4 100644 --- a/roles/matrix-ma1sd/tasks/init.yml +++ b/roles/matrix-ma1sd/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_ma1sd_container_image_self_build and matrix_ma1sd_enabled|bool" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-ma1sd.service'] }}" when: matrix_ma1sd_enabled|bool diff --git a/roles/matrix-ma1sd/tasks/migrate_mxisd.yml b/roles/matrix-ma1sd/tasks/migrate_mxisd.yml index 720afa76..36ca8959 100644 --- a/roles/matrix-ma1sd/tasks/migrate_mxisd.yml +++ b/roles/matrix-ma1sd/tasks/migrate_mxisd.yml @@ -8,7 +8,7 @@ register: ma1sd_migrate_mxisd_data_dir_stat - name: Warn if mxisd data detected - debug: + ansible.builtin.debug: msg: > You seem to have an existing mxisd folder in `{{ matrix_base_data_path }}/mxisd`. We are going to migrate it to ma1sd and rename the folder to mxisd.migrated. @@ -20,7 +20,7 @@ register: matrix_mxisd_service_stat - name: Ensure matrix-mxisd is stopped - service: + ansible.builtin.service: name: matrix-mxisd state: stopped enabled: false @@ -34,7 +34,7 @@ when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists" - name: Ensure matrix-ma1sd is stopped - service: + ansible.builtin.service: name: matrix-ma1sd state: stopped daemon_reload: true @@ -44,7 +44,7 @@ # recursively copy remote directories (like `/matrix/mxisd/data/sign.key`) in older versions of Ansible. - block: - name: Copy mxisd data files to ma1sd folder - command: "cp -ar {{ matrix_base_data_path }}/mxisd/data {{ matrix_ma1sd_base_path }}" + ansible.builtin.command: "cp -ar {{ matrix_base_data_path }}/mxisd/data {{ matrix_ma1sd_base_path }}" - name: Check existence of mxisd.db file stat: @@ -52,20 +52,20 @@ register: matrix_ma1sd_mxisd_db_stat - name: Rename database (mxisd.db -> ma1sd.db) - command: "mv {{ matrix_ma1sd_data_path }}/mxisd.db {{ matrix_ma1sd_data_path }}/ma1sd.db" + ansible.builtin.command: "mv {{ matrix_ma1sd_data_path }}/mxisd.db {{ matrix_ma1sd_data_path }}/ma1sd.db" when: "matrix_ma1sd_mxisd_db_stat.stat.exists" - name: Rename mxisd folder - command: "mv {{ matrix_base_data_path }}/mxisd {{ matrix_base_data_path }}/mxisd.migrated" + ansible.builtin.command: "mv {{ matrix_base_data_path }}/mxisd {{ matrix_base_data_path }}/mxisd.migrated" when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists" - name: Ensure outdated matrix-mxisd.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-mxisd.service" state: absent when: "matrix_mxisd_service_stat.stat.exists" - name: Ensure systemd reloaded after removing outdated matrix-mxisd.service - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mxisd_service_stat.stat.exists" diff --git a/roles/matrix-ma1sd/tasks/self_check_ma1sd.yml b/roles/matrix-ma1sd/tasks/self_check_ma1sd.yml index 4a4c7136..6fde9dd2 100644 --- a/roles/matrix-ma1sd/tasks/self_check_ma1sd.yml +++ b/roles/matrix-ma1sd/tasks/self_check_ma1sd.yml @@ -1,10 +1,10 @@ --- -- set_fact: +- ansible.builtin.set_fact: ma1sd_url_endpoint_public: "https://{{ matrix_server_fqn_matrix }}/_matrix/identity/api/v1" - name: Check ma1sd Identity Service - uri: + ansible.builtin.uri: url: "{{ ma1sd_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_ma1sd_self_check_validate_certificates }}" @@ -13,10 +13,10 @@ ignore_errors: true - name: Fail if ma1sd Identity Service not working - fail: + ansible.builtin.fail: msg: "Failed checking ma1sd is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ ma1sd_url_endpoint_public }}`). Is ma1sd running? Is port 443 open in your firewall? Full error: {{ result_ma1sd }}" when: "result_ma1sd.failed or 'json' not in result_ma1sd" - name: Report working ma1sd Identity Service - debug: + ansible.builtin.debug: msg: "ma1sd at `{{ matrix_server_fqn_matrix }}` is working (checked endpoint: `{{ ma1sd_url_endpoint_public }}`)" diff --git a/roles/matrix-ma1sd/tasks/setup_install.yml b/roles/matrix-ma1sd/tasks/setup_install.yml index e3347a4d..2233067a 100644 --- a/roles/matrix-ma1sd/tasks/setup_install.yml +++ b/roles/matrix-ma1sd/tasks/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure ma1sd paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -18,7 +18,7 @@ # These (SQLite -> Postgres) migration tasks are usually at the top, # but we'd like to run them after `migrate_mxisd.yml`, which requires the ma1sd paths to exist. -- set_fact: +- ansible.builtin.set_fact: matrix_ma1sd_requires_restart: false - block: @@ -28,7 +28,7 @@ register: matrix_ma1sd_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_ma1sd_sqlite_database_path_local }}" dst: "{{ matrix_ma1sd_database_connection_string }}" @@ -40,7 +40,7 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_ma1sd_requires_restart: true when: "matrix_ma1sd_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_ma1sd_database_engine == 'postgres'" @@ -59,7 +59,7 @@ - block: - name: Ensure gradle is installed for self-building (Debian) - apt: + ansible.builtin.apt: name: - gradle state: present @@ -67,7 +67,7 @@ when: (ansible_os_family == 'Debian') - name: Ensure gradle is installed for self-building (RedHat) - fail: + ansible.builtin.fail: msg: "Installing gradle on RedHat ({{ ansible_distribution }}) is currently not supported, so self-building ma1sd cannot happen at this time" when: ansible_os_family == 'RedHat' @@ -80,7 +80,7 @@ when: ansible_distribution == 'Archlinux' - name: Ensure ma1sd repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_ma1sd_container_image_self_build_repo }}" dest: "{{ matrix_ma1sd_docker_src_files_path }}" version: "{{ matrix_ma1sd_container_image_self_build_branch }}" @@ -90,7 +90,7 @@ register: matrix_ma1sd_git_pull_results - name: Ensure ma1sd Docker image is built - shell: "DOCKER_BUILDKIT=1 ./gradlew dockerBuild" + ansible.builtin.shell: "DOCKER_BUILDKIT=1 ./gradlew dockerBuild" args: chdir: "{{ matrix_ma1sd_docker_src_files_path }}" when: matrix_ma1sd_git_pull_results.changed @@ -110,7 +110,7 @@ when: "matrix_ma1sd_container_image_self_build|bool" - name: Ensure ma1sd config installed - copy: + ansible.builtin.copy: content: "{{ matrix_ma1sd_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_ma1sd_config_path }}/ma1sd.yaml" mode: 0644 @@ -118,7 +118,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure custom view templates are installed, if any - copy: + ansible.builtin.copy: content: "{{ item.value }}" dest: "{{ matrix_ma1sd_config_path }}/{{ item.location }}" mode: 0644 @@ -130,7 +130,7 @@ when: "matrix_ma1sd_view_session_custom_templates_enabled|bool and item.value" - name: Ensure custom email templates are installed, if any - copy: + ansible.builtin.copy: content: "{{ item.value }}" dest: "{{ matrix_ma1sd_config_path }}/{{ item.location }}" mode: 0644 @@ -145,7 +145,7 @@ # Only cleaning up for people who define the respective templates - name: (Cleanup) Ensure custom email templates are not in data/ anymore (we've put them in config/) - file: + ansible.builtin.file: path: "{{ matrix_ma1sd_data_path }}/{{ item.location }}" state: absent with_items: @@ -156,19 +156,19 @@ when: "matrix_ma1sd_threepid_medium_email_custom_templates_enabled|bool and item.value" - name: Ensure matrix-ma1sd.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-ma1sd.service.j2" dest: "{{ matrix_systemd_path }}/matrix-ma1sd.service" mode: 0644 register: matrix_ma1sd_systemd_service_result - name: Ensure systemd reloaded after matrix-ma1sd.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_ma1sd_systemd_service_result.changed|bool" - name: Ensure matrix-ma1sd.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-ma1sd.service" state: restarted when: "matrix_ma1sd_requires_restart|bool" diff --git a/roles/matrix-ma1sd/tasks/setup_uninstall.yml b/roles/matrix-ma1sd/tasks/setup_uninstall.yml index 30a1bfda..d50cd613 100644 --- a/roles/matrix-ma1sd/tasks/setup_uninstall.yml +++ b/roles/matrix-ma1sd/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_ma1sd_service_stat - name: Ensure matrix-ma1sd is stopped - service: + ansible.builtin.service: name: matrix-ma1sd state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_ma1sd_service_stat.stat.exists|bool" - name: Ensure matrix-ma1sd.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-ma1sd.service" state: absent when: "matrix_ma1sd_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-ma1sd.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_ma1sd_service_stat.stat.exists|bool" - name: Ensure Matrix ma1sd paths don't exist - file: + ansible.builtin.file: path: "{{ matrix_ma1sd_base_path }}" state: absent diff --git a/roles/matrix-ma1sd/tasks/validate_config.yml b/roles/matrix-ma1sd/tasks/validate_config.yml index 5f621fca..af12dd3f 100644 --- a/roles/matrix-ma1sd/tasks/validate_config.yml +++ b/roles/matrix-ma1sd/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: (Deprecation) Warn about ma1sd variables that are not used anymore - fail: + ansible.builtin.fail: msg: > The `{{ item }}` variable defined in your configuration is not used by this playbook anymore! You'll need to adapt to the new way of extending ma1sd configuration. @@ -31,7 +31,7 @@ - 'matrix_ma1sd_architecture' - name: Ensure ma1sd configuration does not contain any dot-notation keys - fail: + ansible.builtin.fail: msg: > Since version 1.3.0, ma1sd will not accept property-style configuration keys. You have defined a key (`{{ item.key }}`) which contains a dot. @@ -40,7 +40,7 @@ with_dict: "{{ matrix_ma1sd_configuration }}" - name: Fail if required ma1sd settings not defined - fail: + ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) for using ma1sd. when: "vars[item] == ''" @@ -49,7 +49,7 @@ - "matrix_ma1sd_dns_overwrite_homeserver_client_value" - name: (Deprecation) Catch and report renamed ma1sd variables - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). @@ -60,7 +60,7 @@ - {'old': 'matrix_ma1sd_default_port', 'new': 'matrix_ma1sd_container_port'} - name: (Deprecation) Catch and report mxisd variables - fail: + ansible.builtin.fail: msg: >- mxisd is deprecated and has been replaced with ma1sd (https://github.com/ma1uta/ma1sd), a compatible fork. The playbook will migrate your existing mxisd configuration and data automatically, but you need to adjust variable names. diff --git a/roles/matrix-mailer/tasks/init.yml b/roles/matrix-mailer/tasks/init.yml index c928d557..c0afe962 100644 --- a/roles/matrix-mailer/tasks/init.yml +++ b/roles/matrix-mailer/tasks/init.yml @@ -2,10 +2,10 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_mailer_container_image_self_build and matrix_mailer_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mailer.service'] }}" when: matrix_mailer_enabled|bool diff --git a/roles/matrix-mailer/tasks/setup_mailer.yml b/roles/matrix-mailer/tasks/setup_mailer.yml index d2f8f917..aa1e725a 100644 --- a/roles/matrix-mailer/tasks/setup_mailer.yml +++ b/roles/matrix-mailer/tasks/setup_mailer.yml @@ -5,7 +5,7 @@ # - name: Ensure mailer base path exists - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -17,14 +17,14 @@ when: "matrix_mailer_enabled|bool and item.when" - name: Ensure mailer environment variables file created - template: + 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 - git: + ansible.builtin.git: repo: "{{ matrix_mailer_container_image_self_build_repository_url }}" dest: "{{ matrix_mailer_container_image_self_build_src_files_path }}" version: "{{ matrix_mailer_container_image_self_build_version }}" @@ -59,7 +59,7 @@ until: result is not failed - name: Ensure matrix-mailer.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mailer.service.j2" dest: "{{ matrix_systemd_path }}/matrix-mailer.service" mode: 0644 @@ -67,7 +67,7 @@ when: matrix_mailer_enabled|bool - name: Ensure systemd reloaded after matrix-mailer.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_mailer_enabled|bool and matrix_mailer_systemd_service_result.changed" @@ -82,7 +82,7 @@ when: "not matrix_mailer_enabled|bool" - name: Ensure matrix-mailer is stopped - service: + ansible.builtin.service: name: matrix-mailer state: stopped enabled: false @@ -91,18 +91,18 @@ when: "not matrix_mailer_enabled|bool and matrix_mailer_service_stat.stat.exists" - name: Ensure matrix-mailer.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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 - file: + ansible.builtin.file: path: "{{ matrix_mailer_base_path }}" state: absent when: "not matrix_mailer_enabled|bool" diff --git a/roles/matrix-nginx-proxy/tasks/init.yml b/roles/matrix-nginx-proxy/tasks/init.yml index ddc8cb47..3f31470c 100644 --- a/roles/matrix-nginx-proxy/tasks/init.yml +++ b/roles/matrix-nginx-proxy/tasks/init.yml @@ -1,9 +1,9 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-nginx-proxy.service'] }}" when: matrix_nginx_proxy_enabled|bool -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + [item.name] }}" when: "item.applicable|bool and item.enableable|bool" with_items: "{{ matrix_ssl_renewal_systemd_units_list }}" diff --git a/roles/matrix-nginx-proxy/tasks/main.yml b/roles/matrix-nginx-proxy/tasks/main.yml index 74f8e8d1..066e62d3 100644 --- a/roles/matrix-nginx-proxy/tasks/main.yml +++ b/roles/matrix-nginx-proxy/tasks/main.yml @@ -33,7 +33,7 @@ - self-check - name: Mark matrix-nginx-proxy role as executed - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_role_executed: true tags: - always diff --git a/roles/matrix-nginx-proxy/tasks/nginx-proxy/setup_metrics_auth.yml b/roles/matrix-nginx-proxy/tasks/nginx-proxy/setup_metrics_auth.yml index 046746df..5d100577 100644 --- a/roles/matrix-nginx-proxy/tasks/nginx-proxy/setup_metrics_auth.yml +++ b/roles/matrix-nginx-proxy/tasks/nginx-proxy/setup_metrics_auth.yml @@ -2,7 +2,7 @@ # When we're dealing with raw htpasswd content, we just store it in the file directly. - name: Ensure matrix-metrics-htpasswd is present when generated from raw content (protecting /metrics/* URIs) - copy: + ansible.builtin.copy: content: "{{ matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_raw_content }}" dest: "{{ matrix_nginx_proxy_data_path }}/matrix-metrics-htpasswd" owner: "{{ matrix_user_username }}" @@ -30,7 +30,7 @@ # We store the password in a file and make the `htpasswd` tool read it from there, # as opposed to passing it directly on stdin (which will expose it to other processes on the server). - name: Store metrics password in a temporary file - copy: + ansible.builtin.copy: content: "{{ matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_password }}" dest: "/tmp/matrix-nginx-proxy-metrics-password" mode: 0400 @@ -38,7 +38,7 @@ group: "{{ matrix_user_gid }}" - name: Generate matrix-metrics-htpasswd from username/password (protecting /metrics/* URIs) - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -53,7 +53,7 @@ 'cat /password | htpasswd -i -c /data/matrix-metrics-htpasswd {{ matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_username }} && chmod 600 /data/matrix-metrics-htpasswd' - name: Delete temporary metrics password file - file: + ansible.builtin.file: path: /tmp/matrix-nginx-proxy-metrics-password state: absent when: matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_username != '' diff --git a/roles/matrix-nginx-proxy/tasks/self_check_well_known.yml b/roles/matrix-nginx-proxy/tasks/self_check_well_known.yml index be1b6555..ad53084d 100644 --- a/roles/matrix-nginx-proxy/tasks/self_check_well_known.yml +++ b/roles/matrix-nginx-proxy/tasks/self_check_well_known.yml @@ -1,7 +1,7 @@ --- - name: Determine well-known files to check (Matrix) - set_fact: + ansible.builtin.set_fact: well_known_file_checks: - path: /.well-known/matrix/client purpose: Client Discovery @@ -10,7 +10,7 @@ validate_certs: "{{ matrix_nginx_proxy_self_check_validate_certificates }}" - block: - - set_fact: + - ansible.builtin.set_fact: well_known_file_check_matrix_server: path: /.well-known/matrix/server purpose: Server Discovery @@ -19,7 +19,7 @@ validate_certs: "{{ matrix_nginx_proxy_self_check_validate_certificates }}" - name: Determine domains that we require certificates for (ma1sd) - set_fact: + ansible.builtin.set_fact: well_known_file_checks: "{{ well_known_file_checks + [well_known_file_check_matrix_server] }}" when: matrix_well_known_matrix_server_enabled|bool diff --git a/roles/matrix-nginx-proxy/tasks/self_check_well_known_file.yml b/roles/matrix-nginx-proxy/tasks/self_check_well_known_file.yml index 588cd1e7..0a7b5845 100644 --- a/roles/matrix-nginx-proxy/tasks/self_check_well_known_file.yml +++ b/roles/matrix-nginx-proxy/tasks/self_check_well_known_file.yml @@ -1,13 +1,13 @@ --- -- set_fact: +- ansible.builtin.set_fact: well_known_url_matrix: "https://{{ matrix_server_fqn_matrix }}{{ well_known_file_check.path }}" well_known_url_identity: "https://{{ matrix_domain }}{{ well_known_file_check.path }}" # These well-known files may be served without a `Content-Type: application/json` header, # so we can't rely on the uri module's automatic parsing of JSON. - name: Check .well-known on the matrix hostname - uri: + ansible.builtin.uri: url: "{{ well_known_url_matrix }}" follow_redirects: none return_content: true @@ -19,25 +19,25 @@ ignore_errors: true - name: Fail if .well-known not working on the matrix hostname - fail: + ansible.builtin.fail: msg: "Failed checking that the well-known file for {{ well_known_file_check.purpose }} is configured at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ well_known_url_matrix }}`). Is port 443 open in your firewall? Full error: {{ result_well_known_matrix }}" when: "result_well_known_matrix.failed" - name: Parse JSON for well-known payload at the matrix hostname - set_fact: + ansible.builtin.set_fact: well_known_matrix_payload: "{{ result_well_known_matrix.content|from_json }}" - name: Fail if .well-known not CORS-aware on the matrix hostname - fail: + ansible.builtin.fail: msg: "The well-known file for {{ well_known_file_check.purpose }} on `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ well_known_url_matrix }}`) is not CORS-aware. The file needs to be served with an Access-Control-Allow-Origin header set." when: "well_known_file_check.cors and 'access_control_allow_origin' not in result_well_known_matrix" - name: Report working .well-known on the matrix hostname - debug: + ansible.builtin.debug: msg: "well-known for {{ well_known_file_check.purpose }} is configured correctly for `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ well_known_url_matrix }}`)" - name: Check .well-known on the identity hostname - uri: + ansible.builtin.uri: url: "{{ well_known_url_identity }}" follow_redirects: "{{ well_known_file_check.follow_redirects }}" return_content: true @@ -49,25 +49,25 @@ ignore_errors: true - name: Fail if .well-known not working on the identity hostname - fail: + ansible.builtin.fail: msg: "Failed checking that the well-known file for {{ well_known_file_check.purpose }} is configured at `{{ matrix_domain }}` (checked endpoint: `{{ well_known_url_identity }}`). Is port 443 open in your firewall? Full error: {{ result_well_known_identity }}" when: "result_well_known_identity.failed" - name: Parse JSON for well-known payload at the identity hostname - set_fact: + ansible.builtin.set_fact: well_known_identity_payload: "{{ result_well_known_identity.content|from_json }}" - name: Fail if .well-known not CORS-aware on the identity hostname - fail: + ansible.builtin.fail: msg: "The well-known file for {{ well_known_file_check.purpose }} on `{{ matrix_domain }}` (checked endpoint: `{{ well_known_url_identity }}`) is not CORS-aware. The file needs to be served with an Access-Control-Allow-Origin header set. See docs/configuring-well-known.md" when: "well_known_file_check.cors and 'access_control_allow_origin' not in result_well_known_identity" # For people who manually copy the well-known file, try to detect if it's outdated - name: Fail if well-known is different on matrix hostname and identity hostname - fail: + ansible.builtin.fail: msg: "The well-known files for {{ well_known_file_check.purpose }} at `{{ matrix_server_fqn_matrix }}` and `{{ matrix_domain }}` are different. Perhaps you copied the file ({{ well_known_file_check.path }}) manually before and now it's outdated?" when: "well_known_matrix_payload != well_known_identity_payload" - name: Report working .well-known on the identity hostname - debug: + ansible.builtin.debug: msg: "well-known for {{ well_known_file_check.purpose }} ({{ well_known_file_check.path }}) is configured correctly for `{{ matrix_domain }}` (checked endpoint: `{{ well_known_url_identity }}`)" diff --git a/roles/matrix-nginx-proxy/tasks/setup_nginx_proxy.yml b/roles/matrix-nginx-proxy/tasks/setup_nginx_proxy.yml index 70541fdc..7a71c739 100644 --- a/roles/matrix-nginx-proxy/tasks/setup_nginx_proxy.yml +++ b/roles/matrix-nginx-proxy/tasks/setup_nginx_proxy.yml @@ -11,7 +11,7 @@ # to be unnecessary. # - name: Ensure Matrix nginx-proxy paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -25,7 +25,7 @@ when: item.when|bool - name: Ensure Matrix nginx-proxy configured (main config override) - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/nginx.conf.j2" dest: "{{ matrix_nginx_proxy_base_path }}/nginx.conf" mode: 0644 @@ -36,123 +36,123 @@ when: matrix_nginx_proxy_proxy_matrix_metrics_enabled|bool and matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_enabled|bool - name: Ensure Matrix nginx-proxy configured (generic) - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/nginx-http.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/nginx-http.conf" mode: 0644 when: matrix_nginx_proxy_enabled|bool - name: Ensure Matrix nginx-proxy configuration for matrix-synapse exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-synapse.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-synapse.conf" mode: 0644 when: matrix_nginx_proxy_proxy_synapse_enabled|bool - name: Ensure Matrix nginx-proxy configuration for matrix-synapse deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-synapse.conf" state: absent when: "not matrix_nginx_proxy_proxy_synapse_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for matrix-dendrite exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-dendrite.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-dendrite.conf" mode: 0644 when: matrix_nginx_proxy_proxy_dendrite_enabled|bool - name: Ensure Matrix nginx-proxy configuration for matrix-dendrite deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-dendrite.conf" state: absent when: "not matrix_nginx_proxy_proxy_dendrite_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for Element domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-client-element.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-client-element.conf" mode: 0644 when: matrix_nginx_proxy_proxy_element_enabled|bool - name: Ensure Matrix nginx-proxy configuration for riot domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-riot-web.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-riot-web.conf" mode: 0644 when: matrix_nginx_proxy_proxy_riot_compat_redirect_enabled|bool - name: Ensure Matrix nginx-proxy configuration for Hydrogen domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-client-hydrogen.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-client-hydrogen.conf" mode: 0644 when: matrix_nginx_proxy_proxy_hydrogen_enabled|bool - name: Ensure Matrix nginx-proxy configuration for Cinny domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-client-cinny.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-client-cinny.conf" mode: 0644 when: matrix_nginx_proxy_proxy_cinny_enabled|bool - name: Ensure Matrix nginx-proxy configuration for buscarron domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-bot-buscarron.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-bot-buscarron.conf" mode: 0644 when: matrix_nginx_proxy_proxy_buscarron_enabled|bool - name: Ensure Matrix nginx-proxy configuration for dimension domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-dimension.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-dimension.conf" mode: 0644 when: matrix_nginx_proxy_proxy_dimension_enabled|bool - name: Ensure Matrix nginx-proxy configuration for goneb domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-bot-go-neb.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-bot-go-neb.conf" mode: 0644 when: matrix_nginx_proxy_proxy_bot_go_neb_enabled|bool - name: Ensure Matrix nginx-proxy configuration for jitsi domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-jitsi.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-jitsi.conf" mode: 0644 when: matrix_nginx_proxy_proxy_jitsi_enabled|bool - name: Ensure Matrix nginx-proxy configuration for grafana domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-grafana.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-grafana.conf" mode: 0644 when: matrix_nginx_proxy_proxy_grafana_enabled|bool - name: Ensure Matrix nginx-proxy configuration for sygnal domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-sygnal.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-sygnal.conf" mode: 0644 when: matrix_nginx_proxy_proxy_sygnal_enabled|bool - name: Ensure Matrix nginx-proxy configuration for ntfy domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-ntfy.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-ntfy.conf" mode: 0644 when: matrix_nginx_proxy_proxy_ntfy_enabled|bool - name: Ensure Matrix nginx-proxy configuration for Matrix domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-domain.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-domain.conf" mode: 0644 - name: Ensure Matrix nginx-proxy data directory for base domain exists - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_data_path }}/matrix-domain" state: directory mode: 0750 @@ -161,7 +161,7 @@ when: matrix_nginx_proxy_base_domain_serving_enabled|bool and matrix_nginx_proxy_base_domain_create_directory|bool - name: Ensure Matrix nginx-proxy homepage for base domain exists - copy: + ansible.builtin.copy: content: "{{ matrix_nginx_proxy_base_domain_homepage_template }}" dest: "{{ matrix_nginx_proxy_data_path }}/matrix-domain/index.html" mode: 0644 @@ -170,7 +170,7 @@ when: matrix_nginx_proxy_base_domain_serving_enabled|bool and matrix_nginx_proxy_base_domain_homepage_enabled|bool and matrix_nginx_proxy_base_domain_create_directory|bool - name: Ensure Matrix nginx-proxy configuration for base domain exists - template: + ansible.builtin.template: src: "{{ role_path }}/templates/nginx/conf.d/matrix-base-domain.conf.j2" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-base-domain.conf" mode: 0644 @@ -192,7 +192,7 @@ until: result is not failed - name: Ensure matrix-nginx-proxy.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-nginx-proxy.service.j2" dest: "{{ matrix_systemd_path }}/matrix-nginx-proxy.service" mode: 0644 @@ -200,7 +200,7 @@ when: matrix_nginx_proxy_enabled|bool - name: Ensure systemd reloaded after matrix-nginx-proxy.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_nginx_proxy_enabled and matrix_nginx_proxy_systemd_service_result.changed" @@ -216,7 +216,7 @@ when: "not matrix_nginx_proxy_enabled|bool" - name: Ensure matrix-nginx-proxy is stopped - service: + ansible.builtin.service: name: matrix-nginx-proxy state: stopped enabled: false @@ -225,113 +225,113 @@ when: "not matrix_nginx_proxy_enabled|bool and matrix_nginx_proxy_service_stat.stat.exists" - name: Ensure matrix-nginx-proxy.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-nginx-proxy.service" state: absent when: "not matrix_nginx_proxy_enabled|bool and matrix_nginx_proxy_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-nginx-proxy.service removal - service: + ansible.builtin.service: daemon_reload: true when: "not matrix_nginx_proxy_enabled|bool and matrix_nginx_proxy_service_stat.stat.exists" - name: Ensure Matrix nginx-proxy configuration for matrix domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-domain.conf" state: absent when: "not matrix_nginx_proxy_proxy_matrix_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for riot domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-riot-web.conf" state: absent when: "not matrix_nginx_proxy_proxy_riot_compat_redirect_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for Hydrogen domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-client-hydrogen.conf" state: absent when: "not matrix_nginx_proxy_proxy_hydrogen_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for Cinny domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-client-cinny.conf" state: absent when: "not matrix_nginx_proxy_proxy_cinny_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for buscarron domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-bot-buscarron.conf" state: absent when: "not matrix_nginx_proxy_proxy_buscarron_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for dimension domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-dimension.conf" state: absent when: "not matrix_nginx_proxy_proxy_dimension_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for goneb domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-bot-go-neb.conf" state: absent when: "not matrix_nginx_proxy_proxy_bot_go_neb_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for jitsi domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-jitsi.conf" state: absent when: "not matrix_nginx_proxy_proxy_jitsi_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for grafana domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-grafana.conf" state: absent when: "not matrix_nginx_proxy_proxy_grafana_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for sygnal domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-sygnal.conf" state: absent when: "not matrix_nginx_proxy_proxy_sygnal_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for ntfy domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-ntfy.conf" state: absent when: "not matrix_nginx_proxy_proxy_ntfy_enabled|bool" - name: Ensure Matrix nginx-proxy homepage for base domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_data_path }}/matrix-domain/index.html" state: absent when: "not matrix_nginx_proxy_base_domain_serving_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for base domain deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_confd_path }}/matrix-base-domain.conf" state: absent when: "not matrix_nginx_proxy_base_domain_serving_enabled|bool" - name: Ensure Matrix nginx-proxy configuration for main config override deleted - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_base_path }}/nginx.conf" state: absent when: "not matrix_nginx_proxy_enabled|bool" - name: Ensure Matrix nginx-proxy htpasswd is deleted (protecting /_synapse/metrics URI) - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_data_path }}/matrix-synapse-metrics-htpasswd" state: absent # This file is now generated by the matrix-synapse role and saved in the Synapse directory - name: (Cleanup) Ensure old sample prometheus.yml for external scraping is deleted - file: + ansible.builtin.file: path: "{{ matrix_base_data_path }}/external_prometheus.yml.example" state: absent - name: Ensure Matrix nginx-proxy htpasswd is deleted (protecting /metrics/* URIs) - file: + ansible.builtin.file: path: "{{ matrix_nginx_proxy_data_path }}/matrix-metrics-htpasswd" state: absent when: "not matrix_nginx_proxy_proxy_matrix_metrics_enabled|bool or not matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_enabled|bool" diff --git a/roles/matrix-nginx-proxy/tasks/setup_well_known.yml b/roles/matrix-nginx-proxy/tasks/setup_well_known.yml index 1c85552c..11e941bd 100644 --- a/roles/matrix-nginx-proxy/tasks/setup_well_known.yml +++ b/roles/matrix-nginx-proxy/tasks/setup_well_known.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_well_known_file_path: "{{ matrix_static_files_base_path }}/.well-known/matrix/client" # We need others to be able to read these directories too, @@ -7,7 +7,7 @@ # # For running with another webserver, we recommend being part of the `matrix` group. - name: Ensure Matrix static-files path exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0755 @@ -17,7 +17,7 @@ - "{{ matrix_static_files_base_path }}/.well-known/matrix" - name: Ensure Matrix /.well-known/matrix/client configured - template: + ansible.builtin.template: src: "{{ role_path }}/templates/well-known/matrix-client.j2" dest: "{{ matrix_static_files_base_path }}/.well-known/matrix" mode: 0644 diff --git a/roles/matrix-nginx-proxy/tasks/ssl/main.yml b/roles/matrix-nginx-proxy/tasks/ssl/main.yml index 6b843c7b..d6a2627b 100644 --- a/roles/matrix-nginx-proxy/tasks/ssl/main.yml +++ b/roles/matrix-nginx-proxy/tasks/ssl/main.yml @@ -1,12 +1,12 @@ --- - name: Fail if using unsupported SSL certificate retrieval method - fail: + ansible.builtin.fail: msg: "The `matrix_ssl_retrieval_method` variable contains an unsupported value" when: "matrix_ssl_retrieval_method not in ['lets-encrypt', 'self-signed', 'manually-managed', 'none']" - name: Fail if using unsupported private key type - fail: + ansible.builtin.fail: msg: "The `matrix_ssl_lets_encrypt_key_type` variable contains an unsupported value" when: "matrix_ssl_lets_encrypt_key_type not in ['rsa', 'ecdsa']" @@ -14,7 +14,7 @@ # Common tasks, required by almost any method below. - name: Ensure SSL certificate paths exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0770 diff --git a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt.yml b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt.yml index bfd25894..46be689c 100644 --- a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt.yml +++ b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt.yml @@ -3,7 +3,7 @@ # This is a cleanup/migration task, because of to the new way we manage cronjobs (`cron` module) and the new script name. # This migration task can be removed some time in the future. - name: (Migration) Remove deprecated Let's Encrypt SSL certificate management files - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: @@ -31,13 +31,13 @@ loop_var: domain_name - name: Ensure Let's Encrypt SSL renewal script installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/usr-local-bin/matrix-ssl-lets-encrypt-certificates-renew.j2" dest: "{{ matrix_local_bin_path }}/matrix-ssl-lets-encrypt-certificates-renew" mode: 0755 - name: Ensure SSL renewal systemd units installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/{{ item.name }}.j2" dest: "{{ matrix_systemd_path }}/{{ item.name }}" mode: 0644 @@ -51,14 +51,14 @@ - block: - name: Ensure matrix-ssl-lets-encrypt-renew cronjob removed - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/{{ item.name }}" state: absent when: "not item.applicable|bool" with_items: "{{ matrix_ssl_renewal_systemd_units_list }}" - name: Ensure Let's Encrypt SSL renewal script removed - file: + ansible.builtin.file: path: "{{ matrix_local_bin_path }}/matrix-ssl-lets-encrypt-certificates-renew" state: absent when: "matrix_ssl_retrieval_method != 'lets-encrypt'" diff --git a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml index 12a21257..02a137f3 100644 --- a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml +++ b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml @@ -1,8 +1,8 @@ --- -- debug: +- ansible.builtin.debug: msg: "Dealing with SSL certificate retrieval for domain: {{ domain_name }}" -- set_fact: +- ansible.builtin.set_fact: domain_name_certificate_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/fullchain.pem" - name: Check if a certificate for the domain already exists @@ -10,12 +10,12 @@ path: "{{ domain_name_certificate_path }}" register: domain_name_certificate_path_stat -- set_fact: +- ansible.builtin.set_fact: domain_name_needs_cert: "{{ not domain_name_certificate_path_stat.stat.exists }}" - block: - name: Ensure required service for obtaining is started - service: + ansible.builtin.service: name: "{{ matrix_ssl_pre_obtaining_required_service_name }}" state: started register: matrix_ssl_pre_obtaining_required_service_start_result @@ -29,7 +29,7 @@ # This will fail if there is something running on port 80 (like matrix-nginx-proxy). # We suppress the error, as we'll try another method below. - name: Attempt initial SSL certificate retrieval with standalone authenticator (directly) - shell: >- + ansible.builtin.shell: >- {{ matrix_host_command_docker }} run --rm --name=matrix-certbot @@ -58,7 +58,7 @@ # If matrix-nginx-proxy is configured from a previous run of this playbook, # and it's running now, it may be able to proxy requests to `matrix_ssl_lets_encrypt_certbot_standalone_http_port`. - name: Attempt initial SSL certificate retrieval with standalone authenticator (via proxy) - shell: >- + ansible.builtin.shell: >- {{ matrix_host_command_docker }} run --rm --name=matrix-certbot @@ -86,7 +86,7 @@ ignore_errors: true - name: Fail if all SSL certificate retrieval attempts failed - fail: + ansible.builtin.fail: msg: | Failed to obtain a certificate directly (by listening on port 80) and also failed to obtain by relying on the server at port 80 to proxy the request. diff --git a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_manually_managed_verify_for_domain.yml b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_manually_managed_verify_for_domain.yml index 2b5bb1f3..8bab1128 100644 --- a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_manually_managed_verify_for_domain.yml +++ b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_manually_managed_verify_for_domain.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_ssl_certificate_verification_cert_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/fullchain.pem" matrix_ssl_certificate_verification_cert_key_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/privkey.pem" @@ -9,7 +9,7 @@ path: "{{ matrix_ssl_certificate_verification_cert_path }}" register: matrix_ssl_certificate_verification_cert_path_stat_result -- fail: +- ansible.builtin.fail: msg: "Failed finding a certificate file (for domain `{{ domain_name }}`) at `{{ matrix_ssl_certificate_verification_cert_path }}`" when: "not matrix_ssl_certificate_verification_cert_path_stat_result.stat.exists" @@ -18,6 +18,6 @@ path: "{{ matrix_ssl_certificate_verification_cert_key_path }}" register: matrix_ssl_certificate_verification_cert_key_path_stat_result -- fail: +- ansible.builtin.fail: msg: "Failed finding a certificate key file (for domain `{{ domain_name }}`) at `{{ matrix_ssl_certificate_verification_cert_key_path }}`" when: "not matrix_ssl_certificate_verification_cert_key_path_stat_result.stat.exists" diff --git a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed_obtain_for_domain.yml b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed_obtain_for_domain.yml index ff7fa2d8..873420c3 100644 --- a/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed_obtain_for_domain.yml +++ b/roles/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed_obtain_for_domain.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_ssl_certificate_csr_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/csr.csr" matrix_ssl_certificate_cert_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/fullchain.pem" matrix_ssl_certificate_cert_key_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/privkey.pem" @@ -12,7 +12,7 @@ # In order to do any sort of generation (below), we need to ensure the directory exists first - name: Ensure SSL certificate directory exists - file: + ansible.builtin.file: path: "{{ matrix_ssl_certificate_csr_path|dirname }}" state: directory mode: 0750 @@ -28,7 +28,7 @@ # # We'll do it in a more manual way. - name: Generate SSL certificate - command: | + ansible.builtin.command: | openssl req -x509 \ -sha256 \ -newkey rsa:4096 \ @@ -40,7 +40,7 @@ when: "not matrix_ssl_certificate_cert_path_stat_result.stat.exists" - name: Adjust SSL certificate file ownership - file: + ansible.builtin.file: path: "{{ item }}" owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" diff --git a/roles/matrix-nginx-proxy/tasks/validate_config.yml b/roles/matrix-nginx-proxy/tasks/validate_config.yml index c6697e93..7e3b1ecc 100644 --- a/roles/matrix-nginx-proxy/tasks/validate_config.yml +++ b/roles/matrix-nginx-proxy/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). @@ -16,19 +16,19 @@ - {'old': 'matrix_nginx_proxy_reload_cron_time_definition', 'new': ''} - name: Fail on unknown matrix_ssl_retrieval_method - fail: + ansible.builtin.fail: msg: >- `matrix_ssl_retrieval_method` needs to be set to a known value. when: "matrix_ssl_retrieval_method not in ['lets-encrypt', 'self-signed', 'manually-managed', 'none']" - name: Fail on unknown matrix_nginx_proxy_ssl_config - fail: + ansible.builtin.fail: msg: >- `matrix_nginx_proxy_ssl_preset` needs to be set to a known value. when: "matrix_nginx_proxy_ssl_preset not in ['modern', 'intermediate', 'old']" - name: Fail if Basic Auth enabled for metrics, but no credentials supplied - fail: + ansible.builtin.fail: msg: | Enabling Basic Auth for metrics (`matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_enabled`) requires: - either a username/password (provided in `matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_username` and `matrix_nginx_proxy_proxy_matrix_metrics_basic_auth_password`) @@ -37,7 +37,7 @@ - block: - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). @@ -48,7 +48,7 @@ when: "item.old in vars" - name: Fail if required variables are undefined - fail: + ansible.builtin.fail: msg: "The `{{ item }}` variable must be defined and have a non-null value" with_items: - "matrix_ssl_lets_encrypt_support_email" @@ -60,7 +60,7 @@ when: "matrix_ssl_retrieval_method == 'lets-encrypt'" - name: (Deprecation) Catch and report old metrics usage - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable (`{{ item }}`), which refers to the old metrics collection system for Synapse, which exposed metrics on `https://matrix.DOMAIN/_synapse/metrics` and `https://matrix.DOMAIN/_synapse-worker-TYPE-ID/metrics`. diff --git a/roles/matrix-ntfy/tasks/init.yml b/roles/matrix-ntfy/tasks/init.yml index e2622655..997be03f 100644 --- a/roles/matrix-ntfy/tasks/init.yml +++ b/roles/matrix-ntfy/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-ntfy.service'] }}" when: matrix_ntfy_enabled|bool diff --git a/roles/matrix-ntfy/tasks/self_check.yml b/roles/matrix-ntfy/tasks/self_check.yml index e9104734..02529f35 100644 --- a/roles/matrix-ntfy/tasks/self_check.yml +++ b/roles/matrix-ntfy/tasks/self_check.yml @@ -3,11 +3,11 @@ # Query an arbitrary ntfy topic using ntfy's UnifiedPush topic name syntax. # Expect an empty response (because we query 'since=1s'). -- set_fact: +- ansible.builtin.set_fact: matrix_ntfy_url_endpoint_public: "{{ matrix_ntfy_base_url }}/upSELFCHECK123/json?poll=1&since=1s" - name: Check ntfy - uri: + ansible.builtin.uri: url: "{{ matrix_ntfy_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_ntfy_self_check_validate_certificates }}" @@ -16,10 +16,10 @@ ignore_errors: true - name: Fail if ntfy not working - fail: + ansible.builtin.fail: msg: "Failed checking ntfy is up at `{{ matrix_server_fqn_ntfy }}` (checked endpoint: `{{ matrix_ntfy_url_endpoint_public }}`). Is ntfy running? Is port 443 open in your firewall? Full error: {{ matrix_ntfy_self_check_result }}" when: "matrix_ntfy_self_check_result.failed" - name: Report working ntfy - debug: + ansible.builtin.debug: msg: "ntfy at `{{ matrix_server_fqn_ntfy }}` is working (checked endpoint: `{{ matrix_ntfy_url_endpoint_public }}`)" diff --git a/roles/matrix-ntfy/tasks/setup_install.yml b/roles/matrix-ntfy/tasks/setup_install.yml index 461d3176..510110c1 100644 --- a/roles/matrix-ntfy/tasks/setup_install.yml +++ b/roles/matrix-ntfy/tasks/setup_install.yml @@ -12,7 +12,7 @@ until: result is not failed - name: Ensure matrix-ntfy paths exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -24,7 +24,7 @@ - "{{ matrix_ntfy_data_path }}" - name: Ensure matrix-ntfy config installed - copy: + ansible.builtin.copy: content: "{{ matrix_ntfy_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_ntfy_config_dir_path }}/server.yml" mode: 0644 @@ -32,13 +32,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-ntfy.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-ntfy.service.j2" dest: "{{ matrix_systemd_path }}/matrix-ntfy.service" mode: 0644 register: matrix_ntfy_systemd_service_result - name: Ensure systemd reloaded after matrix-ntfy.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_ntfy_systemd_service_result.changed" diff --git a/roles/matrix-ntfy/tasks/setup_uninstall.yml b/roles/matrix-ntfy/tasks/setup_uninstall.yml index e63caa9a..93ecad3d 100644 --- a/roles/matrix-ntfy/tasks/setup_uninstall.yml +++ b/roles/matrix-ntfy/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_ntfy_service_stat - name: Ensure matrix-ntfy is stopped - service: + ansible.builtin.service: name: matrix-ntfy state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_ntfy_service_stat.stat.exists" - name: Ensure matrix-ntfy.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-ntfy.service" state: absent when: "matrix_ntfy_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-ntfy.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_ntfy_service_stat.stat.exists" - name: Ensure matrix-ntfy path doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_ntfy_base_path }}" state: absent diff --git a/roles/matrix-postgres-backup/tasks/init.yml b/roles/matrix-postgres-backup/tasks/init.yml index f74cea06..aea1c337 100644 --- a/roles/matrix-postgres-backup/tasks/init.yml +++ b/roles/matrix-postgres-backup/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-postgres-backup.service'] }}" when: matrix_postgres_backup_enabled|bool diff --git a/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml b/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml index 73341033..deb80d8e 100644 --- a/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml +++ b/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml @@ -10,7 +10,7 @@ # If not, we install using the latest Postgres. # # Upgrading is supposed to be performed separately and explicitly (see `upgrade_postgres.yml`). -- set_fact: +- 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 @@ -27,7 +27,7 @@ until: result is not failed - name: Ensure Postgres backup paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0700 @@ -38,7 +38,7 @@ when: matrix_postgres_backup_enabled|bool - name: Ensure Postgres environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/{{ item }}.j2" dest: "{{ matrix_postgres_backup_path }}/{{ item }}" owner: "{{ matrix_user_username }}" @@ -49,7 +49,7 @@ when: matrix_postgres_backup_enabled|bool - name: Ensure matrix-postgres-backup.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-postgres-backup.service.j2" dest: "{{ matrix_systemd_path }}/matrix-postgres-backup.service" mode: 0644 @@ -57,7 +57,7 @@ when: matrix_postgres_backup_enabled|bool - name: Ensure systemd reloaded after matrix-postgres-backup.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_postgres_backup_enabled|bool and matrix_postgres_backup_systemd_service_result.changed" @@ -72,7 +72,7 @@ when: "not matrix_postgres_backup_enabled|bool" - name: Ensure matrix-postgres-backup is stopped - service: + ansible.builtin.service: name: matrix-postgres-backup state: stopped enabled: false @@ -80,13 +80,13 @@ when: "not matrix_postgres_backup_enabled|bool and matrix_postgres_backup_service_stat.stat.exists" - name: Ensure matrix-postgres-backup.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + ansible.builtin.service: daemon_reload: true when: "not matrix_postgres_backup_enabled|bool and matrix_postgres_backup_service_stat.stat.exists" @@ -98,7 +98,7 @@ # We just want to notify the user. Deleting data is too destructive. - name: Inject warning if matrix-postgres backup data remains - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-postgres-backup/tasks/util/detect_existing_postgres_version.yml b/roles/matrix-postgres-backup/tasks/util/detect_existing_postgres_version.yml index 10828cc7..33120453 100644 --- a/roles/matrix-postgres-backup/tasks/util/detect_existing_postgres_version.yml +++ b/roles/matrix-postgres-backup/tasks/util/detect_existing_postgres_version.yml @@ -4,7 +4,7 @@ # If there is, it also tries to detect the Docker image that corresponds to that version. - name: Initialize Postgres version determination variables (default to empty) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detection_pg_version_path: "{{ matrix_postgres_data_path }}/PG_VERSION" matrix_postgres_backup_detected_existing: false matrix_postgres_backup_detected_version: "" @@ -15,47 +15,47 @@ path: "{{ matrix_postgres_backup_detection_pg_version_path }}" register: result_pg_version_stat -- set_fact: +- ansible.builtin.set_fact: matrix_postgres_backup_detected_existing: true when: "result_pg_version_stat.stat.exists" - name: Determine existing Postgres version (read PG_VERSION file) - slurp: + ansible.builtin.slurp: src: "{{ matrix_postgres_backup_detection_pg_version_path }}" register: result_pg_version when: matrix_postgres_backup_detected_existing|bool - name: Determine existing Postgres version (make sense of PG_VERSION file) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version: "{{ result_pg_version['content']|b64decode|replace('\n', '') }}" when: matrix_postgres_backup_detected_existing|bool - name: Determine corresponding Docker image to detected version (assume default of latest) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_latest }}" when: "matrix_postgres_backup_detected_version != ''" - name: Determine corresponding Docker image to detected version (use 9.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v9 }}" when: "matrix_postgres_backup_detected_version.startswith('9.')" - name: Determine corresponding Docker image to detected version (use 10.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v10 }}" when: "matrix_postgres_backup_detected_version == '10' or matrix_postgres_backup_detected_version.startswith('10.')" - name: Determine corresponding Docker image to detected version (use 11.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v11 }}" when: "matrix_postgres_backup_detected_version == '11' or matrix_postgres_backup_detected_version.startswith('11.')" - name: Determine corresponding Docker image to detected version (use 12.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v12 }}" when: "matrix_postgres_backup_detected_version == '12' or matrix_postgres_backup_detected_version.startswith('12.')" - name: Determine corresponding Docker image to detected version (use 13.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v13 }}" when: "matrix_postgres_backup_detected_version == '13' or matrix_postgres_backup_detected_version.startswith('13.')" diff --git a/roles/matrix-postgres-backup/tasks/validate_config.yml b/roles/matrix-postgres-backup/tasks/validate_config.yml index fda9b919..8a2ddb5a 100644 --- a/roles/matrix-postgres-backup/tasks/validate_config.yml +++ b/roles/matrix-postgres-backup/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required Postgres settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" diff --git a/roles/matrix-postgres/tasks/import_generic_sqlite_db.yml b/roles/matrix-postgres/tasks/import_generic_sqlite_db.yml index 2a673ee3..81f37050 100644 --- a/roles/matrix-postgres/tasks/import_generic_sqlite_db.yml +++ b/roles/matrix-postgres/tasks/import_generic_sqlite_db.yml @@ -3,12 +3,12 @@ # Pre-checks - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot import." when: "not matrix_postgres_enabled|bool" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `sqlite_database_path` variable needs to be provided to this playbook, via --extra-vars" when: "sqlite_database_path is not defined or sqlite_database_path.startswith('<')" @@ -18,7 +18,7 @@ register: sqlite_database_path_stat_result - name: Fail if provided SQLite database file doesn't exist - fail: + ansible.builtin.fail: msg: "File cannot be found on the server at {{ sqlite_database_path }}" when: "not sqlite_database_path_stat_result.stat.exists" @@ -27,16 +27,16 @@ - block: - name: Fail if postgres_connection_string_variable_name points to an undefined variable - fail: msg="postgres_connection_string_variable_name is defined, but there is no variable with the name `{{ postgres_connection_string_variable_name }}`" + ansible.builtin.fail: msg="postgres_connection_string_variable_name is defined, but there is no variable with the name `{{ postgres_connection_string_variable_name }}`" when: "postgres_connection_string_variable_name not in vars" - name: Get Postgres connection string from variable - set_fact: + ansible.builtin.set_fact: postgres_db_connection_string: "{{ lookup('vars', postgres_connection_string_variable_name) }}" when: 'postgres_connection_string_variable_name is defined' - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: >- Either a `postgres_db_connection_string` variable or a `postgres_connection_string_variable_name` needs to be provided to this playbook, via `--extra-vars`. Example: `--extra-vars="postgres_db_connection_string=postgresql://username:password@localhost:/database_name"` or `--extra-vars="postgres_connection_string_variable_name=matrix_appservice_discord_database_connString"` @@ -46,7 +46,7 @@ # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" @@ -54,7 +54,7 @@ # Actual import work - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -68,7 +68,7 @@ when: "matrix_postgres_service_start_result.changed|bool" - name: Import SQLite database from {{ sqlite_database_path }} into Postgres - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -82,11 +82,11 @@ 'pgloader /in.db {{ postgres_db_connection_string }}' - name: Archive SQLite database ({{ sqlite_database_path }} -> {{ sqlite_database_path }}.backup) - command: + ansible.builtin.command: cmd: "mv {{ sqlite_database_path }} {{ sqlite_database_path }}.backup" - name: Inject result - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-postgres/tasks/import_postgres.yml b/roles/matrix-postgres/tasks/import_postgres.yml index 948c4b3a..899dc78c 100644 --- a/roles/matrix-postgres/tasks/import_postgres.yml +++ b/roles/matrix-postgres/tasks/import_postgres.yml @@ -3,12 +3,12 @@ # Pre-checks - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot import." when: "not matrix_postgres_enabled|bool" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `server_path_postgres_dump` variable needs to be provided to this playbook, via --extra-vars" when: "server_path_postgres_dump is not defined or server_path_postgres_dump.startswith('<')" @@ -18,7 +18,7 @@ register: result_server_path_postgres_dump_stat - name: Fail if provided Postgres dump file doesn't exists - fail: + ansible.builtin.fail: msg: "File cannot be found on the server at {{ server_path_postgres_dump }}" when: "not result_server_path_postgres_dump_stat.stat.exists" @@ -26,26 +26,26 @@ # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" - name: Set postgres_import_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_import_wait_time: "{{ 7 * 86400 }}" when: "postgres_import_wait_time|default('') == ''" # By default, we connect and import into the main (`matrix`) database. # Single-database dumps for Synapse may wish to import into `synapse` instead. - name: Set postgres_default_import_database, if not provided - set_fact: + ansible.builtin.set_fact: postgres_default_import_database: "{{ matrix_postgres_db_name }}" when: "postgres_default_import_database|default('') == ''" # Actual import work - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -59,7 +59,7 @@ - import_tasks: tasks/util/detect_existing_postgres_version.yml - name: Abort, if no existing Postgres version detected - fail: + ansible.builtin.fail: msg: "Could not find existing Postgres installation" when: "not matrix_postgres_detected_existing|bool" @@ -68,7 +68,7 @@ # The dump most likely contains those same entries and would try to re-create them, leading to errors. # We need to skip over those lines. - name: Generate Postgres database import command - set_fact: + ansible.builtin.set_fact: matrix_postgres_import_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-import --log-driver=none @@ -91,7 +91,7 @@ # We want to run `debug: msg=".."`, but that dumps it as JSON and escapes double quotes within it, # which ruins the command (`matrix_postgres_import_command`) - name: Note about Postgres importing alternative - set_fact: + ansible.builtin.set_fact: dummy: true with_items: - >- @@ -101,6 +101,6 @@ and manually run the above import command directly on the server. - name: Perform Postgres database import - command: "{{ matrix_postgres_import_command }}" + ansible.builtin.command: "{{ matrix_postgres_import_command }}" async: "{{ postgres_import_wait_time }}" poll: 10 diff --git a/roles/matrix-postgres/tasks/import_synapse_sqlite_db.yml b/roles/matrix-postgres/tasks/import_synapse_sqlite_db.yml index 2dafba59..d10831dd 100644 --- a/roles/matrix-postgres/tasks/import_synapse_sqlite_db.yml +++ b/roles/matrix-postgres/tasks/import_synapse_sqlite_db.yml @@ -3,12 +3,12 @@ # Pre-checks - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot import." when: "not matrix_postgres_enabled|bool" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `server_path_homeserver_db` variable needs to be provided to this playbook, via --extra-vars" when: "server_path_homeserver_db is not defined or server_path_homeserver_db.startswith('<')" @@ -18,7 +18,7 @@ register: result_server_path_homeserver_db_stat - name: Fail if provided SQLite homeserver.db file doesn't exist - fail: + ansible.builtin.fail: msg: "File cannot be found on the server at {{ server_path_homeserver_db }}" when: "not result_server_path_homeserver_db_stat.stat.exists" @@ -26,7 +26,7 @@ # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" @@ -34,18 +34,18 @@ # Actual import work - name: Ensure matrix-postgres is stopped - service: + ansible.builtin.service: name: matrix-postgres state: stopped daemon_reload: true - name: Ensure postgres data is wiped out - file: + ansible.builtin.file: path: "{{ matrix_postgres_data_path }}" state: absent - name: Ensure postgres data path exists - file: + ansible.builtin.file: path: "{{ matrix_postgres_data_path }}" state: directory mode: 0700 @@ -53,7 +53,7 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: restarted daemon_reload: true @@ -70,7 +70,7 @@ # Also, some old `docker_container` versions were buggy and would leave containers behind # on failure, which we had to work around to allow retries (by re-running the playbook). - name: Import SQLite database into Postgres - command: | + ansible.builtin.command: | docker run --rm --name=matrix-synapse-migrate diff --git a/roles/matrix-postgres/tasks/init.yml b/roles/matrix-postgres/tasks/init.yml index e5ebd9c5..0a46fa86 100644 --- a/roles/matrix-postgres/tasks/init.yml +++ b/roles/matrix-postgres/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-postgres.service'] }}" when: matrix_postgres_enabled|bool diff --git a/roles/matrix-postgres/tasks/migrate_postgres_data_directory.yml b/roles/matrix-postgres/tasks/migrate_postgres_data_directory.yml index f927783f..4713fcd6 100644 --- a/roles/matrix-postgres/tasks/migrate_postgres_data_directory.yml +++ b/roles/matrix-postgres/tasks/migrate_postgres_data_directory.yml @@ -16,7 +16,7 @@ register: result_pg_old_data_dir_stat - name: Warn if old Postgres data directory detected - debug: + ansible.builtin.debug: msg: > Found that you have Postgres data in `{{ matrix_postgres_base_path }}`. From now on, Postgres data is supposed to be stored in `{{ matrix_postgres_data_path }}` instead. @@ -26,7 +26,7 @@ # We should stop Postgres first, before building a list of files, # as to ignore any `postmaster.pid` files, etc. - name: Ensure matrix-postgres is stopped - service: + ansible.builtin.service: name: matrix-postgres state: stopped daemon_reload: true @@ -41,7 +41,7 @@ when: "result_pg_old_data_dir_stat.stat.exists" - name: Ensure new Postgres data path exists - file: + ansible.builtin.file: path: "{{ matrix_postgres_data_path }}" state: directory mode: 0700 @@ -51,7 +51,7 @@ - block: - name: Relocate Postgres data files from old directory to new - command: "mv {{ item.path }} {{ matrix_postgres_data_path }}/{{ item.path|basename }}" + ansible.builtin.command: "mv {{ item.path }} {{ matrix_postgres_data_path }}/{{ item.path|basename }}" with_items: "{{ result_pg_old_data_dir_find.files }}" when: "result_pg_old_data_dir_stat.stat.exists" @@ -61,12 +61,12 @@ # and have it initialize a new database. - name: Ensure outdated matrix-postgres.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-postgres.service" state: absent when: "result_pg_old_data_dir_stat.stat.exists" - name: Ensure systemd reloaded after getting rid of outdated matrix-postgres.service - service: + ansible.builtin.service: daemon_reload: true when: "result_pg_old_data_dir_stat.stat.exists" diff --git a/roles/matrix-postgres/tasks/run_vacuum.yml b/roles/matrix-postgres/tasks/run_vacuum.yml index 0b7a60f8..f3c59775 100644 --- a/roles/matrix-postgres/tasks/run_vacuum.yml +++ b/roles/matrix-postgres/tasks/run_vacuum.yml @@ -3,7 +3,7 @@ # Pre-checks - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot run vacuum." when: "not matrix_postgres_enabled|bool" @@ -11,12 +11,12 @@ # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" - name: Set postgres_vacuum_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_vacuum_wait_time: "{{ 7 * 86400 }}" when: "postgres_vacuum_wait_time|default('') == ''" @@ -24,7 +24,7 @@ # Actual vacuuming work - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -38,12 +38,12 @@ - import_tasks: tasks/util/detect_existing_postgres_version.yml - name: Abort, if no existing Postgres version detected - fail: + ansible.builtin.fail: msg: "Could not find existing Postgres installation" when: "not matrix_postgres_detected_existing|bool" - name: Generate Postgres database vacuum command - set_fact: + ansible.builtin.set_fact: matrix_postgres_vacuum_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-synapse-vacuum --user={{ matrix_user_uid }}:{{ matrix_user_gid }} @@ -54,9 +54,9 @@ psql -v ON_ERROR_STOP=1 -h matrix-postgres {{ matrix_synapse_database_database }} -c 'VACUUM FULL VERBOSE' - name: Note about Postgres vacuum alternative - debug: + ansible.builtin.debug: msg: >- - Running vacuum with the following Postgres command: `{{ matrix_postgres_vacuum_command }}`. + Running vacuum with the following Postgres ansible.builtin.command: `{{ matrix_postgres_vacuum_command }}`. If this crashes, you can stop all processes (`systemctl stop matrix-*`), start Postgres only (`systemctl start matrix-postgres`) and manually run the above command directly on the server. @@ -64,26 +64,26 @@ - name: Populate service facts service_facts: -- set_fact: +- ansible.builtin.set_fact: matrix_postgres_synapse_was_running: "{{ ansible_facts.services['matrix-synapse.service']|default(none) is not none and ansible_facts.services['matrix-synapse.service'].state == 'running' }}" - name: Ensure matrix-synapse is stopped - service: + ansible.builtin.service: name: matrix-synapse state: stopped daemon_reload: true - name: Run Postgres vacuum command - command: "{{ matrix_postgres_vacuum_command }}" + ansible.builtin.command: "{{ matrix_postgres_vacuum_command }}" async: "{{ postgres_vacuum_wait_time }}" poll: 10 register: matrix_postgres_synapse_vacuum_result # Intentionally show the results -- debug: var="matrix_postgres_synapse_vacuum_result" +- ansible.builtin.debug: var="matrix_postgres_synapse_vacuum_result" - name: Ensure matrix-synapse is started, if it previously was - service: + ansible.builtin.service: name: matrix-synapse state: started daemon_reload: true diff --git a/roles/matrix-postgres/tasks/setup_postgres.yml b/roles/matrix-postgres/tasks/setup_postgres.yml index 04763a32..3cdde807 100644 --- a/roles/matrix-postgres/tasks/setup_postgres.yml +++ b/roles/matrix-postgres/tasks/setup_postgres.yml @@ -14,17 +14,17 @@ # If not, we install using the latest Postgres. # # Upgrading is supposed to be performed separately and explicitly (see `upgrade_postgres.yml`). -- set_fact: +- ansible.builtin.set_fact: matrix_postgres_docker_image_to_use: "{{ matrix_postgres_docker_image_latest if matrix_postgres_detected_version_corresponding_docker_image == '' else matrix_postgres_detected_version_corresponding_docker_image }}" when: matrix_postgres_enabled|bool - name: Abort if on an unsupported Postgres version - fail: + ansible.builtin.fail: msg: "You're on Postgres {{ matrix_postgres_detected_version }}, which is no longer supported. To upgrade, see docs/maintenance-postgres.md" when: "matrix_postgres_enabled|bool and matrix_postgres_detected_version.startswith('9.')" - name: Inject warning if on an old version of Postgres - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) @@ -49,7 +49,7 @@ until: result is not failed - name: Ensure Postgres paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0700 @@ -64,7 +64,7 @@ # - 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 Postgres data path ownership is correct - file: + ansible.builtin.file: path: "{{ matrix_postgres_data_path }}" state: directory owner: "{{ matrix_user_username }}" @@ -73,7 +73,7 @@ when: matrix_postgres_enabled|bool - name: Ensure Postgres environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/{{ item }}.j2" dest: "{{ matrix_postgres_base_path }}/{{ item }}" owner: "{{ matrix_user_username }}" @@ -85,41 +85,41 @@ when: matrix_postgres_enabled|bool - name: Ensure matrix-postgres-cli script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-cli.j2" dest: "{{ matrix_local_bin_path }}/matrix-postgres-cli" mode: 0755 when: matrix_postgres_enabled|bool - name: Ensure matrix-postgres-cli-non-interactive script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-cli-non-interactive.j2" dest: "{{ matrix_local_bin_path }}/matrix-postgres-cli-non-interactive" mode: 0755 when: matrix_postgres_enabled|bool - name: Ensure matrix-change-user-admin-status script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/usr-local-bin/matrix-change-user-admin-status.j2" dest: "{{ matrix_local_bin_path }}/matrix-change-user-admin-status" mode: 0755 when: matrix_postgres_enabled|bool - name: (Migration) Ensure old matrix-make-user-admin script deleted - file: + ansible.builtin.file: path: "{{ matrix_local_bin_path }}/matrix-make-user-admin" state: absent when: matrix_postgres_enabled|bool - name: Ensure matrix-postgres-update-user-password-hash script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-update-user-password-hash.j2" dest: "{{ matrix_local_bin_path }}/matrix-postgres-update-user-password-hash" mode: 0755 when: matrix_postgres_enabled|bool - name: Ensure matrix-postgres.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-postgres.service.j2" dest: "{{ matrix_systemd_path }}/matrix-postgres.service" mode: 0644 @@ -127,12 +127,12 @@ when: matrix_postgres_enabled|bool - name: Ensure systemd reloaded after matrix-postgres.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_postgres_enabled|bool and matrix_postgres_systemd_service_result.changed" - include_tasks: - file: "{{ role_path }}/tasks/util/create_additional_databases.yml" + ansible.builtin.file: "{{ role_path }}/tasks/util/create_additional_databases.yml" apply: tags: - always @@ -145,7 +145,7 @@ when: "matrix_postgres_enabled|bool" - name: Inject warning if backup data remains - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) @@ -168,20 +168,20 @@ when: "not matrix_postgres_enabled|bool" - name: Ensure matrix-postgres is stopped - service: + ansible.builtin.service: name: matrix-postgres state: stopped daemon_reload: true when: "not matrix_postgres_enabled|bool and matrix_postgres_service_stat.stat.exists" - name: Ensure matrix-postgres.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-postgres.service" state: absent when: "not matrix_postgres_enabled|bool and matrix_postgres_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-postgres.service removal - service: + ansible.builtin.service: daemon_reload: true when: "not matrix_postgres_enabled|bool and matrix_postgres_service_stat.stat.exists" @@ -193,7 +193,7 @@ # We just want to notify the user. Deleting data is too destructive. - name: Inject warning if matrix-postgres local data remains - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) @@ -205,7 +205,7 @@ when: "not matrix_postgres_enabled|bool and matrix_postgres_data_path_stat.stat.exists" - name: Remove Postgres scripts - file: + ansible.builtin.file: path: "{{ matrix_local_bin_path }}/{{ item }}" state: absent with_items: diff --git a/roles/matrix-postgres/tasks/upgrade_postgres.yml b/roles/matrix-postgres/tasks/upgrade_postgres.yml index bf98d938..012f292d 100644 --- a/roles/matrix-postgres/tasks/upgrade_postgres.yml +++ b/roles/matrix-postgres/tasks/upgrade_postgres.yml @@ -1,32 +1,32 @@ --- - name: Set default postgres_dump_dir, if not provided - set_fact: + ansible.builtin.set_fact: postgres_dump_dir: "/tmp" when: "postgres_dump_dir|default('') == ''" - name: Set postgres_dump_name, if not provided - set_fact: + ansible.builtin.set_fact: postgres_dump_name: "matrix-postgres-dump.sql.gz" when: "postgres_dump_name|default('') == ''" - name: Set postgres_auto_upgrade_backup_data_path, if not provided - set_fact: + ansible.builtin.set_fact: postgres_auto_upgrade_backup_data_path: "{{ matrix_postgres_data_path }}-auto-upgrade-backup" when: "postgres_auto_upgrade_backup_data_path|default('') == ''" - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" - name: Set postgres_force_upgrade, if not provided - set_fact: + ansible.builtin.set_fact: postgres_force_upgrade: false when: "postgres_force_upgrade|default('') == ''" - name: Fail, if trying to upgrade external Postgres database - fail: + ansible.builtin.fail: msg: "Your configuration indicates that you're not using Postgres from this role. There is nothing to upgrade." when: "not matrix_postgres_enabled|bool" @@ -36,32 +36,32 @@ register: result_auto_upgrade_path - name: Abort, if existing Postgres auto-upgrade data path detected - fail: + ansible.builtin.fail: msg: "Detected that a left-over {{ postgres_auto_upgrade_backup_data_path }} exists. You should rename it to {{ matrix_postgres_data_path }} if the previous upgrade went wrong, or delete it if it went well." when: "result_auto_upgrade_path.stat.exists" - import_tasks: tasks/util/detect_existing_postgres_version.yml - name: Abort, if no existing Postgres version detected - fail: + ansible.builtin.fail: msg: "Could not find existing Postgres installation" when: "not matrix_postgres_detected_existing|bool" - name: Abort, if already at latest Postgres version - fail: + ansible.builtin.fail: msg: "You are already running the latest Postgres version supported ({{ matrix_postgres_docker_image_latest }}). Nothing to do" when: "matrix_postgres_detected_version_corresponding_docker_image == matrix_postgres_docker_image_latest and not postgres_force_upgrade" -- debug: +- ansible.builtin.debug: msg: "Upgrading database from {{ matrix_postgres_detected_version_corresponding_docker_image }} to {{ matrix_postgres_docker_image_latest }}" - name: Ensure matrix-synapse is stopped - service: + ansible.builtin.service: name: matrix-synapse state: stopped - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -78,7 +78,7 @@ # role (`matrix_postgres_connection_username`) and database (`matrix_postgres_db_name`) by itself on startup, # we need to remove these from the dump, or we'll get errors saying these already exist. - name: Perform Postgres database dump - command: >- + ansible.builtin.command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-dump --log-driver=none --user={{ matrix_user_uid }}:{{ matrix_user_gid }} @@ -92,20 +92,20 @@ > /out/{{ postgres_dump_name }}" - name: Ensure matrix-postgres is stopped - service: + ansible.builtin.service: name: matrix-postgres state: stopped - name: Rename existing Postgres data directory - command: "mv {{ matrix_postgres_data_path }} {{ postgres_auto_upgrade_backup_data_path }}" + ansible.builtin.command: "mv {{ matrix_postgres_data_path }} {{ postgres_auto_upgrade_backup_data_path }}" -- debug: +- ansible.builtin.debug: msg: "NOTE: Your Postgres data directory has been moved from `{{ matrix_postgres_data_path }}` to `{{ postgres_auto_upgrade_backup_data_path }}`. In the event of failure, you can move it back and run the playbook with --tags=setup-postgres to restore operation." - import_tasks: tasks/setup_postgres.yml - name: Ensure matrix-postgres autoruns and is restarted - service: + ansible.builtin.service: name: matrix-postgres enabled: true state: restarted @@ -122,7 +122,7 @@ # The dump most likely contains those same entries and would try to re-create them, leading to errors. # We need to skip over those lines. - name: Generate Postgres database import command - set_fact: + ansible.builtin.set_fact: matrix_postgres_import_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-import --log-driver=none @@ -145,7 +145,7 @@ # We want to run `debug: msg=".."`, but that dumps it as JSON and escapes double quotes within it, # which ruins the command (`matrix_postgres_import_command`) - name: Note about Postgres importing - set_fact: + ansible.builtin.set_fact: dummy: true with_items: - >- @@ -155,18 +155,18 @@ and restore the automatically-made backup (`mv {{ postgres_auto_upgrade_backup_data_path }} {{ matrix_postgres_data_path }}`). - name: Perform Postgres database import - command: "{{ matrix_postgres_import_command }}" + ansible.builtin.command: "{{ matrix_postgres_import_command }}" - name: Delete Postgres database dump file - file: + ansible.builtin.file: path: "{{ postgres_dump_dir }}/{{ postgres_dump_name }}" state: absent - name: Ensure matrix-synapse is started - service: + ansible.builtin.service: name: matrix-synapse state: started daemon_reload: true -- debug: +- ansible.builtin.debug: msg: "NOTE: Your old Postgres data directory is preserved at `{{ postgres_auto_upgrade_backup_data_path }}`. You might want to get rid of it once you've confirmed that all is well." diff --git a/roles/matrix-postgres/tasks/util/create_additional_database.yml b/roles/matrix-postgres/tasks/util/create_additional_database.yml index 22b3c9a2..b4fee2c8 100644 --- a/roles/matrix-postgres/tasks/util/create_additional_database.yml +++ b/roles/matrix-postgres/tasks/util/create_additional_database.yml @@ -3,7 +3,7 @@ # It'd be better if this is belonged to `validate_config.yml`, but it would have to be some loop-within-a-loop there, # and that's ugly. We also don't expect this to catch errors often. It's more of a defensive last-minute check. - name: Fail if additional database data appears invalid - fail: + ansible.builtin.fail: msg: "Additional database definition ({{ additional_db }} lacks a required key: {{ item }}" when: "item not in additional_db" with_items: "{{ ['name', 'username', 'password'] }}" @@ -12,7 +12,7 @@ # This file will be mounted into the container and fed to Postgres. # This way, we avoid passing sensitive data around in CLI commands that other users on the system can see. - name: Create additional database initialization SQL file for {{ additional_db.name }} - template: + ansible.builtin.template: src: "{{ role_path }}/templates/sql/init-additional-db-user-and-role.sql.j2" dest: "/tmp/matrix-postgres-init-additional-db-user-and-role.sql" mode: 0600 @@ -20,7 +20,7 @@ group: "{{ matrix_user_gid }}" - name: Execute Postgres additional database initialization SQL file for {{ additional_db.name }} - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -35,6 +35,6 @@ 'psql -h {{ matrix_postgres_connection_hostname }} --file=/matrix-postgres-init-additional-db-user-and-role.sql' - name: Delete additional database initialization SQL file for {{ additional_db.name }} - file: + ansible.builtin.file: path: /tmp/matrix-postgres-init-additional-db-user-and-role.sql state: absent diff --git a/roles/matrix-postgres/tasks/util/create_additional_databases.yml b/roles/matrix-postgres/tasks/util/create_additional_databases.yml index de87f98c..c1b5cd51 100644 --- a/roles/matrix-postgres/tasks/util/create_additional_databases.yml +++ b/roles/matrix-postgres/tasks/util/create_additional_databases.yml @@ -1,7 +1,7 @@ --- - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true diff --git a/roles/matrix-postgres/tasks/util/detect_existing_postgres_version.yml b/roles/matrix-postgres/tasks/util/detect_existing_postgres_version.yml index a7e94a0c..932ca336 100644 --- a/roles/matrix-postgres/tasks/util/detect_existing_postgres_version.yml +++ b/roles/matrix-postgres/tasks/util/detect_existing_postgres_version.yml @@ -4,7 +4,7 @@ # If there is, it also tries to detect the Docker image that corresponds to that version. - name: Initialize Postgres version determination variables (default to empty) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detection_pg_version_path: "{{ matrix_postgres_data_path }}/PG_VERSION" matrix_postgres_detected_existing: false matrix_postgres_detected_version: "" @@ -15,47 +15,47 @@ path: "{{ matrix_postgres_detection_pg_version_path }}" register: result_pg_version_stat -- set_fact: +- ansible.builtin.set_fact: matrix_postgres_detected_existing: true when: "result_pg_version_stat.stat.exists" - name: Determine existing Postgres version (read PG_VERSION file) - slurp: + ansible.builtin.slurp: src: "{{ matrix_postgres_detection_pg_version_path }}" register: result_pg_version when: matrix_postgres_detected_existing|bool - name: Determine existing Postgres version (make sense of PG_VERSION file) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version: "{{ result_pg_version['content']|b64decode|replace('\n', '') }}" when: matrix_postgres_detected_existing|bool - name: Determine corresponding Docker image to detected version (assume default of latest) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version_corresponding_docker_image: "{{ matrix_postgres_docker_image_latest }}" when: "matrix_postgres_detected_version != ''" - name: Determine corresponding Docker image to detected version (use 9.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version_corresponding_docker_image: "{{ matrix_postgres_docker_image_v9 }}" when: "matrix_postgres_detected_version.startswith('9.')" - name: Determine corresponding Docker image to detected version (use 10.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version_corresponding_docker_image: "{{ matrix_postgres_docker_image_v10 }}" when: "matrix_postgres_detected_version == '10' or matrix_postgres_detected_version.startswith('10.')" - name: Determine corresponding Docker image to detected version (use 11.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version_corresponding_docker_image: "{{ matrix_postgres_docker_image_v11 }}" when: "matrix_postgres_detected_version == '11' or matrix_postgres_detected_version.startswith('11.')" - name: Determine corresponding Docker image to detected version (use 12.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version_corresponding_docker_image: "{{ matrix_postgres_docker_image_v12 }}" when: "matrix_postgres_detected_version == '12' or matrix_postgres_detected_version.startswith('12.')" - name: Determine corresponding Docker image to detected version (use 13.x, if detected) - set_fact: + ansible.builtin.set_fact: matrix_postgres_detected_version_corresponding_docker_image: "{{ matrix_postgres_docker_image_v13 }}" when: "matrix_postgres_detected_version == '13' or matrix_postgres_detected_version.startswith('13.')" diff --git a/roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml b/roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml index 90f73dba..7b1fb6aa 100644 --- a/roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml +++ b/roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml @@ -1,17 +1,17 @@ --- - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot migrate." when: "not matrix_postgres_enabled|bool" - name: Fail if util called incorrectly (missing matrix_postgres_db_migration_request) - fail: + ansible.builtin.fail: msg: "The `matrix_postgres_db_migration_request` variable needs to be provided to this util." when: "matrix_postgres_db_migration_request is not defined" - name: Fail if util called incorrectly (invalid matrix_postgres_db_migration_request) - fail: + ansible.builtin.fail: msg: "The `matrix_postgres_db_migration_request` variable needs to contain `{{ item }}`." with_items: - src @@ -27,13 +27,13 @@ register: matrix_postgres_db_migration_request_src_stat_result - name: Fail if provided source database file doesn't exist - fail: + ansible.builtin.fail: msg: "File cannot be found on the server at {{ matrix_postgres_db_migration_request.src }}" when: "not matrix_postgres_db_migration_request_src_stat_result.stat.exists" - block: - name: Ensure pgloader repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_postgres_pgloader_container_image_self_build_repo }}" dest: "{{ matrix_postgres_pgloader_container_image_self_build_src_path }}" version: "{{ matrix_postgres_pgloader_container_image_self_build_repo_branch }}" @@ -49,7 +49,7 @@ # # Although we're not using the dimitri/pgloader image, the one we're using suffers from the same problem. - name: Switch pgloader base image from Debian stable (likely 10.x/Buster) to Bullseye - lineinfile: + ansible.builtin.lineinfile: path: "{{ matrix_postgres_pgloader_container_image_self_build_src_path }}/Dockerfile" regexp: "{{ item.match }}" line: "{{ item.replace }}" @@ -82,7 +82,7 @@ # Defaults - name: Set postgres_start_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: postgres_start_wait_time: 15 when: "postgres_start_wait_time|default('') == ''" @@ -90,7 +90,7 @@ # matrix-postgres is most likely started already - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -112,14 +112,14 @@ # However, we don't do it, because it's simpler having it here, and it also gets to happen only if we'll be doing an import. # If we bailed out (somewhere above), nothing would have gotten stopped. It's nice to leave this running in such cases. - name: Ensure systemd services blocking the database import are stopped - service: + ansible.builtin.service: name: "{{ item }}" state: stopped failed_when: false with_items: "{{ matrix_postgres_db_migration_request.systemd_services_to_stop }}" - name: Import {{ matrix_postgres_db_migration_request.engine_old }} database from {{ matrix_postgres_db_migration_request.src }} into Postgres - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -137,11 +137,11 @@ # because it refers to the role that included this util, and not to the role this file belongs to. - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/detect_existing_postgres_version.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_docker_image_to_use: "{{ matrix_postgres_docker_image_latest if matrix_postgres_detected_version_corresponding_docker_image == '' else matrix_postgres_detected_version_corresponding_docker_image }}" - name: Execute additional Postgres SQL migration statements - command: + ansible.builtin.command: cmd: >- {{ matrix_host_command_docker }} run --rm @@ -156,11 +156,11 @@ when: "matrix_postgres_db_migration_request.additional_psql_statements_list|default([])|length > 0" - name: Archive {{ matrix_postgres_db_migration_request.engine_old }} database ({{ matrix_postgres_db_migration_request.src }} -> {{ matrix_postgres_db_migration_request.src }}.backup) - command: + ansible.builtin.command: cmd: "mv {{ matrix_postgres_db_migration_request.src }} {{ matrix_postgres_db_migration_request.src }}.backup" - name: Inject result - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-postgres/tasks/validate_config.yml b/roles/matrix-postgres/tasks/validate_config.yml index eac4dd5b..f239b116 100644 --- a/roles/matrix-postgres/tasks/validate_config.yml +++ b/roles/matrix-postgres/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: (Deprecation) Warn about matrix_postgres_use_external usage - fail: + ansible.builtin.fail: msg: > The `matrix_postgres_use_external` variable defined in your configuration is not used by this playbook anymore! You'll need to adapt to the new way of using an external Postgres server. @@ -13,7 +13,7 @@ # This is separate (from the other required variables below), # because we'd like to have a friendlier message for our existing users. - name: Fail if matrix_postgres_connection_password not defined - fail: + ansible.builtin.fail: msg: >- The playbook no longer has a default Postgres password defined in the `matrix_postgres_connection_password` variable, among lots of other Postgres changes. You need to perform multiple manual steps to resolve this. @@ -22,7 +22,7 @@ when: "matrix_postgres_connection_password == ''" - name: Fail if required Postgres settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" @@ -34,6 +34,6 @@ - "matrix_postgres_db_name" - name: Fail if Postgres password length exceeded - fail: + ansible.builtin.fail: msg: "The maximum `matrix_postgres_connection_password` length is 99 characters" when: "matrix_postgres_connection_password|length > 99" diff --git a/roles/matrix-prometheus-node-exporter/tasks/init.yml b/roles/matrix-prometheus-node-exporter/tasks/init.yml index d08340a8..4e53b0c3 100644 --- a/roles/matrix-prometheus-node-exporter/tasks/init.yml +++ b/roles/matrix-prometheus-node-exporter/tasks/init.yml @@ -1,12 +1,12 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-prometheus-node-exporter.service'] }}" when: matrix_prometheus_node_exporter_enabled|bool - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append node-exporter's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -15,7 +15,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate node-exporter metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/node-exporter) - set_fact: + ansible.builtin.set_fact: matrix_prometheus_node_exporter_nginx_metrics_configuration_block: | location /metrics/node-exporter { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -31,7 +31,7 @@ } - name: Register node-exporter metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/node-exporter) - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([]) diff --git a/roles/matrix-prometheus-node-exporter/tasks/setup.yml b/roles/matrix-prometheus-node-exporter/tasks/setup.yml index 21d0b55d..ee2c1835 100644 --- a/roles/matrix-prometheus-node-exporter/tasks/setup.yml +++ b/roles/matrix-prometheus-node-exporter/tasks/setup.yml @@ -17,7 +17,7 @@ until: result is not failed - name: Ensure matrix-prometheus-node-exporter.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-prometheus-node-exporter.service.j2" dest: "{{ matrix_systemd_path }}/matrix-prometheus-node-exporter.service" mode: 0644 @@ -25,7 +25,7 @@ when: matrix_prometheus_node_exporter_enabled|bool - name: Ensure systemd reloaded after matrix-prometheus.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_prometheus_node_exporter_enabled|bool and matrix_prometheus_node_exporter_systemd_service_result.changed" @@ -39,7 +39,7 @@ register: matrix_prometheus_node_exporter_service_stat - name: Ensure matrix-prometheus-node-exporter is stopped - service: + ansible.builtin.service: name: matrix-prometheus-node-exporter state: stopped enabled: false @@ -48,12 +48,12 @@ 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 - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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/matrix-prometheus-postgres-exporter/tasks/init.yml b/roles/matrix-prometheus-postgres-exporter/tasks/init.yml index 996cc975..3c7b5b01 100644 --- a/roles/matrix-prometheus-postgres-exporter/tasks/init.yml +++ b/roles/matrix-prometheus-postgres-exporter/tasks/init.yml @@ -1,12 +1,12 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-prometheus-postgres-exporter.service'] }}" when: matrix_prometheus_postgres_exporter_enabled|bool - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append postgres-exporter's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -15,7 +15,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate postgres-exporter metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/postgres-exporter) - set_fact: + ansible.builtin.set_fact: matrix_prometheus_postgres_exporter_nginx_metrics_configuration_block: | location /metrics/postgres-exporter { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -31,7 +31,7 @@ } - name: Register postgres-exporter metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/postgres-exporter) - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([]) diff --git a/roles/matrix-prometheus-postgres-exporter/tasks/setup.yml b/roles/matrix-prometheus-postgres-exporter/tasks/setup.yml index 08ffe708..2c263eb2 100644 --- a/roles/matrix-prometheus-postgres-exporter/tasks/setup.yml +++ b/roles/matrix-prometheus-postgres-exporter/tasks/setup.yml @@ -17,7 +17,7 @@ until: result is not failed - name: Ensure matrix-prometheus-postgres-exporter.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-prometheus-postgres-exporter.service.j2" dest: "{{ matrix_systemd_path }}/matrix-prometheus-postgres-exporter.service" mode: 0644 @@ -25,7 +25,7 @@ when: matrix_prometheus_postgres_exporter_enabled|bool - name: Ensure systemd reloaded after matrix-prometheus.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_prometheus_postgres_exporter_enabled|bool and matrix_prometheus_postgres_exporter_systemd_service_result.changed" @@ -39,7 +39,7 @@ register: matrix_prometheus_postgres_exporter_service_stat - name: Ensure matrix-prometheus-postgres-exporter is stopped - service: + ansible.builtin.service: name: matrix-prometheus-postgres-exporter state: stopped enabled: false @@ -48,12 +48,12 @@ 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 - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + 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/matrix-prometheus/tasks/init.yml b/roles/matrix-prometheus/tasks/init.yml index 6587ddd9..946410e3 100644 --- a/roles/matrix-prometheus/tasks/init.yml +++ b/roles/matrix-prometheus/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-prometheus.service'] }}" when: matrix_prometheus_enabled|bool diff --git a/roles/matrix-prometheus/tasks/setup_install.yml b/roles/matrix-prometheus/tasks/setup_install.yml index 06989e7e..ad2b94aa 100644 --- a/roles/matrix-prometheus/tasks/setup_install.yml +++ b/roles/matrix-prometheus/tasks/setup_install.yml @@ -12,7 +12,7 @@ until: result is not failed - name: Ensure Prometheus paths exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -24,7 +24,7 @@ - "{{ matrix_prometheus_data_path }}" - name: Download synapse-v2.rules - get_url: + ansible.builtin.get_url: url: "{{ matrix_prometheus_scraper_synapse_rules_download_url }}" dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules" force: true @@ -38,7 +38,7 @@ until: result is not failed - name: Ensure prometheus.yml installed - copy: + ansible.builtin.copy: content: "{{ matrix_prometheus_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_prometheus_config_path }}/prometheus.yml" mode: 0644 @@ -46,13 +46,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-prometheus.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-prometheus.service.j2" dest: "{{ matrix_systemd_path }}/matrix-prometheus.service" mode: 0644 register: matrix_prometheus_systemd_service_result - name: Ensure systemd reloaded after matrix-prometheus.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_prometheus_systemd_service_result.changed|bool" diff --git a/roles/matrix-prometheus/tasks/setup_uninstall.yml b/roles/matrix-prometheus/tasks/setup_uninstall.yml index c9f07f52..f1a62481 100644 --- a/roles/matrix-prometheus/tasks/setup_uninstall.yml +++ b/roles/matrix-prometheus/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_prometheus_service_stat - name: Ensure matrix-prometheus is stopped - service: + ansible.builtin.service: name: matrix-prometheus state: stopped enabled: false @@ -15,12 +15,12 @@ when: "matrix_prometheus_service_stat.stat.exists|bool" - name: Ensure matrix-prometheus.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-prometheus.service" state: absent when: "matrix_prometheus_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-prometheus.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_prometheus_service_stat.stat.exists|bool" diff --git a/roles/matrix-prometheus/tasks/validate_config.yml b/roles/matrix-prometheus/tasks/validate_config.yml index 9fcfe12b..3e386304 100644 --- a/roles/matrix-prometheus/tasks/validate_config.yml +++ b/roles/matrix-prometheus/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if Synapse metrics or Prometheus Node Exporter not enabled - fail: + ansible.builtin.fail: msg: > You need to enable `matrix_prometheus_scraper_synapse_enabled` and/or `matrix_prometheus_scraper_node_enabled` for Prometheus grab metrics. when: "not matrix_prometheus_scraper_synapse_enabled and not matrix_prometheus_scraper_node_enabled" diff --git a/roles/matrix-redis/tasks/init.yml b/roles/matrix-redis/tasks/init.yml index 99c52026..08d7ec5a 100644 --- a/roles/matrix-redis/tasks/init.yml +++ b/roles/matrix-redis/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-redis'] }}" when: matrix_redis_enabled|bool diff --git a/roles/matrix-redis/tasks/setup_redis.yml b/roles/matrix-redis/tasks/setup_redis.yml index df1d1736..7ff55552 100644 --- a/roles/matrix-redis/tasks/setup_redis.yml +++ b/roles/matrix-redis/tasks/setup_redis.yml @@ -17,7 +17,7 @@ until: result is not failed - name: Ensure redis paths exist - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0700 @@ -32,7 +32,7 @@ # - 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 - file: + ansible.builtin.file: path: "{{ matrix_redis_data_path }}" state: directory owner: "{{ matrix_user_username }}" @@ -41,7 +41,7 @@ when: matrix_redis_enabled|bool - name: Ensure redis environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/{{ item }}.j2" dest: "{{ matrix_redis_base_path }}/{{ item }}" mode: 0644 @@ -50,7 +50,7 @@ when: matrix_redis_enabled|bool - name: Ensure matrix-redis.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-redis.service.j2" dest: "{{ matrix_systemd_path }}/matrix-redis.service" mode: 0644 @@ -58,7 +58,7 @@ when: matrix_redis_enabled|bool - name: Ensure systemd reloaded after matrix-redis.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_redis_enabled|bool and matrix_redis_systemd_service_result.changed" @@ -73,7 +73,7 @@ when: "not matrix_redis_enabled|bool" - name: Ensure matrix-redis is stopped - service: + ansible.builtin.service: name: matrix-redis state: stopped enabled: false @@ -81,13 +81,13 @@ when: "not matrix_redis_enabled|bool and matrix_redis_service_stat.stat.exists" - name: Ensure matrix-redis.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + ansible.builtin.service: daemon_reload: true when: "not matrix_redis_enabled|bool and matrix_redis_service_stat.stat.exists" @@ -99,6 +99,6 @@ # We just want to notify the user. Deleting data is too destructive. - name: Notify if matrix-redis local data remains - debug: + 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/matrix-registration/tasks/generate_token.yml b/roles/matrix-registration/tasks/generate_token.yml index 4e337b01..4b01957c 100644 --- a/roles/matrix-registration/tasks/generate_token.yml +++ b/roles/matrix-registration/tasks/generate_token.yml @@ -1,17 +1,17 @@ --- - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `one_time` variable needs to be provided to this playbook, via --extra-vars" when: "one_time is not defined or one_time not in ['yes', 'no']" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `ex_date` variable (expiration date) needs to be provided to this playbook, via --extra-vars" when: "ex_date is not defined or ex_date == ''" - name: Call matrix-registration token creation API - uri: + ansible.builtin.uri: url: "{{ matrix_registration_api_token_endpoint }}" follow_redirects: none validate_certs: "{{ matrix_registration_api_validate_certs }}" @@ -28,7 +28,7 @@ check_mode: false register: matrix_registration_api_result -- set_fact: +- ansible.builtin.set_fact: matrix_registration_api_result_message: >- matrix-registration result: @@ -42,7 +42,7 @@ check_mode: false - name: Inject result message into matrix_playbook_runtime_results - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-registration/tasks/init.yml b/roles/matrix-registration/tasks/init.yml index 44a887d1..5267f2b2 100644 --- a/roles/matrix-registration/tasks/init.yml +++ b/roles/matrix-registration/tasks/init.yml @@ -2,17 +2,17 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_registration_container_image_self_build and matrix_registration_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-registration.service'] }}" when: matrix_registration_enabled|bool - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append matrix-registration's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -21,7 +21,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate matrix-registration proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_registration_matrix_nginx_proxy_configuration: | rewrite ^{{ matrix_registration_public_endpoint }}$ {{ matrix_nginx_proxy_x_forwarded_proto_value }}://$server_name{{ matrix_registration_public_endpoint }}/ permanent; rewrite ^{{ matrix_registration_public_endpoint }}/$ {{ matrix_nginx_proxy_x_forwarded_proto_value }}://$server_name{{ matrix_registration_public_endpoint }}/register redirect; @@ -47,7 +47,7 @@ } - name: Register matrix-registration proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -59,7 +59,7 @@ when: matrix_registration_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the matrix-registration tool but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-registration/tasks/list_tokens.yml b/roles/matrix-registration/tasks/list_tokens.yml index 9ef40d27..d83d2976 100644 --- a/roles/matrix-registration/tasks/list_tokens.yml +++ b/roles/matrix-registration/tasks/list_tokens.yml @@ -1,7 +1,7 @@ --- - name: Call matrix-registration list all tokens API - uri: + ansible.builtin.uri: url: "{{ matrix_registration_api_token_endpoint }}" follow_redirects: none validate_certs: "{{ matrix_registration_api_validate_certs }}" @@ -13,7 +13,7 @@ check_mode: false register: matrix_registration_api_result -- set_fact: +- ansible.builtin.set_fact: matrix_registration_api_result_message: >- matrix-registration result: @@ -21,7 +21,7 @@ check_mode: false - name: Inject result message into matrix_playbook_runtime_results - set_fact: + ansible.builtin.set_fact: matrix_playbook_runtime_results: | {{ matrix_playbook_runtime_results|default([]) diff --git a/roles/matrix-registration/tasks/setup_install.yml b/roles/matrix-registration/tasks/setup_install.yml index 36cd0fd4..3a8e71e7 100644 --- a/roles/matrix-registration/tasks/setup_install.yml +++ b/roles/matrix-registration/tasks/setup_install.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_registration_requires_restart: false - block: @@ -10,7 +10,7 @@ register: matrix_registration_sqlite_database_path_local_stat_result - block: - - set_fact: + - ansible.builtin.set_fact: matrix_postgres_db_migration_request: src: "{{ matrix_registration_sqlite_database_path_local }}" dst: "{{ matrix_registration_database_connection_string }}" @@ -26,13 +26,13 @@ - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml" - - set_fact: + - ansible.builtin.set_fact: matrix_registration_requires_restart: true when: "matrix_registration_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_registration_database_engine == 'postgres'" - name: Ensure matrix-registration paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 @@ -58,7 +58,7 @@ until: result is not failed - name: Ensure matrix-registration repository is present when self-building - git: + ansible.builtin.git: repo: "{{ matrix_registration_container_image_self_build_repo }}" dest: "{{ matrix_registration_docker_src_files_path }}" version: "{{ matrix_registration_container_image_self_build_branch }}" @@ -70,7 +70,7 @@ # See: https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1864 - name: Patch setup.py to allow self-built version to work - lineinfile: + ansible.builtin.lineinfile: path: "{{ matrix_registration_docker_src_files_path }}/setup.py" regexp: 'flask-limiter' line: '"flask-limiter~=1.1.0", "Markupsafe<2.1",' @@ -89,7 +89,7 @@ when: "matrix_registration_container_image_self_build|bool" - name: Ensure matrix-registration config installed - copy: + ansible.builtin.copy: content: "{{ matrix_registration_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_registration_config_path }}/config.yaml" mode: 0644 @@ -97,19 +97,19 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-registration.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-registration.service.j2" dest: "{{ matrix_systemd_path }}/matrix-registration.service" mode: 0644 register: matrix_registration_systemd_service_result - name: Ensure systemd reloaded after matrix-registration.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_registration_systemd_service_result.changed|bool" - name: Ensure matrix-registration.service restarted, if necessary - service: + ansible.builtin.service: name: "matrix-registration.service" state: restarted when: "matrix_registration_requires_restart|bool" diff --git a/roles/matrix-registration/tasks/setup_uninstall.yml b/roles/matrix-registration/tasks/setup_uninstall.yml index 4b7c195f..54f5483b 100644 --- a/roles/matrix-registration/tasks/setup_uninstall.yml +++ b/roles/matrix-registration/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_registration_service_stat - name: Ensure matrix-registration is stopped - service: + ansible.builtin.service: name: matrix-registration state: stopped enabled: false @@ -15,13 +15,13 @@ when: "matrix_registration_service_stat.stat.exists|bool" - name: Ensure matrix-registration.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-registration.service" state: absent when: "matrix_registration_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-registration.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_registration_service_stat.stat.exists|bool" diff --git a/roles/matrix-registration/tasks/validate_config.yml b/roles/matrix-registration/tasks/validate_config.yml index 90466b46..eb140d31 100644 --- a/roles/matrix-registration/tasks/validate_config.yml +++ b/roles/matrix-registration/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required matrix-registration settings not defined - fail: + ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) for using matrix-registration. when: "vars[item] == ''" @@ -11,7 +11,7 @@ - "matrix_registration_server_location" - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-sygnal/tasks/init.yml b/roles/matrix-sygnal/tasks/init.yml index efa17a4d..1543435c 100644 --- a/roles/matrix-sygnal/tasks/init.yml +++ b/roles/matrix-sygnal/tasks/init.yml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sygnal.service'] }}" when: matrix_sygnal_enabled|bool diff --git a/roles/matrix-sygnal/tasks/setup_install.yml b/roles/matrix-sygnal/tasks/setup_install.yml index 1a6ce186..26b59d99 100644 --- a/roles/matrix-sygnal/tasks/setup_install.yml +++ b/roles/matrix-sygnal/tasks/setup_install.yml @@ -12,7 +12,7 @@ until: result is not failed - name: Ensure Sygnal paths exists - file: + ansible.builtin.file: path: "{{ item }}" state: directory mode: 0750 @@ -24,7 +24,7 @@ - "{{ matrix_sygnal_data_path }}" - name: Ensure Sygnal config installed - copy: + ansible.builtin.copy: content: "{{ matrix_sygnal_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_sygnal_config_path }}/sygnal.yaml" mode: 0640 @@ -32,13 +32,13 @@ group: "{{ matrix_user_groupname }}" - name: Ensure matrix-sygnal.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-sygnal.service.j2" dest: "{{ matrix_systemd_path }}/matrix-sygnal.service" mode: 0644 register: matrix_sygnal_systemd_service_result - name: Ensure systemd reloaded after matrix-sygnal.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_sygnal_systemd_service_result.changed|bool" diff --git a/roles/matrix-sygnal/tasks/setup_uninstall.yml b/roles/matrix-sygnal/tasks/setup_uninstall.yml index 5a81a1b2..37b7db22 100644 --- a/roles/matrix-sygnal/tasks/setup_uninstall.yml +++ b/roles/matrix-sygnal/tasks/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_sygnal_service_stat - name: Ensure matrix-sygnal is stopped - service: + ansible.builtin.service: name: matrix-sygnal state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_sygnal_service_stat.stat.exists|bool" - name: Ensure matrix-sygnal.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-sygnal.service" state: absent when: "matrix_sygnal_service_stat.stat.exists|bool" - name: Ensure systemd reloaded after matrix-sygnal.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_sygnal_service_stat.stat.exists|bool" - name: Ensure Sygnal base directory doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_sygnal_base_path }}" state: absent diff --git a/roles/matrix-sygnal/tasks/validate_config.yml b/roles/matrix-sygnal/tasks/validate_config.yml index 2121edf4..b2c38010 100644 --- a/roles/matrix-sygnal/tasks/validate_config.yml +++ b/roles/matrix-sygnal/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if no Sygnal apps defined - fail: + ansible.builtin.fail: msg: >- Enabling Sygnal requires that you specify at least one app in `matrix_sygnal_apps` when: "matrix_sygnal_enabled and matrix_sygnal_apps|length == 0" diff --git a/roles/matrix-synapse-admin/tasks/init.yml b/roles/matrix-synapse-admin/tasks/init.yml index de8c0046..e274e186 100644 --- a/roles/matrix-synapse-admin/tasks/init.yml +++ b/roles/matrix-synapse-admin/tasks/init.yml @@ -2,17 +2,17 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_synapse_admin_container_image_self_build and matrix_synapse_admin_enabled" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-synapse-admin.service'] }}" when: matrix_synapse_admin_enabled|bool - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Synapse Admin's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -21,7 +21,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate Synapse Admin proxying configuration for matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_synapse_admin_matrix_nginx_proxy_configuration: | rewrite ^{{ matrix_synapse_admin_public_endpoint }}$ {{ matrix_nginx_proxy_x_forwarded_proto_value }}://$server_name{{ matrix_synapse_admin_public_endpoint }}/ permanent; @@ -38,7 +38,7 @@ } - name: Register Synapse Admin proxying configuration with matrix-nginx-proxy - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) @@ -50,7 +50,7 @@ when: matrix_synapse_admin_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used - debug: + ansible.builtin.debug: msg: >- NOTE: You've enabled the Synapse Admin tool but are not using the matrix-nginx-proxy reverse proxy. diff --git a/roles/matrix-synapse-admin/tasks/setup.yml b/roles/matrix-synapse-admin/tasks/setup.yml index f83ccdc3..5f117a12 100644 --- a/roles/matrix-synapse-admin/tasks/setup.yml +++ b/roles/matrix-synapse-admin/tasks/setup.yml @@ -17,7 +17,7 @@ until: result is not failed - name: Ensure matrix-synapse-admin repository is present when self-building - git: + ansible.builtin.git: repo: "{{ matrix_synapse_admin_container_image_self_build_repo }}" dest: "{{ matrix_synapse_admin_docker_src_files_path }}" version: "{{ matrix_synapse_admin_docker_image.split(':')[1] }}" @@ -40,7 +40,7 @@ when: "matrix_synapse_admin_enabled|bool and matrix_synapse_admin_container_image_self_build|bool" - name: Ensure matrix-synapse-admin.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-synapse-admin.service.j2" dest: "{{ matrix_systemd_path }}/matrix-synapse-admin.service" mode: 0644 @@ -48,7 +48,7 @@ when: matrix_synapse_admin_enabled|bool - name: Ensure systemd reloaded after matrix-synapse-admin.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_synapse_admin_enabled|bool and matrix_synapse_admin_systemd_service_result.changed" @@ -62,7 +62,7 @@ register: matrix_synapse_admin_service_stat - name: Ensure matrix-synapse-admin is stopped - service: + ansible.builtin.service: name: matrix-synapse-admin state: stopped enabled: false @@ -71,13 +71,13 @@ when: "not matrix_synapse_admin_enabled|bool and matrix_synapse_admin_service_stat.stat.exists" - name: Ensure matrix-synapse-admin.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_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 - service: + ansible.builtin.service: daemon_reload: true when: "not matrix_synapse_admin_enabled|bool and matrix_synapse_admin_service_stat.stat.exists" diff --git a/roles/matrix-synapse-admin/tasks/validate_config.yml b/roles/matrix-synapse-admin/tasks/validate_config.yml index 20a5c170..bf5fe69e 100644 --- a/roles/matrix-synapse-admin/tasks/validate_config.yml +++ b/roles/matrix-synapse-admin/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). diff --git a/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_install.yml b/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_install.yml index cdcdd082..41970cde 100644 --- a/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_install.yml +++ b/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Download matrix_encryption_disabler - get_url: + ansible.builtin.get_url: url: "{{ matrix_synapse_ext_encryption_disabler_download_url }}" dest: "{{ matrix_synapse_ext_path }}/matrix_e2ee_filter.py" force: true @@ -13,7 +13,7 @@ delay: "{{ matrix_geturl_retries_delay }}" until: result is not failed -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_modules: | {{ matrix_synapse_modules|default([]) diff --git a/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_uninstall.yml b/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_uninstall.yml index a532464d..c223f6e8 100644 --- a/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/ext/encryption-disabler/setup_uninstall.yml @@ -1,6 +1,6 @@ --- - name: Ensure matrix_encryption_disabler doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_ext_path }}/matrix_e2ee_filter.py" state: absent diff --git a/roles/matrix-synapse/tasks/ext/ldap-auth/setup.yml b/roles/matrix-synapse/tasks/ext/ldap-auth/setup.yml index b483f688..d5f54db3 100644 --- a/roles/matrix-synapse/tasks/ext/ldap-auth/setup.yml +++ b/roles/matrix-synapse/tasks/ext/ldap-auth/setup.yml @@ -1,6 +1,6 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_password_providers_enabled: true matrix_synapse_additional_loggers: > diff --git a/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_install.yml b/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_install.yml index 1d224bc9..4dd122ff 100644 --- a/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_install.yml +++ b/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_install.yml @@ -1,7 +1,7 @@ --- - name: Ensure git installed (RedHat) - yum: + ansible.builtin.yum: name: - git state: present @@ -9,7 +9,7 @@ when: "ansible_os_family == 'RedHat'" - name: Ensure git installed (Debian) - apt: + ansible.builtin.apt: name: - git state: present @@ -25,14 +25,14 @@ when: "ansible_distribution == 'Archlinux'" - name: Clone mjolnir-antispam git repository - git: + ansible.builtin.git: repo: "{{ matrix_synapse_ext_spam_checker_mjolnir_antispam_git_repository_url }}" version: "{{ matrix_synapse_ext_spam_checker_mjolnir_antispam_git_version }}" dest: "{{ matrix_synapse_ext_path }}/mjolnir" become: true become_user: "{{ matrix_user_username }}" -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_spam_checker: > {{ matrix_synapse_spam_checker diff --git a/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_uninstall.yml b/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_uninstall.yml index f8439a87..8211d51a 100644 --- a/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/ext/mjolnir-antispam/setup_uninstall.yml @@ -1,6 +1,6 @@ --- - name: Ensure mjolnir-antispam doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_ext_path }}/mjolnir" state: absent diff --git a/roles/matrix-synapse/tasks/ext/rest-auth/setup_install.yml b/roles/matrix-synapse/tasks/ext/rest-auth/setup_install.yml index 22ad318d..685b2922 100644 --- a/roles/matrix-synapse/tasks/ext/rest-auth/setup_install.yml +++ b/roles/matrix-synapse/tasks/ext/rest-auth/setup_install.yml @@ -1,12 +1,12 @@ --- - name: Fail if REST Auth endpoint not configured - fail: + ansible.builtin.fail: msg: "You have enabled the REST Auth password provider, but have not configured its endpoint in the `matrix_synapse_ext_password_provider_rest_auth_endpoint` variable. Consult the documentation." when: "matrix_synapse_ext_password_provider_rest_auth_endpoint == ''" - name: Download matrix-synapse-rest-auth - get_url: + ansible.builtin.get_url: url: "{{ matrix_synapse_ext_password_provider_rest_auth_download_url }}" dest: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" force: true @@ -18,7 +18,7 @@ delay: "{{ matrix_geturl_retries_delay }}" until: result is not failed -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_password_providers_enabled: true matrix_synapse_container_extra_arguments: > diff --git a/roles/matrix-synapse/tasks/ext/rest-auth/setup_uninstall.yml b/roles/matrix-synapse/tasks/ext/rest-auth/setup_uninstall.yml index be8ad600..d95dd1c7 100644 --- a/roles/matrix-synapse/tasks/ext/rest-auth/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/ext/rest-auth/setup_uninstall.yml @@ -1,6 +1,6 @@ --- - name: Ensure matrix-synapse-rest-auth doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" state: absent diff --git a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_install.yml b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_install.yml index 091b0eb2..f4229538 100644 --- a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_install.yml +++ b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_install.yml @@ -1,17 +1,17 @@ --- - name: Fail if Shared Secret Auth secret not set - fail: + ansible.builtin.fail: msg: "Shared Secret Auth is enabled, but no secret has been set in matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret" when: "matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret == ''" - name: Fail if no Shared Secret Auth login types enabled - fail: + ansible.builtin.fail: msg: "Shared Secret Auth is enabled, but none of the login types are" when: "not (matrix_synapse_ext_password_provider_shared_secret_auth_m_login_password_support_enabled or matrix_synapse_ext_password_provider_shared_secret_auth_com_devture_shared_secret_auth_support_enabled)" - name: Download matrix-synapse-shared-secret-auth - get_url: + ansible.builtin.get_url: url: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_download_url }}" dest: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" force: true @@ -23,7 +23,7 @@ delay: "{{ matrix_geturl_retries_delay }}" until: result is not failed -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_modules: | {{ matrix_synapse_modules|default([]) diff --git a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_uninstall.yml b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_uninstall.yml index e564909e..b2f90944 100644 --- a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup_uninstall.yml @@ -1,6 +1,6 @@ --- - name: Ensure matrix-synapse-shared-secret-auth doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" state: absent diff --git a/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_install.yml b/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_install.yml index 579a707c..7eb67deb 100644 --- a/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_install.yml +++ b/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_install.yml @@ -1,12 +1,12 @@ --- - name: Fail if Synapse Simple Antispam blocked homeservers is not set - fail: + ansible.builtin.fail: msg: "Synapse Simple Antispam is enabled, but no blocked homeservers have been set in matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers" when: "matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers|length == 0" - name: Ensure git installed (RedHat) - yum: + ansible.builtin.yum: name: - git state: present @@ -14,7 +14,7 @@ when: "ansible_os_family == 'RedHat'" - name: Ensure git installed (Debian) - apt: + ansible.builtin.apt: name: - git state: present @@ -30,14 +30,14 @@ when: "ansible_distribution == 'Archlinux'" - name: Clone synapse-simple-antispam git repository - git: + ansible.builtin.git: repo: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_repository_url }}" version: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_version }}" dest: "{{ matrix_synapse_ext_path }}/synapse-simple-antispam" become: true become_user: "{{ matrix_user_username }}" -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_modules: > {{ matrix_synapse_modules diff --git a/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_uninstall.yml b/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_uninstall.yml index 14cefc72..b1d558aa 100644 --- a/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/ext/synapse-simple-antispam/setup_uninstall.yml @@ -1,6 +1,6 @@ --- - name: Ensure synapse-simple-antispam doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_ext_path }}/synapse-simple-antispam" state: absent diff --git a/roles/matrix-synapse/tasks/goofys/setup_install.yml b/roles/matrix-synapse/tasks/goofys/setup_install.yml index d3781520..b9e99747 100644 --- a/roles/matrix-synapse/tasks/goofys/setup_install.yml +++ b/roles/matrix-synapse/tasks/goofys/setup_install.yml @@ -21,7 +21,7 @@ ignore_errors: true - name: Ensure Matrix Goofys external storage mountpoint exists - file: + ansible.builtin.file: path: "{{ matrix_s3_media_store_path }}" state: directory mode: 0750 @@ -30,20 +30,20 @@ when: "not local_path_matrix_s3_media_store_path_stat.failed and not local_path_matrix_s3_media_store_path_stat.stat.exists" - name: Ensure goofys environment variables file created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/goofys/env-goofys.j2" dest: "{{ matrix_synapse_config_dir_path }}/env-goofys" owner: root mode: 0600 - name: Ensure matrix-goofys.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/goofys/systemd/matrix-goofys.service.j2" dest: "{{ matrix_systemd_path }}/matrix-goofys.service" mode: 0644 register: matrix_goofys_systemd_service_result - name: Ensure systemd reloaded after matrix-goofys.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_goofys_systemd_service_result.changed" diff --git a/roles/matrix-synapse/tasks/goofys/setup_uninstall.yml b/roles/matrix-synapse/tasks/goofys/setup_uninstall.yml index c00206ef..8f7e3237 100644 --- a/roles/matrix-synapse/tasks/goofys/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/goofys/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_goofys_service_stat - name: Ensure matrix-goofys is stopped - service: + ansible.builtin.service: name: matrix-goofys state: stopped enabled: false @@ -15,18 +15,18 @@ when: "matrix_goofys_service_stat.stat.exists" - name: Ensure matrix-goofys.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-goofys.service" state: absent when: "matrix_goofys_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-goofys.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_goofys_service_stat.stat.exists" - name: Ensure goofys environment variables file doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_config_dir_path }}/env-goofys" state: absent diff --git a/roles/matrix-synapse/tasks/import_media_store.yml b/roles/matrix-synapse/tasks/import_media_store.yml index 8e962680..edfad27e 100644 --- a/roles/matrix-synapse/tasks/import_media_store.yml +++ b/roles/matrix-synapse/tasks/import_media_store.yml @@ -3,12 +3,12 @@ # Pre-checks - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `server_path_media_store` variable needs to be provided to this playbook, via --extra-vars" when: "server_path_media_store is not defined or server_path_media_store.startswith('<')" - name: Fail if media store is on Amazon S3 - fail: + ansible.builtin.fail: msg: "Your media store is on Amazon S3. Due to technical limitations, restoring is not supported." when: matrix_s3_media_store_enabled|bool @@ -18,7 +18,7 @@ register: server_path_media_store_stat - name: Fail if provided media store directory doesn't exist on the server - fail: + ansible.builtin.fail: msg: "{{ server_path_media_store }} cannot be found on the server" when: "not server_path_media_store_stat.stat.exists or not server_path_media_store_stat.stat.isdir" @@ -33,7 +33,7 @@ register: server_path_media_store_remote_content_stat - name: Fail if media store directory doesn't look okay (lacking remote and local content) - fail: + ansible.builtin.fail: msg: "{{ server_path_media_store }} contains neither local_content nor remote_content directories. It's most likely a mistake and is not a media store directory." when: "not server_path_media_store_local_content_stat.stat.exists and not server_path_media_store_remote_content_stat.stat.exists" @@ -41,7 +41,7 @@ # Actual import work - name: Ensure matrix-synapse is stopped - service: + ansible.builtin.service: name: matrix-synapse state: stopped enabled: false @@ -57,14 +57,14 @@ delete: true # It's wasteful to preserve owner/group now. We chown below anyway. owner: false - group: false + ansible.builtin.group: false times: true delegate_to: "{{ inventory_hostname }}" # This is for the generic case and fails in other cases (remote file systems), # because in such cases the base path (matrix_synapse_media_store_path) is a mount point. - name: Ensure media store permissions are correct (generic case) - file: + ansible.builtin.file: path: "{{ matrix_synapse_media_store_path }}" owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" @@ -75,7 +75,7 @@ # all files become owned by whoever needs to own them. - name: Ensure Synapse is started (if it previously was) - service: + ansible.builtin.service: name: "{{ item }}" state: started daemon_reload: true diff --git a/roles/matrix-synapse/tasks/init.yml b/roles/matrix-synapse/tasks/init.yml index ffaec05f..c76b4f6c 100644 --- a/roles/matrix-synapse/tasks/init.yml +++ b/roles/matrix-synapse/tasks/init.yml @@ -2,7 +2,7 @@ # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 - name: Fail if trying to self-build on Ansible < 2.8 - fail: + ansible.builtin.fail: msg: "To self-build the Synapse image, you should use Ansible 2.8 or higher. See docs/ansible.md" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_synapse_container_image_self_build and matrix_synapse_enabled" @@ -11,7 +11,7 @@ - import_tasks: "{{ role_path }}/tasks/synapse/workers/init.yml" when: "matrix_synapse_enabled and matrix_synapse_workers_enabled and matrix_synapse_workers_enabled_list|length == 0" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-synapse.service'] }}" when: matrix_synapse_enabled|bool @@ -22,13 +22,13 @@ loop_var: matrix_synapse_worker_details when: matrix_synapse_enabled|bool and matrix_synapse_workers_enabled|bool -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-goofys.service'] }}" when: matrix_s3_media_store_enabled|bool - block: - name: Fail if matrix-nginx-proxy role already executed - fail: + ansible.builtin.fail: msg: >- Trying to append Synapse's reverse-proxying configuration to matrix-nginx-proxy, but it's pointless since the matrix-nginx-proxy role had already executed. @@ -37,7 +37,7 @@ when: matrix_nginx_proxy_role_executed|default(False)|bool - name: Generate synapse metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/synapse/main-process) - set_fact: + ansible.builtin.set_fact: matrix_synapse_nginx_metrics_configuration_block: | location /metrics/synapse/main-process { {% if matrix_nginx_proxy_enabled|default(False) %} @@ -52,7 +52,7 @@ } - name: Register synapse metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/synapse/main-process) - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([]) @@ -61,7 +61,7 @@ }} - name: Generate synapse worker metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/synapse/worker) - set_fact: + ansible.builtin.set_fact: matrix_synapse_worker_nginx_metrics_configuration_block: | {% for worker in matrix_synapse_workers_enabled_list %} {% if worker.metrics_port != 0 %} @@ -76,7 +76,7 @@ when: matrix_synapse_workers_enabled_list|length > 0 - name: Register synapse worker metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/synapse/worker) - set_fact: + ansible.builtin.set_fact: matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([]) diff --git a/roles/matrix-synapse/tasks/main.yml b/roles/matrix-synapse/tasks/main.yml index 55235843..31a8c368 100644 --- a/roles/matrix-synapse/tasks/main.yml +++ b/roles/matrix-synapse/tasks/main.yml @@ -51,7 +51,7 @@ - rust-synapse-compress-state - name: Mark matrix-synapse role as executed - set_fact: + ansible.builtin.set_fact: matrix_synapse_role_executed: true tags: - always diff --git a/roles/matrix-synapse/tasks/register_user.yml b/roles/matrix-synapse/tasks/register_user.yml index 2a1c5708..48ce33bb 100644 --- a/roles/matrix-synapse/tasks/register_user.yml +++ b/roles/matrix-synapse/tasks/register_user.yml @@ -1,22 +1,22 @@ --- - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `username` variable needs to be provided to this playbook, via --extra-vars" when: "username is not defined or username == ''" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `password` variable needs to be provided to this playbook, via --extra-vars" when: "password is not defined or password == ''" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `admin` variable needs to be provided to this playbook, via --extra-vars" when: "admin is not defined or admin not in ['yes', 'no']" - name: Ensure matrix-synapse is started - service: + ansible.builtin.service: name: matrix-synapse state: started daemon_reload: true @@ -28,4 +28,4 @@ when: "start_result.changed" - name: Register user - command: "{{ matrix_local_bin_path }}/matrix-synapse-register-user {{ username|quote }} {{ password|quote }} {{ '1' if admin == 'yes' else '0' }}" + ansible.builtin.command: "{{ matrix_local_bin_path }}/matrix-synapse-register-user {{ username|quote }} {{ password|quote }} {{ '1' if admin == 'yes' else '0' }}" diff --git a/roles/matrix-synapse/tasks/rust-synapse-compress-state/compress_room.yml b/roles/matrix-synapse/tasks/rust-synapse-compress-state/compress_room.yml index e1386c75..30849ded 100644 --- a/roles/matrix-synapse/tasks/rust-synapse-compress-state/compress_room.yml +++ b/roles/matrix-synapse/tasks/rust-synapse-compress-state/compress_room.yml @@ -1,10 +1,10 @@ --- -- debug: +- ansible.builtin.debug: msg: "Compressing room `{{ room_details.room_id }}` having {{ room_details.count }} state group rows" - name: Generate rust-synapse-compress-state room compression command - set_fact: + ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_compress_room_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-compress-room --user={{ matrix_user_uid }}:{{ matrix_user_gid }} @@ -17,15 +17,15 @@ -r '{{ room_details.room_id }}' - name: Run rust-synapse-compress-state room compression command (SQL generation) - command: "{{ matrix_synapse_rust_synapse_compress_state_compress_room_command }}" + ansible.builtin.command: "{{ matrix_synapse_rust_synapse_compress_state_compress_room_command }}" async: "{{ matrix_synapse_rust_synapse_compress_state_compress_room_time }}" poll: 10 register: matrix_synapse_rust_synapse_compress_state_compress_room_command_result -- debug: var="matrix_synapse_rust_synapse_compress_state_compress_room_command_result" +- ansible.builtin.debug: var="matrix_synapse_rust_synapse_compress_state_compress_room_command_result" - name: Generate Postgres compression SQL import command - set_fact: + ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_psql_import_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-psql-import --user={{ matrix_user_uid }}:{{ matrix_user_gid }} @@ -39,12 +39,12 @@ psql -v ON_ERROR_STOP=1 -h matrix-postgres -d {{ matrix_synapse_database_database }}" - name: Import compression SQL into Postgres - command: "{{ matrix_synapse_rust_synapse_compress_state_psql_import_command }}" + ansible.builtin.command: "{{ matrix_synapse_rust_synapse_compress_state_psql_import_command }}" async: "{{ matrix_synapse_rust_synapse_compress_state_psql_import_time }}" poll: 10 register: matrix_synapse_rust_synapse_compress_state_psql_import_command_result - name: Clean up - file: + ansible.builtin.file: path: "{{ matrix_synapse_rust_synapse_compress_state_base_path }}/state-compressor.sql" state: absent diff --git a/roles/matrix-synapse/tasks/rust-synapse-compress-state/main.yml b/roles/matrix-synapse/tasks/rust-synapse-compress-state/main.yml index 219f1c98..33a18ac6 100644 --- a/roles/matrix-synapse/tasks/rust-synapse-compress-state/main.yml +++ b/roles/matrix-synapse/tasks/rust-synapse-compress-state/main.yml @@ -2,7 +2,7 @@ # Pre-checks - name: Fail if Postgres not enabled - fail: + ansible.builtin.fail: msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot use rust-synapse-compress-state." when: "not matrix_postgres_enabled|bool" @@ -10,22 +10,22 @@ # Defaults - name: Set matrix_synapse_rust_synapse_compress_state_find_rooms_command_wait_time, if not provided - set_fact: + ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_find_rooms_command_wait_time: 1800 when: "matrix_synapse_rust_synapse_compress_state_find_rooms_command_wait_time|default('') == ''" - name: Set matrix_synapse_rust_synapse_compress_state_compress_room_time, if not provided - set_fact: + ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_compress_room_time: 3600 when: "matrix_synapse_rust_synapse_compress_state_compress_room_time|default('') == ''" - name: Set matrix_synapse_rust_synapse_compress_state_psql_import_time, if not provided - set_fact: + ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_psql_import_time: 3600 when: "matrix_synapse_rust_synapse_compress_state_psql_import_time|default('') == ''" - name: Set matrix_synapse_rust_synapse_compress_state_min_state_groups_required, if not provided - set_fact: + ansible.builtin.set_fact: # The minimum number of state groups we're looking for before we consider a room eligible for compression. # Rooms with a smaller state groups count will not be compressed. matrix_synapse_rust_synapse_compress_state_min_state_groups_required: 100000 @@ -35,7 +35,7 @@ # Actual compression work - name: Ensure rust-synapse-compress-state paths exist - file: + ansible.builtin.file: path: "{{ matrix_synapse_rust_synapse_compress_state_base_path }}" state: directory mode: 0750 @@ -54,7 +54,7 @@ until: result is not failed - name: Generate rust-synapse-compress-state room find command - set_fact: + ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_find_rooms_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-find-rooms --user={{ matrix_user_uid }}:{{ matrix_user_gid }} @@ -66,7 +66,7 @@ 'SELECT array_to_json(array_agg(row_to_json (r))) FROM (SELECT room_id, count(*) AS count FROM state_groups_state GROUP BY room_id HAVING count(*) > {{ matrix_synapse_rust_synapse_compress_state_min_state_groups_required }} ORDER BY count DESC) r;' - name: Find rooms eligible for compression with rust-synapse-compress-state - command: "{{ matrix_synapse_rust_synapse_compress_state_find_rooms_command }}" + ansible.builtin.command: "{{ matrix_synapse_rust_synapse_compress_state_find_rooms_command }}" async: "{{ matrix_synapse_rust_synapse_compress_state_find_rooms_command_wait_time }}" poll: 10 register: matrix_synapse_rust_synapse_compress_state_find_rooms_command_result @@ -85,10 +85,10 @@ # Row 3 contains a space when there's no result. - block: - - debug: var="matrix_synapse_rust_synapse_compress_state_find_rooms_command_result" + - ansible.builtin.debug: var="matrix_synapse_rust_synapse_compress_state_find_rooms_command_result" - name: Fail if room find result is not what we expect - fail: + ansible.builtin.fail: msg: >- Expecting 4 lines in the "find rooms" result. when: "matrix_synapse_rust_synapse_compress_state_find_rooms_command_result.failed or matrix_synapse_rust_synapse_compress_state_find_rooms_command_result.stdout_lines|length != 4" @@ -96,11 +96,11 @@ - block: # matrix_synapse_rust_synapse_compress_state_eligible_rooms is a list # of dictionaries like this: {'room_id': '!some-id', 'count': 2461329} - - set_fact: + - ansible.builtin.set_fact: matrix_synapse_rust_synapse_compress_state_eligible_rooms: "{{ matrix_synapse_rust_synapse_compress_state_find_rooms_command_result.stdout_lines[2] | from_json }}" - name: Display rooms that will be compressed - debug: + ansible.builtin.debug: msg: >- The following rooms contain more than {{ matrix_synapse_rust_synapse_compress_state_min_state_groups_required }} state group rows (configurable via `matrix_synapse_rust_synapse_compress_state_min_state_groups_required`) @@ -115,7 +115,7 @@ when: "matrix_synapse_rust_synapse_compress_state_find_rooms_command_result.stdout_lines[2] != ' '" - name: Show notice about lack of rooms to compress - debug: + ansible.builtin.debug: msg: >- No rooms were found to contain more than {{ matrix_synapse_rust_synapse_compress_state_min_state_groups_required }} state group rows (configurable via `matrix_synapse_rust_synapse_compress_state_min_state_groups_required`), diff --git a/roles/matrix-synapse/tasks/self_check_client_api.yml b/roles/matrix-synapse/tasks/self_check_client_api.yml index 407a79ff..c0906304 100644 --- a/roles/matrix-synapse/tasks/self_check_client_api.yml +++ b/roles/matrix-synapse/tasks/self_check_client_api.yml @@ -1,7 +1,7 @@ --- - name: Check Matrix Client API - uri: + ansible.builtin.uri: url: "{{ matrix_synapse_client_api_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_synapse_self_check_validate_certificates }}" @@ -11,11 +11,11 @@ when: matrix_synapse_enabled|bool - name: Fail if Matrix Client API not working - fail: + ansible.builtin.fail: msg: "Failed checking Matrix Client API is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_synapse_client_api_url_endpoint_public }}`). Is Synapse running? Is port 443 open in your firewall? Full error: {{ result_matrix_synapse_client_api }}" when: "matrix_synapse_enabled|bool and (result_matrix_synapse_client_api.failed or 'json' not in result_matrix_synapse_client_api)" - name: Report working Matrix Client API - debug: + ansible.builtin.debug: msg: "The Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_synapse_client_api_url_endpoint_public }}`) is working" when: matrix_synapse_enabled|bool diff --git a/roles/matrix-synapse/tasks/self_check_federation_api.yml b/roles/matrix-synapse/tasks/self_check_federation_api.yml index 32249372..447e3e26 100644 --- a/roles/matrix-synapse/tasks/self_check_federation_api.yml +++ b/roles/matrix-synapse/tasks/self_check_federation_api.yml @@ -1,7 +1,7 @@ --- - name: Check Matrix Federation API - uri: + ansible.builtin.uri: url: "{{ matrix_synapse_federation_api_url_endpoint_public }}" follow_redirects: none validate_certs: "{{ matrix_synapse_self_check_validate_certificates }}" @@ -11,16 +11,16 @@ when: matrix_synapse_enabled|bool - name: Fail if Matrix Federation API not working - fail: + ansible.builtin.fail: msg: "Failed checking Matrix Federation API is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_synapse_federation_api_url_endpoint_public }}`). Is Synapse running? Is port {{ matrix_federation_public_port }} open in your firewall? Full error: {{ result_matrix_synapse_federation_api }}" when: "matrix_synapse_enabled|bool and matrix_synapse_federation_enabled|bool and (result_matrix_synapse_federation_api.failed or 'json' not in result_matrix_synapse_federation_api)" - name: Fail if Matrix Federation API unexpectedly enabled - fail: + ansible.builtin.fail: msg: "Matrix Federation API is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_synapse_federation_api_url_endpoint_public }}`) despite being disabled." when: "matrix_synapse_enabled|bool and not matrix_synapse_federation_enabled|bool and not result_matrix_synapse_federation_api.failed" - name: Report working Matrix Federation API - debug: + ansible.builtin.debug: msg: "The Matrix Federation API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_synapse_federation_api_url_endpoint_public }}`) is working" when: "matrix_synapse_enabled|bool and matrix_synapse_federation_enabled|bool" diff --git a/roles/matrix-synapse/tasks/setup_synapse.yml b/roles/matrix-synapse/tasks/setup_synapse.yml index 47e404f4..c2b33f0b 100644 --- a/roles/matrix-synapse/tasks/setup_synapse.yml +++ b/roles/matrix-synapse/tasks/setup_synapse.yml @@ -1,7 +1,7 @@ --- - name: Ensure Synapse paths exist - file: + ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0750 diff --git a/roles/matrix-synapse/tasks/synapse/setup_install.yml b/roles/matrix-synapse/tasks/synapse/setup_install.yml index 1aaaf7b3..e0d47072 100644 --- a/roles/matrix-synapse/tasks/synapse/setup_install.yml +++ b/roles/matrix-synapse/tasks/synapse/setup_install.yml @@ -10,7 +10,7 @@ # This is separate and conditional, to ensure we don't execute it # if the path already exists or we failed to check, because it's mounted using fuse. - name: Ensure Synapse media store path exists - file: + ansible.builtin.file: path: "{{ matrix_synapse_media_store_path }}" state: directory mode: 0750 @@ -20,7 +20,7 @@ - block: - name: Ensure Synapse repository is present on self-build - git: + ansible.builtin.git: repo: "{{ matrix_synapse_container_image_self_build_repo }}" dest: "{{ matrix_synapse_docker_src_files_path }}" version: "{{ matrix_synapse_docker_image.split(':')[1] }}" @@ -30,14 +30,14 @@ register: matrix_synapse_git_pull_results - name: Check if Synapse Docker image exists - command: "{{ matrix_host_command_docker }} images --quiet --filter 'reference={{ matrix_synapse_docker_image }}'" + ansible.builtin.command: "{{ matrix_host_command_docker }} images --quiet --filter 'reference={{ matrix_synapse_docker_image }}'" register: matrix_synapse_docker_image_check_result # Invoking the `docker build` command here, instead of calling the `docker_image` Ansible module, # because the latter does not support BuildKit. # See: https://github.com/ansible-collections/community.general/issues/514 - name: Ensure Synapse Docker image is built - shell: + ansible.builtin.shell: chdir: "{{ matrix_synapse_docker_src_files_path }}" cmd: | {{ matrix_host_command_docker }} build \ @@ -74,7 +74,7 @@ # We don't use the `docker_container` module, because using it with `cap_drop` requires # a very recent docker-py version, which is not available for a lot of people yet. - name: Generate initial Synapse config and signing key - command: | + ansible.builtin.command: | docker run --rm --name=matrix-config @@ -89,7 +89,7 @@ when: "not matrix_synapse_signing_key_stat.stat.exists" - name: Ensure Synapse homeserver config installed - copy: + ansible.builtin.copy: content: "{{ matrix_synapse_configuration|to_nice_yaml(indent=2, width=999999) }}" dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml" mode: 0644 @@ -97,31 +97,31 @@ group: "{{ matrix_user_groupname }}" - name: Ensure Synapse log config installed - template: + ansible.builtin.template: src: "{{ matrix_synapse_template_synapse_log }}" dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.log.config" mode: 0644 - name: Ensure matrix-synapse.service installed - template: + ansible.builtin.template: src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2" dest: "{{ matrix_systemd_path }}/matrix-synapse.service" mode: 0644 register: matrix_synapse_systemd_service_result - name: Ensure systemd reloaded after matrix-synapse.service installation - service: + ansible.builtin.service: daemon_reload: true when: "matrix_synapse_systemd_service_result.changed" - name: Ensure matrix-synapse-register-user script created - template: + ansible.builtin.template: src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-register-user.j2" dest: "{{ matrix_local_bin_path }}/matrix-synapse-register-user" mode: 0755 - name: Generate sample prometheus.yml for external scraping - template: + ansible.builtin.template: src: "{{ role_path }}/templates/synapse/prometheus/external_prometheus.yml.example.j2" dest: "{{ matrix_synapse_base_path }}/external_prometheus.yml.example" owner: "{{ matrix_user_username }}" diff --git a/roles/matrix-synapse/tasks/synapse/setup_uninstall.yml b/roles/matrix-synapse/tasks/synapse/setup_uninstall.yml index 1d4fe7ad..1f2d3fe5 100644 --- a/roles/matrix-synapse/tasks/synapse/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/synapse/setup_uninstall.yml @@ -6,7 +6,7 @@ register: matrix_synapse_service_stat - name: Ensure matrix-synapse is stopped - service: + ansible.builtin.service: name: matrix-synapse state: stopped enabled: false @@ -15,13 +15,13 @@ when: "matrix_synapse_service_stat.stat.exists" - name: Ensure matrix-synapse.service doesn't exist - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-synapse.service" state: absent when: "matrix_synapse_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-synapse.service removal - service: + ansible.builtin.service: daemon_reload: true when: "matrix_synapse_service_stat.stat.exists" @@ -31,7 +31,7 @@ state: absent - name: Ensure sample prometheus.yml for external scraping is deleted - file: + ansible.builtin.file: path: "{{ matrix_synapse_base_path }}/external_prometheus.yml.example" state: absent when: "not matrix_synapse_metrics_proxying_enabled|bool" diff --git a/roles/matrix-synapse/tasks/synapse/workers/init.yml b/roles/matrix-synapse/tasks/synapse/workers/init.yml index f59313bd..6d75d9f6 100644 --- a/roles/matrix-synapse/tasks/synapse/workers/init.yml +++ b/roles/matrix-synapse/tasks/synapse/workers/init.yml @@ -5,7 +5,7 @@ # so we're forced to do something much uglier. - name: Build generic workers - set_fact: + ansible.builtin.set_fact: worker: type: 'generic_worker' instanceId: "{{ matrix_synapse_workers_generic_workers_port_range_start + item }}" @@ -15,7 +15,7 @@ loop: "{{ range(0, matrix_synapse_workers_generic_workers_count|int)|list }}" - name: Build federation sender workers - set_fact: + ansible.builtin.set_fact: worker: type: 'federation_sender' instanceId: "{{ item }}" @@ -26,7 +26,7 @@ # This type of worker can only have a count of 1, at most - name: Build pusher workers - set_fact: + ansible.builtin.set_fact: worker: type: 'pusher' instanceId: "{{ item }}" @@ -37,7 +37,7 @@ # This type of worker can only have a count of 1, at most - name: Build appservice workers - set_fact: + ansible.builtin.set_fact: worker: type: 'appservice' instanceId: "{{ item }}" @@ -47,7 +47,7 @@ loop: "{{ range(0, matrix_synapse_workers_appservice_workers_count|int)|list }}" - name: Build media_repository workers - set_fact: + ansible.builtin.set_fact: worker: type: 'media_repository' instanceId: "{{ matrix_synapse_workers_media_repository_workers_port_range_start + item }}" @@ -57,7 +57,7 @@ loop: "{{ range(0, matrix_synapse_workers_media_repository_workers_count|int)|list }}" - name: Build frontend_proxy workers - set_fact: + ansible.builtin.set_fact: worker: type: 'frontend_proxy' instanceId: "{{ matrix_synapse_workers_frontend_proxy_workers_port_range_start + item }}" @@ -66,7 +66,7 @@ register: "matrix_synapse_workers_list_results_frontend_proxy_workers" loop: "{{ range(0, matrix_synapse_workers_frontend_proxy_workers_count|int)|list }}" -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_dynamic_workers_list: "{{ matrix_synapse_dynamic_workers_list|default([]) + [item.ansible_facts.worker] }}" with_items: | {{ @@ -83,5 +83,5 @@ matrix_synapse_workers_list_results_frontend_proxy_workers.results }} -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_workers_enabled_list: "{{ matrix_synapse_dynamic_workers_list }}" diff --git a/roles/matrix-synapse/tasks/synapse/workers/setup.yml b/roles/matrix-synapse/tasks/synapse/workers/setup.yml index ce66a2e4..7fcce2b4 100644 --- a/roles/matrix-synapse/tasks/synapse/workers/setup.yml +++ b/roles/matrix-synapse/tasks/synapse/workers/setup.yml @@ -3,14 +3,14 @@ # A previous version of the worker setup used this. # This is a temporary cleanup for people who ran that version. - name: Ensure old matrix-synapse.service.wants directory is gone - file: + ansible.builtin.file: path: "{{ matrix_systemd_path }}/matrix-synapse.service.wants" state: absent # Same. This was part of a previous version of the worker setup. # No longer necessary. - name: Ensure matrix-synapse-worker-write-pid script is removed - file: + ansible.builtin.file: path: "{{ matrix_local_bin_path }}/matrix-synapse-worker-write-pid" state: absent diff --git a/roles/matrix-synapse/tasks/synapse/workers/setup_install.yml b/roles/matrix-synapse/tasks/synapse/workers/setup_install.yml index 983f1876..ce86e35f 100644 --- a/roles/matrix-synapse/tasks/synapse/workers/setup_install.yml +++ b/roles/matrix-synapse/tasks/synapse/workers/setup_install.yml @@ -9,7 +9,7 @@ # This also deletes some things which we need. They will be recreated below. - name: Ensure previous worker configs are cleaned - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{ matrix_synapse_workers_current_config_files.files }}" @@ -22,7 +22,7 @@ register: matrix_synapse_workers_current_systemd_services - name: Ensure unnecessary worker systemd services are stopped and disabled - service: + ansible.builtin.service: name: "{{ item.path|basename }}" state: stopped enabled: false @@ -30,7 +30,7 @@ when: "not ansible_check_mode and item.path|basename not in matrix_systemd_services_list" - name: Ensure unnecessary worker systemd services are cleaned - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}" diff --git a/roles/matrix-synapse/tasks/synapse/workers/setup_uninstall.yml b/roles/matrix-synapse/tasks/synapse/workers/setup_uninstall.yml index f0357611..8b70dec5 100644 --- a/roles/matrix-synapse/tasks/synapse/workers/setup_uninstall.yml +++ b/roles/matrix-synapse/tasks/synapse/workers/setup_uninstall.yml @@ -4,7 +4,7 @@ service_facts: - name: Ensure any worker services are stopped - service: + ansible.builtin.service: name: "{{ item.key }}" state: stopped with_dict: "{{ ansible_facts.services|default({})|dict2items|selectattr('key', 'match', 'matrix-synapse-worker-.+\\.service')|list|items2dict }}" @@ -18,7 +18,7 @@ register: matrix_synapse_workers_current_config_files - name: Ensure previous worker configs are cleaned - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{ matrix_synapse_workers_current_config_files.files }}" @@ -31,7 +31,7 @@ register: matrix_synapse_workers_current_systemd_services - name: Ensure previous worker systemd services are cleaned - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}" diff --git a/roles/matrix-synapse/tasks/synapse/workers/util/inject_systemd_services_for_worker.yml b/roles/matrix-synapse/tasks/synapse/workers/util/inject_systemd_services_for_worker.yml index 2669e149..dfbb8316 100644 --- a/roles/matrix-synapse/tasks/synapse/workers/util/inject_systemd_services_for_worker.yml +++ b/roles/matrix-synapse/tasks/synapse/workers/util/inject_systemd_services_for_worker.yml @@ -8,12 +8,12 @@ # In the future, it should be possible to remove this check. # Our own code which dynamically builds `matrix_synapse_workers_enabled_list` does things right. - name: Fail if instanceId not defined for worker - fail: + ansible.builtin.fail: msg: "Synapse workers (like {{ matrix_synapse_worker_details|to_json }}) need to define an instanceId property (type + instanceId must be unique)" when: "'instanceId' not in matrix_synapse_worker_details" -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_worker_systemd_service_name: "matrix-synapse-worker-{{ matrix_synapse_worker_details.type }}-{{ matrix_synapse_worker_details.instanceId }}.service" -- set_fact: +- ansible.builtin.set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + [matrix_synapse_worker_systemd_service_name] }}" diff --git a/roles/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml b/roles/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml index 2247cd89..883558a7 100644 --- a/roles/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml +++ b/roles/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml @@ -1,21 +1,21 @@ --- -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_worker_systemd_service_name: "matrix-synapse-worker-{{ matrix_synapse_worker_details.type }}-{{ matrix_synapse_worker_details.instanceId }}" -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_worker_container_name: "{{ matrix_synapse_worker_systemd_service_name }}" -- set_fact: +- ansible.builtin.set_fact: matrix_synapse_worker_config_file_name: "worker.{{ matrix_synapse_worker_details.type }}_{{ matrix_synapse_worker_details.instanceId }}.yaml" - name: Ensure configuration exists for {{ matrix_synapse_worker_systemd_service_name }} - template: + ansible.builtin.template: src: "{{ role_path }}/templates/synapse/worker.yaml.j2" dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }}" - name: Ensure systemd service exists for {{ matrix_synapse_worker_systemd_service_name }} - template: + ansible.builtin.template: src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse-worker.service.j2" dest: "{{ matrix_systemd_path }}/{{ matrix_synapse_worker_systemd_service_name }}.service" mode: 0644 diff --git a/roles/matrix-synapse/tasks/update_user_password.yml b/roles/matrix-synapse/tasks/update_user_password.yml index fd348d9d..171159ff 100644 --- a/roles/matrix-synapse/tasks/update_user_password.yml +++ b/roles/matrix-synapse/tasks/update_user_password.yml @@ -1,29 +1,29 @@ --- - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `username` variable needs to be provided to this playbook, via --extra-vars" when: "username is not defined or username == ''" - name: Fail if playbook called incorrectly - fail: + ansible.builtin.fail: msg: "The `password` variable needs to be provided to this playbook, via --extra-vars" when: "password is not defined or password == ''" - name: Fail if not using matrix-postgres container - fail: + ansible.builtin.fail: msg: "This command is working only when matrix-postgres container is being used" when: "not matrix_postgres_enabled|bool" - name: Ensure matrix-synapse is started - service: + ansible.builtin.service: name: matrix-synapse state: started daemon_reload: true register: start_result - name: Ensure matrix-postgres is started - service: + ansible.builtin.service: name: matrix-postgres state: started daemon_reload: true @@ -36,8 +36,8 @@ when: "start_result.changed or postgres_start_result.changed" - name: Generate password hash - shell: "{{ matrix_host_command_docker }} exec matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml -p {{ password|quote }}" + ansible.builtin.shell: "{{ matrix_host_command_docker }} exec matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml -p {{ password|quote }}" register: password_hash - name: Update user password hash - command: "{{ matrix_local_bin_path }}/matrix-postgres-update-user-password-hash {{ username|quote }} {{ password_hash.stdout|quote }}" + ansible.builtin.command: "{{ matrix_local_bin_path }}/matrix-postgres-update-user-password-hash {{ username|quote }} {{ password_hash.stdout|quote }}" diff --git a/roles/matrix-synapse/tasks/validate_config.yml b/roles/matrix-synapse/tasks/validate_config.yml index ab0ca3a7..ba60abf8 100644 --- a/roles/matrix-synapse/tasks/validate_config.yml +++ b/roles/matrix-synapse/tasks/validate_config.yml @@ -1,7 +1,7 @@ --- - name: Fail if required Synapse settings not defined - fail: + ansible.builtin.fail: msg: >- You need to define a required configuration setting (`{{ item }}`) for using Synapse. when: "vars[item] == ''" @@ -13,7 +13,7 @@ - "matrix_synapse_database_database" - name: Fail if asking to configure deprecaed workers (appservice, userdir) - fail: + ansible.builtin.fail: msg: >- `{{ item }}` cannot be more than 0. This type of worker has been deprecated since Synapse v1.59. @@ -25,7 +25,7 @@ - "matrix_synapse_workers_user_dir_workers_count" - name: Fail if asking for more than 1 instance of single-instance workers - fail: + ansible.builtin.fail: msg: >- `{{ item }}` cannot be more than 1. This is a single-instance worker. when: "vars[item]|int > 1" @@ -34,7 +34,7 @@ - "matrix_synapse_workers_federation_sender_workers_count" - name: (Deprecation) Catch and report renamed settings - fail: + ansible.builtin.fail: msg: >- Your configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). @@ -63,7 +63,7 @@ - {'old': 'matrix_synapse_enable_group_creation', 'new': ''} - name: (Deprecation) Catch and report renamed settings in matrix_synapse_configuration_extension_yaml - fail: + ansible.builtin.fail: msg: >- Your matrix_synapse_configuration_extension_yaml configuration contains a variable, which now has a different name. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).