Skip to content

Commit

Permalink
feat(fonts): add fonts role
Browse files Browse the repository at this point in the history
  • Loading branch information
donhector committed Dec 11, 2021
1 parent 28c217e commit 2e25103
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 22 deletions.
24 changes: 22 additions & 2 deletions donhector/workstation/roles/fonts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@ lint:
test:
@molecule test --all

## Run just the role
## Spin up an instance
.PHONY: create
create:
@molecule create

## Converge (run the playbook)
.PHONY: converge
converge: create
@molecule converge

## Log into the running instance
.PHONY: login
login:
@molecule login

## Destroy the instance
.PHONY: destroy
destroy:
@molecule destroy

.PHONY: run
## Run the playbook locally without molecule
run:
@molecule converge
@ansible-playbook -v tests/test.yml -i tests/inventory
4 changes: 2 additions & 2 deletions donhector/workstation/roles/fonts/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Role Name
fonts
=========

Install fonts
Expand All @@ -11,7 +11,7 @@ None
Role Variables
--------------

`fonts_packages`: list of font packages to install from APT
`fonts_packages`: list of font packages to install

Dependencies
------------
Expand Down
4 changes: 0 additions & 4 deletions donhector/workstation/roles/fonts/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
---
# defaults file for fonts
fonts_packages:
- fonts-firacode
- fonts-powerline
- fonts-cascadia-code
4 changes: 2 additions & 2 deletions donhector/workstation/roles/fonts/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
galaxy_info:
author: donhector
role_name: fonts
description: font installation
author: donhector
company: darkenv.com
role_name: fonts

license: MIT

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
- name: Converge
hosts: all
become: true

pre_tasks:
- name: Update apt cache.
become: true
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'

tasks:
- name: "Include fonts"
include_role:
name: "fonts"
roles:
- role: donhector.fonts
40 changes: 38 additions & 2 deletions donhector/workstation/roles/fonts/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
---
dependency:
name: galaxy

driver:
name: docker

lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: instance

- name: ubuntu2004
image: ${MOLECULE_DISTRO:-geerlingguy/docker-ubuntu2004-ansible:latest}
# Needed for systemd
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd}
Expand All @@ -17,10 +21,42 @@ platforms:
capabilities:
- SYS_ADMIN
pre_build_image: true

- name: debian9
image: ${MOLECULE_DISTRO:-geerlingguy/docker-debian9-ansible:latest}
# Needed for systemd
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
pre_build_image: true

- name: debian10
image: ${MOLECULE_DISTRO:-geerlingguy/docker-debian10-ansible:latest}
# Needed for systemd
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
pre_build_image: true

- name: debian11
image: ${MOLECULE_DISTRO:-geerlingguy/docker-debian11-ansible:latest}
# Needed for systemd
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
pre_build_image: true

provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

verifier:
name: ansible
enabled: true
enabled: false
16 changes: 14 additions & 2 deletions donhector/workstation/roles/fonts/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
---
# tasks file for fonts

- name: Install fonts
- name: Load OS and distro specific vars.
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"

# For comparing version numbers, refer to
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#comparing-versions

- name: Install fonts (Debian/Ubuntu)
become: true
ansible.builtin.apt:
name: '{{ fonts_packages }}'
state: present
update_cache: false
update_cache: true
cache_valid_time: 600
when: ansible_os_family == 'Debian'
2 changes: 1 addition & 1 deletion donhector/workstation/roles/fonts/tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
vars:
ansible_connection: local
roles:
- {role: fonts, become: true}
- { role: donhector.fonts }
4 changes: 4 additions & 0 deletions donhector/workstation/roles/fonts/vars/Debian-10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fonts_packages:
- fonts-firacode
- fonts-powerline
3 changes: 3 additions & 0 deletions donhector/workstation/roles/fonts/vars/Debian-9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
fonts_packages:
- fonts-powerline
5 changes: 5 additions & 0 deletions donhector/workstation/roles/fonts/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fonts_packages:
- fonts-firacode
- fonts-powerline
- fonts-cascadia-code
2 changes: 0 additions & 2 deletions donhector/workstation/roles/fonts/vars/main.yml

This file was deleted.

0 comments on commit 2e25103

Please sign in to comment.