feat(*): allow for filtering the playbook by role

Allow for appending ansible-playbook arguments to the dotfiles script,
and automatically applying tags to the included roles.

For example:

`./bin/dotfiles --tags=neovim`
This commit is contained in:
Oliver Davies 2022-04-20 21:31:46 +01:00
parent 093df0ac09
commit 7ee57545ce
2 changed files with 13 additions and 4 deletions

View file

@ -23,4 +23,4 @@ run_playbook() {
clone_or_update_dotfiles clone_or_update_dotfiles
install_dependencies install_dependencies
run_playbook run_playbook "${@}"

View file

@ -2,13 +2,22 @@
- hosts: localhost - hosts: localhost
tasks: tasks:
- name: Set roles - name: Set roles
set_fact: ansible.builtin.set_fact:
roles: "{{ default_roles | difference(exclude_roles | default([])) }}" roles: "{{ default_roles | difference(exclude_roles | default([])) }}"
tags:
- always
- name: Display roles - name: Display roles
debug: "var=roles" ansible.builtin.debug: "var=roles"
tags:
- always
- name: Run roles - name: Run roles
include_role: ansible.builtin.include_role:
name: "{{ item }}" name: "{{ item }}"
apply:
tags:
- "{{ item }}"
with_items: "{{ roles }}" with_items: "{{ roles }}"
tags:
- always