This commit is contained in:
Kenneth Benzie 2022-11-13 16:09:08 +00:00
commit 114130d8f4
5 changed files with 169 additions and 0 deletions

48
local.yaml Normal file
View File

@ -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

22
local/base-dirs.yaml Normal file
View File

@ -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}}'

21
local/distrobox.yaml Normal file
View File

@ -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

20
local/ferdi.yaml Normal file
View File

@ -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

58
local/fonts.yaml Normal file
View File

@ -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