0
0
vps-set-up-playbook/roles/install-nvim/tasks/main.yml

114 lines
2.7 KiB
YAML
Raw Normal View History

2024-10-29 18:05:22 +08:00
---
- name: Set architecture specific variables
set_fact:
arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else '64' }}"
- name: Create temp directory
file:
path: /tmp/temp
state: directory
- name: Fetch latest nvim version
uri:
url: "https://api.github.com/repos/neovim/neovim/releases/latest"
return_content: yes
register: nvim_release
- name: Extract nvim version from response
set_fact:
nvim_version: "{{ nvim_release.content | from_json | json_query('tag_name') | regex_replace('^v', '') }}"
- name: Download nvim tar.gz
get_url:
url: "https://github.com/neovim/neovim/releases/download/v{{ nvim_version }}/nvim-linux{{ arch }}.tar.gz"
dest: /tmp/temp/nvim.tar.gz
when:
- arch == "64"
- name: Download nvim tar.gz to control node
get_url:
url: "https://gitlab.b-data.ch/neovim/neovim/-/releases/v{{ nvim_version }}/downloads/builds/nvim-linux-{{ arch }}.tar.gz"
dest: "{{ role_path }}/files/nvim-linux-{{ arch }}.tar.gz"
delegate_to: desktop
run_once: true
when:
- arch == "arm64"
- name: Copy nvim tar.gz to remote nodes
copy:
src: "{{ role_path }}/files/nvim-linux-{{ arch }}.tar.gz"
dest: /tmp/temp/nvim.tar.gz
when:
- arch == "arm64"
#- name: Download nvim tar.gz
# get_url:
# url: "https://gitlab.b-data.ch/neovim/neovim/-/releases/v{{ nvim_version }}/downloads/builds/nvim-linux-{{ arch }}.tar.gz"
# dest: /tmp/temp/nvim.tar.gz
# when:
# - arch == "arm64"
- name: Extract nvim
unarchive:
src: /tmp/temp/nvim.tar.gz
dest: /tmp/temp/
remote_src: yes
- name: Copy nvim to /usr/local/bin
copy:
src: /tmp/temp/nvim-linux{{ arch }}/bin/
dest: /usr/local/bin/
mode: '0755'
remote_src: yes
when:
- arch == "64"
- name: Copy nvim to /usr/local/lib
copy:
src: /tmp/temp/nvim-linux{{ arch }}/lib/
dest: /usr/local/lib/
mode: '0755'
remote_src: yes
when:
- arch == "64"
- name: Copy nvim to /usr/local/share
copy:
src: /tmp/temp/nvim-linux{{ arch }}/share/
dest: /usr/local/share/
mode: '0755'
remote_src: yes
when:
- arch == "64"
- name: Copy nvim to /usr/local/bin
copy:
src: /tmp/temp/nvim-linux-{{ arch }}/bin/
dest: /usr/local/bin/
mode: '0755'
remote_src: yes
when:
- arch == "arm64"
- name: Copy nvim to /usr/local/lib
copy:
src: /tmp/temp/nvim-linux-{{ arch }}/lib/
dest: /usr/local/lib/
mode: '0755'
remote_src: yes
when:
- arch == "arm64"
- name: Copy nvim to /usr/local/share
copy:
src: /tmp/temp/nvim-linux-{{ arch }}/share/
dest: /usr/local/share/
mode: '0755'
remote_src: yes
when:
- arch == "arm64"
- name: Remove temp directory
file:
path: /tmp/temp
state: absent