Add Linux support to fonts role
This commit is contained in:
parent
b560f9c7d9
commit
1749c78364
3
roles/fonts/handlers/main.yaml
Normal file
3
roles/fonts/handlers/main.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- name: refresh font cache
|
||||||
|
command: fc-cache
|
56
roles/fonts/tasks/Linux.yaml
Normal file
56
roles/fonts/tasks/Linux.yaml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
- name: stat version file
|
||||||
|
stat:
|
||||||
|
path: '{{ansible_env.HOME}}/.local/share/fonts/CaskaydiaCove.version'
|
||||||
|
register: version_file
|
||||||
|
|
||||||
|
- name: slurp version
|
||||||
|
when: version_file.stat.exists
|
||||||
|
slurp:
|
||||||
|
path: '{{ansible_env.HOME}}/.local/share/fonts/CaskaydiaCove.version'
|
||||||
|
register: version_slurp
|
||||||
|
|
||||||
|
- when: version_file.stat.exists
|
||||||
|
set_fact:
|
||||||
|
version: '{{version_slurp.content | b64decode}}'
|
||||||
|
|
||||||
|
- name: get latest release
|
||||||
|
uri:
|
||||||
|
url: https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest
|
||||||
|
register: latest
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
needs_installed:
|
||||||
|
'{{ not version_file.stat.exists or version.strip() != latest.json.tag_name }}'
|
||||||
|
asset: '{{ latest.json.assets | to_json | from_json |
|
||||||
|
json_query("[?contains(name, `CascadiaCode.zip`)] | [0]") }}'
|
||||||
|
|
||||||
|
- name: create user fonts directory
|
||||||
|
when: needs_installed
|
||||||
|
file:
|
||||||
|
path: '{{ansible_env.HOME}}/.local/share/fonts'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: download Caskaydia Cove Nerd Font archive
|
||||||
|
when: needs_installed
|
||||||
|
get_url:
|
||||||
|
url: '{{asset.browser_download_url}}'
|
||||||
|
dest: '{{ansible_env.HOME}}/.local/share/fonts/tmp.zip'
|
||||||
|
|
||||||
|
- name: install Caskaydia Cove Nerd Font
|
||||||
|
when: needs_installed
|
||||||
|
unarchive:
|
||||||
|
src: '{{ansible_env.HOME}}/.local/share/fonts/tmp.zip'
|
||||||
|
dest: '{{ansible_env.HOME}}/.local/share/fonts'
|
||||||
|
notify: refresh font cache
|
||||||
|
|
||||||
|
- name: write version file
|
||||||
|
copy:
|
||||||
|
content: '{{latest.json.tag_name}}'
|
||||||
|
dest: '{{ansible_env.HOME}}/.local/share/fonts/CaskaydiaCove.version'
|
||||||
|
|
||||||
|
- name: remove Caskaydia Cove Nerd Font archive
|
||||||
|
when: needs_installed
|
||||||
|
file:
|
||||||
|
path: '{{ansible_env.HOME}}/.local/share/fonts/tmp.zip'
|
||||||
|
state: absent
|
@ -1,2 +1,5 @@
|
|||||||
---
|
---
|
||||||
- include_tasks: '{{ansible_os_family}}.yaml'
|
- when: ansible_os_family == 'Darwin'
|
||||||
|
include_tasks: 'Darwin.yaml'
|
||||||
|
- when: ansible_os_family != 'Darwin' and ansible_os_family != 'Windows'
|
||||||
|
include_tasks: 'Linux.yaml'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user