From 3c285bc6f51371c44b8048747fa6eea0c7759d07 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 27 Aug 2020 13:58:35 +0300 Subject: [PATCH] Install lsb-release on Debian distros if unavailable Certain more-minimal Debian installations may not have lsb-release installed, which makes the playbook fail. We need lsb-release on Debian, so that ansible_lsb could tell us if this is Debian or Raspbian. --- roles/matrix-base/tasks/server_base/setup.yml | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/roles/matrix-base/tasks/server_base/setup.yml b/roles/matrix-base/tasks/server_base/setup.yml index 2425c82b..64f461ef 100644 --- a/roles/matrix-base/tasks/server_base/setup.yml +++ b/roles/matrix-base/tasks/server_base/setup.yml @@ -3,11 +3,26 @@ - include_tasks: "{{ role_path }}/tasks/server_base/setup_centos.yml" when: ansible_distribution == 'CentOS' -- include_tasks: "{{ role_path }}/tasks/server_base/setup_debian.yml" - when: (ansible_os_family == 'Debian') and (ansible_lsb.id != 'Raspbian') +- block: + # ansible_lsb is only available if lsb-release is installed. + - name: Ensure lsb-release installed + apt: + name: + - lsb-release + state: present + update_cache: yes + register: lsb_release_installation_result -- include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml" - when: (ansible_os_family == 'Debian') and (ansible_lsb.id == 'Raspbian') + - name: Reread ansible_lsb facts if lsb-release got installed + setup: filter=ansible_lsb* + when: lsb_release_installation_result.changed + + - include_tasks: "{{ role_path }}/tasks/server_base/setup_debian.yml" + when: (ansible_os_family == 'Debian') and (ansible_lsb.id != 'Raspbian') + + - include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml" + when: (ansible_os_family == 'Debian') and (ansible_lsb.id == 'Raspbian') + when: ansible_os_family == 'Debian' - include_tasks: "{{ role_path }}/tasks/server_base/setup_archlinux.yml" when: ansible_distribution == 'Archlinux'