commit 114130d8f4676c347efa1321af5d4647b0fec38e Author: Kenneth Benzie (Benie) Date: Sun Nov 13 16:09:08 2022 +0000 temp! diff --git a/local.yaml b/local.yaml new file mode 100644 index 0000000..295826d --- /dev/null +++ b/local.yaml @@ -0,0 +1,48 @@ +--- +- hosts: localhost + + vars: + package_become: true + repos: + # - repo: git@code.infektor.net:config/kitty.git + # path: ~/.config/kitty + - repo: git@code.infektor.net:config/zsh.git + path: ~/.config/zsh + - repo: git@code.infektor.net:config/tmux.git + path: ~/.config/tmux + - repo: git@code.infektor.net:config/vim.git + path: ~/.config/nvim + - repo: git@code.infektor.net:config/git.git + path: ~/.config/git + - repo: git@code.infektor.net:config/python.git + path: ~/.config/python + + tasks: + - name: Clone config repos + git: + repo: '{{item.repo}}' + dest: '{{item.path}}' + version: master + with_items: '{{repos}}' + + - name: Set config repos user.email + git_config: + repo: '{{item.path}}' + scope: local + name: user.email + value: '{{item.email | default("benie@infektor.net")}}' + with_items: '{{repos}}' + + - block: + - name: Dynamically include tasks from config repos + include_tasks: + file: '{{config}}/tasks.yaml' + loop_control: + loop_var: config + with_items: '{{repos | map(attribute="path") | list}}' + tags: tasks + +- import_playbook: local/base-dirs.yaml +- import_playbook: local/fonts.yaml +- import_playbook: local/ferdi.yaml +- import_playbook: local/distrobox.yaml diff --git a/local/base-dirs.yaml b/local/base-dirs.yaml new file mode 100644 index 0000000..bdf9e6f --- /dev/null +++ b/local/base-dirs.yaml @@ -0,0 +1,22 @@ +--- +- hosts: localhost + + vars: + base_dirs: + - ~/.cache + - ~/.cache/local + - ~/.config + - ~/.local + - ~/.local/bin + - ~/.local/include + - ~/.local/lib + - ~/.local/share + - ~/.local/src + - ~/.local/state + + tasks: + - name: Create base directories + file: + state: directory + path: '{{item}}' + with_items: '{{base_dirs}}' diff --git a/local/distrobox.yaml b/local/distrobox.yaml new file mode 100644 index 0000000..c9d3d24 --- /dev/null +++ b/local/distrobox.yaml @@ -0,0 +1,21 @@ +--- +- hosts: localhost + + handlers: + - name: Install distrobox + command: + creates: ~/.local/bin/distrobox* + cmd: ~/.local/src/distrobox/install -p ~/.local/bin + + tasks: + - name: Install distrobox dependencies + become: true + apt: + name: podman + + - name: Clone distrobox repository + git: + repo: https://github.com/89luca89/distrobox.git + dest: ~/.local/src/distrobox + version: main + notify: Install distrobox diff --git a/local/ferdi.yaml b/local/ferdi.yaml new file mode 100644 index 0000000..9832195 --- /dev/null +++ b/local/ferdi.yaml @@ -0,0 +1,20 @@ +--- +- hosts: localhost + + handlers: + - name: Install Ferdi + become: true + apt: + deb: '~/.cache/local/ferdi_{{latest.json.name}}_amd64.deb' + + tasks: + - name: Get latest Ferdi release + uri: + url: https://api.github.com/repos/getferdi/ferdi/releases/latest + register: latest + + - name: Download latest Ferdi deb package + get_url: + url: 'https://github.com/getferdi/ferdi/releases/download/{{latest.json.tag_name}}/ferdi_{{latest.json.name}}_amd64.deb' + dest: '~/.cache/local/ferdi_{{latest.json.name}}_amd64.deb' + notify: Install Ferdi diff --git a/local/fonts.yaml b/local/fonts.yaml new file mode 100644 index 0000000..7cd4e11 --- /dev/null +++ b/local/fonts.yaml @@ -0,0 +1,58 @@ +--- +- hosts: localhost + + vars: + # jq: From all the items in the assets list, select the item + # with the name that starts with "OTF" and return that name. + otf_query: >- + .assets[] | select(.name | test("OTF.*")) | .name + # jq: As above but instead of returning the name return the browser + # download URL. + otf_url_query: >- + .assets[] | select(.name | test("OTF.*")) | + .browser_download_url + + handlers: + - name: Rebuild font cache + command: fc-cache -f + + tasks: + - name: Get latest Source Code Pro font release + uri: + url: https://api.github.com/repos/adobe-fonts/source-code-pro/releases/latest + register: latest + + - name: Set Source Code Pro font zip path + set_fact: + zip_path: '~/.cache/local/{{latest.json | moreati.jq.jq(otf_query)}}' + + - name: Download latest Source Code Pro zip + get_url: + url: '{{latest.json | moreati.jq.jq(otf_url_query)}}' + dest: '{{zip_path}}' + + - name: Extract Source Code Pro font zip + unarchive: + src: '{{zip_path}}' + dest: ~/.local/share/fonts + notify: Rebuild font cache + + - name: Get latest Source Sans font release + uri: + url: https://api.github.com/repos/adobe-fonts/source-sans-pro/releases/latest + register: latest + + - name: Set Source Sans font zip path + set_fact: + zip_path: '~/.cache/local/{{latest.json | moreati.jq.jq(otf_query)}}' + + - name: Download latest Source Sans font zip + get_url: + url: '{{latest.json | moreati.jq.jq(otf_url_query)}}' + dest: '{{zip_path}}' + + - name: Extract Source Sans font zip + unarchive: + src: '{{zip_path}}' + dest: ~/.local/share/fonts + notify: Rebuild font cache