Changeset - 14e9fb107a9a
[Not reviewed]
0 3 0
Branko Majic (branko) - 5 months ago 2023-11-26 14:37:12
branko@majic.rs
MAR-186: Reorder the deprecation tasks for xmpp_server role to make the runs reliable:

- Deprecated apt repository really needs to be removed first in case
it has an unresolvable URL (so the backports repository cache update
would trigger correctly).
- Use the file removal for Prosody repository as well to make sure the
file is dropped.
3 files changed with 68 insertions and 26 deletions:
0 comments (0 inline, 0 general)
docs/releasenotes.rst
Show inline comments
 
@@ -2,6 +2,21 @@ Release notes
 
=============
 

	
 

	
 
x.y.z
 
-----
 

	
 
Minor bug-fixes.
 

	
 
**Bug fixes:**
 

	
 
* ``xmpp_server`` role
 

	
 
  * Make sure to take care of deprecation-related package and
 
    configuration removals prior to running the rest of the tasks to
 
    avoid errors relaetd to deprecated elements being invalid (like
 
    repository URLs for Prosody).
 

	
 

	
 
7.0.0
 
-----
 

	
roles/xmpp_server/molecule/default/prepare.yml
Show inline comments
 
@@ -162,6 +162,14 @@
 
        group: root
 
        mode: 0755
 

	
 
    - name: Invalidate the Prosody repository URL for testing if the file gets dropped at correct time during initial converge
 
      copy:
 
        content: "deb http://invalidname/debian buster main"
 
        dest: "/etc/apt/sources.list.d/packages_prosody_im_debian.list"
 
        owner: root
 
        group: root
 
        mode: 0644
 

	
 
- hosts: clients
 
  become: true
 
  tasks:
roles/xmpp_server/tasks/main.yml
Show inline comments
 
---
 

	
 
# Ansible pre-requisites
 
# ======================
 

	
 
- name: Install Python apt bindings
 
  apt:
 
    name: python-apt
 

	
 
- name: Set-up the Debian backports repository
 
  template:
 
    src: backports.list.j2
 
    dest: /etc/apt/sources.list.d/backports.list
 
    owner: root
 
    group: root
 
    mode: 0644
 
  register: backports_repository_configuration
 

	
 
- name: Update apt cache if backports repository configuration changed (for immediate use)  # noqa 503
 
  # [503] Tasks that run when changed should likely be handlers
 
  #   Since apt_repository module is not reliable (does not deploy
 
  #   change when changing distro version etc), we have to use
 
  #   template instead, but this also means we need to trigger the apt
 
  #   cache reload by hand.
 
  apt:
 
    update_cache: true
 
  when: backports_repository_configuration.changed
 

	
 
- name: Configure package pins to backports for Prosody
 
  template:
 
    src: prosody_backports_pin.j2
 
    dest: /etc/apt/preferences.d/prosody
 
    owner: root
 
    group: root
 
    mode: 0644
 
# Deprecation
 
# ===========
 

	
 
- name: Drop directory for storing custom Prosody modules (deprecation)
 
- name: Drop directory for storing custom Prosody modules
 
  file:
 
    path: "/usr/local/lib/prosody/"
 
    state: absent
 
@@ -76,6 +56,45 @@
 
    repo: "deb http://packages.prosody.im/debian {{ ansible_distribution_release }} main"
 
    state: absent
 

	
 
# Remove the repository configuration file based on path as well, just
 
# to be on the safe side (in case the file was manually modified, and
 
# did not get detected properly by apt_repository module).
 
- name: Remove Prosody project-provided repository (double-tap)
 
  file:
 
    path: "/etc/apt/sources.list.d/packages_prosody_im_debian.list"
 
    state: absent
 

	
 

	
 
# Main implementation
 
# ===================
 

	
 
- name: Set-up the Debian backports repository
 
  template:
 
    src: backports.list.j2
 
    dest: /etc/apt/sources.list.d/backports.list
 
    owner: root
 
    group: root
 
    mode: 0644
 
  register: backports_repository_configuration
 

	
 
- name: Update apt cache if backports repository configuration changed (for immediate use)  # noqa 503
 
  # [503] Tasks that run when changed should likely be handlers
 
  #   Since apt_repository module is not reliable (does not deploy
 
  #   change when changing distro version etc), we have to use
 
  #   template instead, but this also means we need to trigger the apt
 
  #   cache reload by hand.
 
  apt:
 
    update_cache: true
 
  when: backports_repository_configuration.changed
 

	
 
- name: Configure package pins to backports for Prosody
 
  template:
 
    src: prosody_backports_pin.j2
 
    dest: /etc/apt/preferences.d/prosody
 
    owner: root
 
    group: root
 
    mode: 0644
 

	
 
- name: Install additional Prosody dependencies
 
  apt:
 
    name:
0 comments (0 inline, 0 general)