--- # Install Meslo LG Nerd Font for the user/system - name: Determine target user ansible.builtin.set_fact: shell_user: "{{ shell_user | default( lookup('env','USER') ) }}" - name: Detect platform ansible.builtin.set_fact: is_macos: "{{ ansible_facts['os_family'] == 'Darwin' }}" - name: Install Meslo LG Nerd Font on macOS using Homebrew cask community.general.homebrew_cask: name: font-meslo-lg-nerd-font state: present when: is_macos become: true become_user: "{{ shell_user }}" - name: Ensure ~/.local/share/fonts exists for user ansible.builtin.file: path: "/home/{{ shell_user }}/.local/share/fonts" state: directory mode: '0755' owner: "{{ shell_user }}" recurse: yes when: not is_macos become: true - name: Clone Nerd Fonts repo (temporary) ansible.builtin.git: repo: https://github.com/ryanoasis/nerd-fonts.git dest: "/tmp/nerd-fonts" update: yes when: not is_macos become: true - name: Copy Meslo patched fonts to user fonts dir ansible.builtin.find: paths: "/tmp/nerd-fonts/patched-fonts/Meslo/Regular" patterns: "*Meslo*.ttf" register: meslo_files when: not is_macos - name: Install Meslo TTFs for user ansible.builtin.copy: src: "{{ item.path }}" dest: "/home/{{ shell_user }}/.local/share/fonts/{{ item.path | basename }}" remote_src: yes owner: "{{ shell_user }}" mode: '0644' loop: "{{ meslo_files.files }}" when: not is_macos and meslo_files.files | length > 0 become: true - name: Refresh font cache on Linux ansible.builtin.command: fc-cache -fv when: not is_macos become: true - name: Cleanup nerd-fonts clone ansible.builtin.file: path: /tmp/nerd-fonts state: absent when: not is_macos become: true