Skip to content

Commit

Permalink
refactor: improve filtering of deb assets, handle already installed p…
Browse files Browse the repository at this point in the history
…ackages.
  • Loading branch information
TerrorSquad committed Mar 1, 2024
1 parent d2c80c9 commit 2a6fc4c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions post-installation/tasks/install_github_asset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,34 @@
when: type == "deb"
block:
- name: Filter assets by deb type
set_fact:
ansible.builtin.set_fact:
deb_asset_url: "{{ github_release_info.json.assets | selectattr('name', 'search', 'deb') }}"

- name: Apply additional filters to deb assets (multiple only)
set_fact:
ansible.builtin.set_fact:
deb_asset_url: "{{ deb_asset_url
| selectattr('name', 'search', architecture_filter)
| rejectattr('name', 'search', excluded_os_filter) }}"
when: deb_asset_url | length > 1

- name: Download deb asset
ansible.builtin.get_url:
url: "{{ deb_asset_url | map(attribute='browser_download_url')| first }}"
url: "{{ deb_asset_url | map(attribute='browser_download_url') | first }}"
dest: "{{ github_asset_dest }}.deb"
mode: "0755"

- name: Install deb asset
ansible.builtin.apt:
deb: "{{ github_asset_dest }}.deb"
state: present
register: apt_output
failed_when: false

- name: Check if the deb asset was not installed
ansible.builtin.debug:
msg: "The package was not installed because a newer version is already installed."
when: apt_output is failed


- name: Download tar.gz asset {{ github_asset }}
when: type == "tar.gz"
Expand Down

0 comments on commit 2a6fc4c

Please sign in to comment.