Use fully-qualified module names for builtin Ansible modules

Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/1939
This commit is contained in:
Slavi Pantaleev
2022-07-18 10:39:08 +03:00
parent 78b5be4a26
commit 34cdaade08
297 changed files with 1420 additions and 1420 deletions

View File

@ -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

View File

@ -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"

View File

@ -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 }}`)"

View File

@ -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"

View File

@ -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

View File

@ -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.