Files
ansible/roles/ubuntu/tasks/github_releases.yml
Tuan-Dat Tran 39a2925bcd feat(ubuntu): Refactor package installation, streamline GitHub deb installs
- Added 'become_password_file' to 'ansible.cfg' for privilege escalation handling.
- Removed separate installation tasks for 'atuin', 'eurkey', 'ghostty', 'git-delta', 'ripgrep', 'starship', 'veracrypt', and 'pacstall', consolidating them into 'curl.yml' and 'git_deb.yml'.
- Introduced 'git_deb.yml' for handling GitHub '.deb' installations dynamically using 'github_deb' variable.
- Improved error handling and pipe safety in curl-based installations ('set -o pipefail').
- Set proper permissions ('mode: 0600') for downloaded files in 'remove_ubuntu_banner.yml' and 'fira_code_fonts.yml'.
- Refactored 'github_releases.yml' to allow optional 'v' prefix handling in 'tag_name'.
- Updated 'main.yml' to remove redundant installations and streamline execution.
- Defined 'github_deb' list in 'vars/main.yml' to manage '.deb' package downloads dynamically.

These changes enhance maintainability, reduce redundancy, and improve package installation flexibility.

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2025-02-17 18:19:08 +01:00

44 lines
1.3 KiB
YAML

---
- name: "Get latest version: {{ project.name }}"
ansible.builtin.shell: |
set -o pipefail && curl -s "https://api.github.com/repos/{{ project.repo }}/releases/latest" |
grep -Po '"tag_name": *"v?\K[^"]*'
args:
executable: /usr/bin/bash
register: project_version
changed_when: false
- name: "Set version: {{ project_version }}"
ansible.builtin.set_fact:
project_version: "{{ project_version.stdout }}"
- name: "Download: {{ project.name }}"
ansible.builtin.get_url:
url: "https://github.com/{{ project.repo }}/releases/download/v{{ project_version }}/{{ project.name }}_{{ project_version }}_Linux_x86_64.tar.gz"
dest: "/tmp/{{ project.name }}.tar.gz"
mode: "0666"
- name: "Extract binary: {{ project.name }}"
ansible.builtin.unarchive:
src: "/tmp/{{ project.name }}.tar.gz"
dest: "/tmp"
creates: "/tmp/{{ project.name }}"
remote_src: true
- name: "Install: {{ project.name }}"
ansible.builtin.copy:
src: "/tmp/{{ project.name }}"
dest: "/usr/local/bin/{{ project.name }}"
mode: "0755"
become: true
- name: Remove tar.gz and binary
ansible.builtin.file:
path: "{{ loop_file_name }}"
state: absent
loop:
- "/tmp/{{ project.name }}.tar.gz"
- "/tmp/{{ project.name }}"
loop_control:
loop_var: loop_file_name