feat(ubuntu): Install github releases dynamically
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
37
roles/ubuntu/tasks/github_releases.yml
Normal file
37
roles/ubuntu/tasks/github_releases.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
- name: "Get latest version: {{ project.name }}"
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
curl -s "https://api.github.com/repos/{{ project.repo }}/releases/latest" |
|
||||||
|
grep -Po '"tag_name": *"v\K[^"]*'
|
||||||
|
register: project_version
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: "Download: {{ project.name }}"
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "https://github.com/{{ project.repo }}/releases/download/v{{ project_version.stdout }}/{{ project.name }}_{{ project_version.stdout }}_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
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Get latest lazygit version
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" |
|
|
||||||
grep -Po '"tag_name": *"v\K[^"]*'
|
|
||||||
register: lazygit_version
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Download lazygit tar.gz
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: "https://github.com/jesseduffield/lazygit/releases/download/v{{ lazygit_version.stdout }}/lazygit_{{ lazygit_version.stdout }}_Linux_x86_64.tar.gz"
|
|
||||||
dest: "/tmp/lazygit.tar.gz"
|
|
||||||
|
|
||||||
- name: Extract lazygit binary
|
|
||||||
ansible.builtin.unarchive:
|
|
||||||
src: "/tmp/lazygit.tar.gz"
|
|
||||||
dest: "/tmp"
|
|
||||||
creates: "/tmp/lazygit"
|
|
||||||
remote_src: true
|
|
||||||
|
|
||||||
- name: Install lazygit
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "/tmp/lazygit"
|
|
||||||
dest: /usr/local/bin/lazygit
|
|
||||||
mode: "0755"
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Remove lazygit tar.gz and binary
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
loop:
|
|
||||||
- "/tmp/lazygit.tar.gz"
|
|
||||||
- "/tmp/lazygit"
|
|
||||||
@@ -31,8 +31,11 @@
|
|||||||
ansible.builtin.import_tasks: protonvpn.yml
|
ansible.builtin.import_tasks: protonvpn.yml
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
ansible.builtin.import_tasks: docker.yml
|
ansible.builtin.import_tasks: docker.yml
|
||||||
- name: Install lazygit
|
- name: "Install {{ item }}"
|
||||||
ansible.builtin.import_tasks: lazygit.yml
|
ansible.builtin.include_tasks: github_releases.yml
|
||||||
|
vars:
|
||||||
|
project: "{{ item }}"
|
||||||
|
loop: "{{ github_releases }}"
|
||||||
- name: Install ripgrep
|
- name: Install ripgrep
|
||||||
ansible.builtin.import_tasks: ripgrep.yml
|
ansible.builtin.import_tasks: ripgrep.yml
|
||||||
- name: Install Vagrant
|
- name: Install Vagrant
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ apt_dependencies:
|
|||||||
- xsel
|
- xsel
|
||||||
|
|
||||||
apt_tools:
|
apt_tools:
|
||||||
|
- audacity
|
||||||
- keepassxc
|
- keepassxc
|
||||||
- obs-studio
|
- obs-studio
|
||||||
- p7zip
|
- p7zip
|
||||||
@@ -84,3 +85,9 @@ docker:
|
|||||||
apt_release_channel: "stable"
|
apt_release_channel: "stable"
|
||||||
|
|
||||||
aarch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
|
aarch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
|
||||||
|
|
||||||
|
github_releases:
|
||||||
|
- name: lazygit
|
||||||
|
repo: jesseduffield/lazygit
|
||||||
|
- name: lazydocker
|
||||||
|
repo: jesseduffield/lazydocker
|
||||||
|
|||||||
Reference in New Issue
Block a user