From d7696613f96b1c175de23763421177d0d79d93ab Mon Sep 17 00:00:00 2001 From: fkonradmain <88140888+fkonradmain@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:48:27 +0100 Subject: [PATCH] feat: added Linux Mint Support (#515) * feat: added Linux Mint Support * feat: added linuxmint test image, added meta information, added automatic resolution of apt repo codename * fix: fixed linter warnings * fix: introduced common.yaml as shared dependency among debian install and uninstall * fix: renamed apt-codename.yml dependency * Fix typo in apt-codename.yml --- .github/workflows/pull_request_target.yml | 1 + meta/main.yml | 5 ++++ tasks/debian/apt-codename.yml | 33 +++++++++++++++++++++++ tasks/debian/install.yml | 5 ++++ tasks/debian/uninstall.yml | 5 ++++ vars/main.yml | 6 +++-- 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tasks/debian/apt-codename.yml diff --git a/.github/workflows/pull_request_target.yml b/.github/workflows/pull_request_target.yml index 995ffe9b..aebe7760 100644 --- a/.github/workflows/pull_request_target.yml +++ b/.github/workflows/pull_request_target.yml @@ -31,6 +31,7 @@ jobs: - image: ghcr.io/artis3n/docker-rhel8-ansible:latest - image: ghcr.io/artis3n/docker-oraclelinux8-ansible:latest - image: geerlingguy/docker-ubuntu2404-ansible:latest + - image: ghcr.io/fkonradmain/docker-linuxmint22-ansible:latest - image: geerlingguy/docker-ubuntu2204-ansible:latest - image: geerlingguy/docker-ubuntu2004-ansible:latest - image: geerlingguy/docker-ubuntu1804-ansible:latest diff --git a/meta/main.yml b/meta/main.yml index 18d140a5..1d5899d1 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -46,6 +46,11 @@ galaxy_info: - "15.4" - "15.5" # - "15.6" + # Linux Mint not supported in schema + # https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json + # - name: LinuxMint + # versions: + # - "22" galaxy_tags: - tailscale diff --git a/tasks/debian/apt-codename.yml b/tasks/debian/apt-codename.yml new file mode 100644 index 00000000..d51f4072 --- /dev/null +++ b/tasks/debian/apt-codename.yml @@ -0,0 +1,33 @@ +--- +# Retrieve "ID_LIKE" from /etc/os-release +# ID_LIKE has the following values, depending on the operating system +# | OS | ID_LIKE | +# | Debian | -- does not exist -- | +# | Raspberry Pi OS | -- does not exist -- | +# | Proxmox | -- does not exist -- | +# | Devuan | "debian" | +# | Raspbian | "debian" | +# | Ubuntu | "debian" | +# | Pop!OS | "ubuntu debian" | +# | Linux Mint | "ubuntu debian" | +- name: Debian | Retrieve Apt ID_LIKE + check_mode: false + ansible.builtin.command: >- + awk -F= '/^ID_LIKE/ {print $2}' {{ ansible_distribution_file_path }} + register: apt_id_like + changed_when: false + +# Ubuntu and its derivatives all have a value called "UBUNTU_CODENAME" set in their "/etc/os-release" +# This value points to the actual ubuntu Version. +# Ansible does not pick up that value on setup. Usually it picks up "VERSION_CODENAME" +- name: Debian | Retrieve ubuntu_codename on Ubuntu derivatives + check_mode: false + ansible.builtin.command: >- + awk -F= '/^UBUNTU_CODENAME/ {print $2}' {{ ansible_distribution_file_path }} + register: ubuntu_codename + when: apt_id_like.stdout == '"ubuntu debian"' + changed_when: false + +- name: Debian | Set codename for apt + ansible.builtin.set_fact: + apt_codename: "{{ ubuntu_codename.stdout | default(ansible_distribution_release) }}" diff --git a/tasks/debian/install.yml b/tasks/debian/install.yml index 69bb76e8..8ae55e9f 100644 --- a/tasks/debian/install.yml +++ b/tasks/debian/install.yml @@ -1,4 +1,8 @@ --- +- name: Debian | Include apt codename generation tasks + ansible.builtin.include_tasks: + file: apt-codename.yml + - name: Debian | Apt Dependencies become: true ansible.builtin.apt: @@ -29,6 +33,7 @@ repo: "{{ tailscale_apt_deb }}" filename: "tailscale" state: present + codename: "{{ apt_codename }}" - name: Debian | Install Tailscale become: true diff --git a/tasks/debian/uninstall.yml b/tasks/debian/uninstall.yml index db5cfcef..915619a9 100644 --- a/tasks/debian/uninstall.yml +++ b/tasks/debian/uninstall.yml @@ -1,4 +1,8 @@ --- +- name: Debian | Include apt codename generation tasks + ansible.builtin.include_tasks: + file: apt-codename.yml + - name: Debian | Apt Dependencies become: true ansible.builtin.apt: @@ -17,6 +21,7 @@ ansible.builtin.apt_repository: repo: "{{ tailscale_apt_deb }}" state: absent + codename: "{{ apt_codename }}" - name: Debian | Remove Tailscale Signing Key from trusted.gpg become: true diff --git a/vars/main.yml b/vars/main.yml index 84d1e1eb..0ecf1859 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -6,6 +6,7 @@ tailscale_debian_family_distros: - Debian - Pop!_OS - OSMC + - "Linux Mint" tailscale_centos_family_distros: - CentOS @@ -36,12 +37,13 @@ tailscale_debian_distro: ubuntu: ubuntu debian: debian osmc: debian + "linux mint": ubuntu tailscale_apt_keyring_path: /usr/share/keyrings/tailscale-archive-keyring.gpg -tailscale_apt_deb: deb [signed-by={{ tailscale_apt_keyring_path }}] https://pkgs.tailscale.com/{{ release_stability | lower }}/{{ tailscale_debian_distro[ansible_distribution | lower] }} {{ ansible_distribution_release | lower }} main +tailscale_apt_deb: deb [signed-by={{ tailscale_apt_keyring_path }}] https://pkgs.tailscale.com/{{ release_stability | lower }}/{{ tailscale_debian_distro[ansible_distribution | lower] }} {{ apt_codename | lower }} main -tailscale_apt_signkey: https://pkgs.tailscale.com/{{ release_stability | lower }}/{{ tailscale_debian_distro[ansible_distribution | lower] }}/{{ ansible_distribution_release | lower }}.noarmor.gpg +tailscale_apt_signkey: https://pkgs.tailscale.com/{{ release_stability | lower }}/{{ tailscale_debian_distro[ansible_distribution | lower] }}/{{ apt_codename | lower }}.noarmor.gpg tailscale_yum_dependencies: - yum-utils