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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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