Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Forked from mkubenka/sparsecheckout.yml
Last active September 15, 2023 03:43
Show Gist options
  • Save pythoninthegrass/49182ea28ede2bc4749e591d82ee76e8 to your computer and use it in GitHub Desktop.
Save pythoninthegrass/49182ea28ede2bc4749e591d82ee76e8 to your computer and use it in GitHub Desktop.
Install hack nerd-font via ansible shell out to git sparse-checkout
# code: language=ansible
---
- hosts: localhost
connection: local
gather_facts: true
any_errors_fatal: true
vars:
base_dir: "{{ home_dir }}/git/nerd-fonts"
repo_url: https://github.com/ryanoasis/nerd-fonts.git
version: master
sparse_checkout: patched-fonts/Hack
pre_tasks:
- name: Get running ansible user
ansible.builtin.set_fact:
local_user: "{{ lookup('env', 'USER') }}"
home_dir: "{{ lookup('env', 'HOME') }}"
work_dir: "{{ playbook_dir | dirname }}"
cacheable: true
tasks:
- name: Delete repo directory if it exists
ansible.builtin.file:
path: "{{ base_dir }}"
state: absent
- name: Create repo directory
ansible.builtin.file:
path: "{{ base_dir }}"
state: directory
owner: "{{ local_user }}"
group: "{{ local_user }}"
mode: 0755
- name: Clone repo
ansible.builtin.shell: |
git clone --filter=blob:none --sparse "{{ repo_url }}" "{{ base_dir }}"
cd "{{ base_dir }}"
git sparse-checkout add "{{ sparse_checkout }}"
become: true
become_user: "{{ local_user }}"
- name: Install font
ansible.builtin.shell: |
cd "{{ base_dir }}"
./install.sh Hack
become: true
become_user: "{{ local_user }}"
@pythoninthegrass
Copy link
Author

Kudos to @mkubenka for the inspiration! Small part of a more holistic config management repo for the framework laptop; turns out it works pretty well for general fedora too 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment