diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d09762fe..4e456a286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,36 @@ +# 2026-03-23 + +## Migration validation system introduced + +Previously, when updating your setup, you had to remember to read the [CHANGELOG](CHANGELOG.md) file or risk breakage. + +Now, the playbook includes a migration validation system that ensures you're aware of breaking changes before they affect your deployment. +You're now forced to acknowledge each breaking change, unless you wish to live dangerously (see below). + +A new `matrix_playbook_migration_validated_version` variable has been introduced. + +**New users** who started from the [example `vars.yml`](examples/vars.yml) file already have this variable set and do not need to do anything. + +**Existing users** will need to add the following to their `vars.yml` file after reviewing all changelog entries up to now: + +```yml +matrix_playbook_migration_validated_version: v2026.03.23.0 +``` + +Going forward, whenever a breaking change is introduced the playbook will: + +- bump its expected version value (`matrix_playbook_migration_expected_version`), causing a discrepancy with what you validated (`matrix_playbook_migration_validated_version`) + +- fail when you run it with a helpful message listing what changed and linking to the relevant changelog entries + +After reviewing and adapting your setup, you simply update the variable to the new version. + +If you'd like to live dangerously and skip these checks (not recommended), you can set this once and be done with it: + +```yml +matrix_playbook_migration_validated_version: "{{ matrix_playbook_migration_expected_version }}" +``` + # 2026-03-19 ## Matrix Authentication Service now prefers UNIX sockets for playbook-managed Postgres diff --git a/examples/vars.yml b/examples/vars.yml index 655e75c24..05259d65d 100644 --- a/examples/vars.yml +++ b/examples/vars.yml @@ -1,4 +1,9 @@ --- +# This variable acknowledges that you've reviewed breaking changes up to this version. +# The playbook will fail if this is outdated, guiding you through what changed. +# See the changelog: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/CHANGELOG.md +matrix_playbook_migration_validated_version: v2026.03.23.0 + # The bare domain name which represents your Matrix identity. # Matrix user IDs for your server will be of the form (`@alice:example.com`). # diff --git a/roles/custom/matrix_playbook_migration/defaults/main.yml b/roles/custom/matrix_playbook_migration/defaults/main.yml index b12074cbc..2432996ae 100644 --- a/roles/custom/matrix_playbook_migration/defaults/main.yml +++ b/roles/custom/matrix_playbook_migration/defaults/main.yml @@ -1,9 +1,27 @@ -# SPDX-FileCopyrightText: 2023 - 2025 Slavi Pantaleev +# SPDX-FileCopyrightText: 2023 - 2026 Slavi Pantaleev # SPDX-FileCopyrightText: 2024 Suguru Hirahara # # SPDX-License-Identifier: AGPL-3.0-or-later --- + +# The version that the user has validated their setup against. +# When empty, the user will be prompted to set this variable. +# New users should set this to the current expected version (see below). +# See `examples/vars.yml` and `matrix_playbook_migration_expected_version` for the recommended value. +matrix_playbook_migration_validated_version: '' + +# The version that the playbook expects the user to have validated against. +# This is bumped whenever a breaking change is introduced. +# The value configured here needs to exist in `matrix_playbook_migration_breaking_changes` as well. +matrix_playbook_migration_expected_version: "v2026.03.23.0" + +# A list of breaking changes, used to inform users what changed between their validated version and the expected version. +matrix_playbook_migration_breaking_changes: + - version: "v2026.03.23.0" + summary: "Initial migration validation system" + changelog_url: "https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/CHANGELOG.md#2026-03-22" + # Controls if (`matrix_prometheus_nginxlog_exporter` -> `prometheus_nginxlog_exporter`) validation will run. matrix_playbook_migration_matrix_prometheus_nginxlog_exporter_migration_validation_enabled: true diff --git a/roles/custom/matrix_playbook_migration/tasks/main.yml b/roles/custom/matrix_playbook_migration/tasks/main.yml index 333380332..538521df1 100644 --- a/roles/custom/matrix_playbook_migration/tasks/main.yml +++ b/roles/custom/matrix_playbook_migration/tasks/main.yml @@ -1,9 +1,14 @@ -# SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev +# SPDX-FileCopyrightText: 2022 - 2026 Slavi Pantaleev # # SPDX-License-Identifier: AGPL-3.0-or-later --- +- tags: + - always + block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_migration_version.yml" + - tags: - setup-all - install-all diff --git a/roles/custom/matrix_playbook_migration/tasks/validate_migration_version.yml b/roles/custom/matrix_playbook_migration/tasks/validate_migration_version.yml new file mode 100644 index 000000000..334f524cc --- /dev/null +++ b/roles/custom/matrix_playbook_migration/tasks/validate_migration_version.yml @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2026 Slavi Pantaleev +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- name: Fail if migration version is not validated (first-time onboarding) + ansible.builtin.fail: + msg: >- + This playbook now uses a migration validation system to help you stay aware of breaking changes. + + It appears that you haven't configured the `matrix_playbook_migration_validated_version` variable yet. + + Please review the changelog (https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/CHANGELOG.md) + and then add the following to your vars.yml file: + + matrix_playbook_migration_validated_version: {{ matrix_playbook_migration_expected_version }} + when: "matrix_playbook_migration_validated_version == ''" + +- name: Fail if migration version is outdated + ansible.builtin.fail: + msg: |- + Your validated migration version ({{ matrix_playbook_migration_validated_version }}) is behind the expected version ({{ matrix_playbook_migration_expected_version }}). + + The following breaking changes have been introduced since your last validation: + + {% for item in matrix_playbook_migration_breaking_changes | selectattr('version', '>', matrix_playbook_migration_validated_version) | sort(attribute='version') %} + - {{ item.version }}: {{ item.summary }} ({{ item.changelog_url }}) + {% endfor %} + + After reviewing the above changes and adapting your setup, update your vars.yml: + + matrix_playbook_migration_validated_version: "{{ matrix_playbook_migration_expected_version }}" + when: "matrix_playbook_migration_validated_version != '' and matrix_playbook_migration_validated_version < matrix_playbook_migration_expected_version"