summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-04-23 17:03:49 +0200
committerAhmed Abdelhalim <[email protected]>2026-04-23 17:04:18 +0200
commit2496520d9ea994140870a5059cbf5f4da11f9c0f (patch)
treef72c1d7c22078ad056728bcbd8d478534348581b
parent438e8629828f1c45743deb306580af6193a294bd (diff)
Refactor font role to install missing alacritty nerd fonts on ubuntu
-rw-r--r--roles/font/tasks/install-google-fonts.yml34
-rw-r--r--roles/font/tasks/install-nerd-fonts.yml19
-rw-r--r--roles/font/tasks/main.yml41
-rw-r--r--roles/font/vars/archlinux.yml2
-rw-r--r--roles/font/vars/debian.yml4
5 files changed, 65 insertions, 35 deletions
diff --git a/roles/font/tasks/install-google-fonts.yml b/roles/font/tasks/install-google-fonts.yml
new file mode 100644
index 00000000..d287dce6
--- /dev/null
+++ b/roles/font/tasks/install-google-fonts.yml
@@ -0,0 +1,34 @@
+---
+- name: "Ensure Google Fonts directory exists"
+ become: true
+ ansible.builtin.file:
+ path: "/usr/share/fonts/google-fonts"
+ state: "directory"
+ mode: "0755"
+
+- name: "Fetch Google Fonts file references"
+ ansible.builtin.uri:
+ url: "https://fonts.google.com/download/list?family={{ item | urlencode }}"
+ return_content: true
+ register: font_google_fonts_metadata
+ loop: "{{ font_google_font_families }}"
+ no_log: "{{ ansible_verbosity == 0 }}"
+
+- name: "Parse Google Fonts file references"
+ vars:
+ font_response_json: "{{ item.content | regex_replace('^[^{]+', '') | from_json }}"
+ font_file_refs: "{{ font_response_json.manifest.fileRefs | default([]) }}"
+ ansible.builtin.set_fact:
+ font_google_font_files: "{{ font_google_font_files | default([]) + font_file_refs }}"
+ loop: "{{ font_google_fonts_metadata.results }}"
+ no_log: "{{ ansible_verbosity == 0 }}"
+
+- name: "Install Google Fonts"
+ become: true
+ ansible.builtin.get_url:
+ url: "{{ item.url }}"
+ dest: "/usr/share/fonts/google-fonts/{{ item.filename }}"
+ mode: "0644"
+ loop: "{{ font_google_font_files | default([]) }}"
+ notify:
+ - "Update font-cache"
diff --git a/roles/font/tasks/install-nerd-fonts.yml b/roles/font/tasks/install-nerd-fonts.yml
new file mode 100644
index 00000000..563d1806
--- /dev/null
+++ b/roles/font/tasks/install-nerd-fonts.yml
@@ -0,0 +1,19 @@
+---
+- name: "Ensure Nerd Fonts directory exists"
+ become: true
+ ansible.builtin.file:
+ path: "/usr/share/fonts/nerd-fonts/{{ item.name }}"
+ state: "directory"
+ mode: "0755"
+ loop: "{{ font_nerd_fonts }}"
+
+- name: "Download and extract Nerd Fonts"
+ become: true
+ ansible.builtin.unarchive:
+ src: "https://github.com/ryanoasis/nerd-fonts/releases/download/v{{ item.version }}/{{ item.name }}.tar.xz"
+ dest: "/usr/share/fonts/nerd-fonts/{{ item.name }}"
+ remote_src: true
+ creates: "/usr/share/fonts/nerd-fonts/{{ item.name }}/{{ item.name }}NerdFont-Regular.ttf"
+ loop: "{{ font_nerd_fonts }}"
+ notify:
+ - "Update font-cache"
diff --git a/roles/font/tasks/main.yml b/roles/font/tasks/main.yml
index bdeb3657..119e222f 100644
--- a/roles/font/tasks/main.yml
+++ b/roles/font/tasks/main.yml
@@ -45,39 +45,10 @@
state: "link"
loop: "{{ font_presets }}"
-- name: "Ensure Google Fonts directory exists"
- become: true
- ansible.builtin.file:
- path: "/usr/share/fonts/google-fonts"
- state: "directory"
- mode: "0755"
-
-- name: "Install Google fonts"
- when: "font_google_font_families | length > 0"
- block:
- - name: "Fetch Google Fonts file references"
- ansible.builtin.uri:
- url: "https://fonts.google.com/download/list?family={{ item | urlencode }}"
- return_content: true
- register: font_google_fonts_metadata
- loop: "{{ font_google_font_families }}"
- no_log: "{{ ansible_verbosity == 0 }}"
-
- - name: "Parse Google Fonts file references"
- vars:
- font_response_json: "{{ item.content | regex_replace('^[^{]+', '') | from_json }}"
- font_file_refs: "{{ font_response_json.manifest.fileRefs | default([]) }}"
- ansible.builtin.set_fact:
- font_google_font_files: "{{ font_google_font_files | default([]) + font_file_refs }}"
- loop: "{{ font_google_fonts_metadata.results }}"
- no_log: "{{ ansible_verbosity == 0 }}"
+- name: "Install Nerd Fonts"
+ when: "font_nerd_fonts | default([]) | length > 0"
+ ansible.builtin.include_tasks: "install-nerd-fonts.yml"
- - name: "Install Google Fonts"
- become: true
- ansible.builtin.get_url:
- url: "{{ item.url }}"
- dest: "/usr/share/fonts/google-fonts/{{ item.filename }}"
- mode: "0644"
- loop: "{{ font_google_font_files | default([]) }}"
- notify:
- - "Update font-cache"
+- name: "Install Google Fonts"
+ when: "font_google_font_families | default([]) | length > 0"
+ ansible.builtin.include_tasks: "install-google-fonts.yml"
diff --git a/roles/font/vars/archlinux.yml b/roles/font/vars/archlinux.yml
index 2de675d6..e3d27fff 100644
--- a/roles/font/vars/archlinux.yml
+++ b/roles/font/vars/archlinux.yml
@@ -5,6 +5,8 @@ font_packages:
- "noto-fonts"
- "noto-fonts-emoji"
+font_nerd_fonts: []
+
font_google_font_families:
- "PT Sans"
diff --git a/roles/font/vars/debian.yml b/roles/font/vars/debian.yml
index 73714a56..a028953a 100644
--- a/roles/font/vars/debian.yml
+++ b/roles/font/vars/debian.yml
@@ -10,6 +10,10 @@ font_packages:
font_google_font_families: []
+font_nerd_fonts:
+ - name: "JetBrainsMono"
+ version: "3.2.1"
+
font_presets:
- src: "/usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf"
dest: "/etc/fonts/conf.d/10-sub-pixel-rgb.conf"