From 887eee43c78b929685a4244982161583d27d8a1d Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Mon, 16 May 2022 18:21:33 +0200 Subject: [PATCH] Fix package downgrading for non-{RedHat,Debian} systems Not all package install handlers implement the `allow_downgrade` option. For example, using Ansible >= 2.12 on Arch Linux would croak like: Unsupported parameters for (ansible.legacy.pacman) module: allow_downgrade. --- tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index f050dd6..91fceef 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,22 +5,22 @@ - include_tasks: setup-Debian.yml when: ansible_os_family == 'Debian' -- name: Install Docker (Ansible <2.12). +- name: Install Docker. package: name: "{{ docker_package }}" state: "{{ docker_package_state }}" notify: restart docker ignore_errors: "{{ ansible_check_mode }}" - when: "ansible_version.full is version_compare('2.12', '<')" + when: "ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian']" -- name: Install Docker (Ansible >=2.12). +- name: Install Docker (with downgrade option). package: name: "{{ docker_package }}" state: "{{ docker_package_state }}" allow_downgrade: true notify: restart docker ignore_errors: "{{ ansible_check_mode }}" - when: "ansible_version.full is version_compare('2.12', '>=')" + when: "ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']" - name: Ensure /etc/docker/ directory exists. file: