From 7ee57545ce555e0fad9f8ab0c6afc05a23ea72bd Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 20 Apr 2022 21:31:46 +0100 Subject: [PATCH] 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` --- bin/dotfiles | 2 +- main.yaml | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/dotfiles b/bin/dotfiles index 4878431..b2d4704 100755 --- a/bin/dotfiles +++ b/bin/dotfiles @@ -23,4 +23,4 @@ run_playbook() { clone_or_update_dotfiles install_dependencies -run_playbook +run_playbook "${@}" diff --git a/main.yaml b/main.yaml index afd2e35..4654491 100644 --- a/main.yaml +++ b/main.yaml @@ -2,13 +2,22 @@ - hosts: localhost tasks: - name: Set roles - set_fact: + ansible.builtin.set_fact: roles: "{{ default_roles | difference(exclude_roles | default([])) }}" + tags: + - always - name: Display roles - debug: "var=roles" + ansible.builtin.debug: "var=roles" + tags: + - always - name: Run roles - include_role: + ansible.builtin.include_role: name: "{{ item }}" + apply: + tags: + - "{{ item }}" with_items: "{{ roles }}" + tags: + - always