From df00529f8601e9b87bf3d16e4b06b7bda861eecb Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 1 Aug 2023 19:14:32 +0100 Subject: [PATCH] Use /etc/os-release to ID Ubuntu/Debian Ansible facts aren't always enough to determine if a distro is derived from Ubuntu or not, this is available from `/etc/os-release` when it contains `ID_LIKE="ubuntu debian"`. This patch uses `/etc/os-release` to correctly handle Ubuntu installations, e.g. PPA's, for all Ubuntu derived dirtros rather than just Ubuntu itself. --- roles/llvm/tasks/Debian.yaml | 12 ++++++++++++ roles/llvm/tasks/Linux Mint.yaml | 2 -- roles/llvm/tasks/Pop!_OS.yaml | 2 -- roles/llvm/tasks/main.yaml | 3 --- roles/neovim/tasks/Debian.yaml | 11 +++++++++-- 5 files changed, 21 insertions(+), 9 deletions(-) delete mode 100644 roles/llvm/tasks/Linux Mint.yaml delete mode 100644 roles/llvm/tasks/Pop!_OS.yaml diff --git a/roles/llvm/tasks/Debian.yaml b/roles/llvm/tasks/Debian.yaml index c93e6aa..9e3f9dc 100644 --- a/roles/llvm/tasks/Debian.yaml +++ b/roles/llvm/tasks/Debian.yaml @@ -1,5 +1,17 @@ --- +- name: slurp /etc/os-release + slurp: + src: /etc/os-release + register: os_release_slurp +- set_fact: + os_release: "{{ os_release_slurp.content | + b64decode | trim() | replace('=', ': ') | from_yaml }}" + +- include_tasks: Ubuntu.yaml + when: "'ID_LIKE' in os_release and os_release.ID_LIKE == 'ubuntu debian'" + - name: install apt packages + when: "'ID_LIKE' not in os_release" become: true apt: name: diff --git a/roles/llvm/tasks/Linux Mint.yaml b/roles/llvm/tasks/Linux Mint.yaml deleted file mode 100644 index 53957fa..0000000 --- a/roles/llvm/tasks/Linux Mint.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- include_tasks: Ubuntu.yaml diff --git a/roles/llvm/tasks/Pop!_OS.yaml b/roles/llvm/tasks/Pop!_OS.yaml deleted file mode 100644 index 53957fa..0000000 --- a/roles/llvm/tasks/Pop!_OS.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- include_tasks: Ubuntu.yaml diff --git a/roles/llvm/tasks/main.yaml b/roles/llvm/tasks/main.yaml index b5ebbe1..6853678 100644 --- a/roles/llvm/tasks/main.yaml +++ b/roles/llvm/tasks/main.yaml @@ -1,5 +1,2 @@ --- - include_tasks: '{{ansible_os_family}}.yaml' - when: ansible_os_family in ['Darwin', 'Windows'] -- include_tasks: '{{ansible_distribution}}.yaml' - when: ansible_os_family not in ['Darwin', 'Windows'] diff --git a/roles/neovim/tasks/Debian.yaml b/roles/neovim/tasks/Debian.yaml index b642ef6..fec63dc 100644 --- a/roles/neovim/tasks/Debian.yaml +++ b/roles/neovim/tasks/Debian.yaml @@ -1,7 +1,14 @@ --- +- name: slurp /etc/os-release + slurp: + src: /etc/os-release + register: os_release_slurp +- set_fact: + os_release: "{{ os_release_slurp.content | + b64decode | trim() | replace('=', ': ') | from_yaml }}" + - name: add neovim stable ppa - when: ansible_distribution == 'Ubuntu' and - ansible_distribution_version == '20.04' + when: "'ID_LIKE' in os_release and os_release.ID_LIKE == 'ubuntu debian'" become: true apt_repository: repo: ppa:neovim-ppa/stable