From 76d3b54c8db57f12b611ca0fccdb80e99bd5aa29 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Tue, 27 Dec 2022 16:49:55 +0100 Subject: [PATCH] increase fault tolerancy for the master playbook add units apt packages --- library/rescue_role.yml | 8 ++++++++ playbooks/all.yml | 25 ++++++++++++++++--------- roles/system/tasks/main.yml | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 library/rescue_role.yml diff --git a/library/rescue_role.yml b/library/rescue_role.yml new file mode 100644 index 0000000..cf77e6e --- /dev/null +++ b/library/rescue_role.yml @@ -0,0 +1,8 @@ +# https://stackoverflow.com/a/55524120 +- name: Rescue role + block: + - include_role: + name: "{{ item_my_role }}" + rescue: + - set_fact: + failed_roles: "{{ failed_roles|default([]) + [ item_my_role ] }}" diff --git a/playbooks/all.yml b/playbooks/all.yml index 246e361..4668c94 100644 --- a/playbooks/all.yml +++ b/playbooks/all.yml @@ -2,12 +2,19 @@ hosts: self roles: - system - - zsh - - asdf - - neovim - - signal - - virtualbox - - vscodium - - syncthing - - strawberry - - nicotine + vars: + my_roles: + - zsh + - asdf + - neovim + - signal + - virtualbox + - vscodium + - syncthing + - strawberry + - nicotine + tasks: + - include_tasks: "../library/rescue_role.yml" + loop: "{{ my_roles }}" + loop_control: + loop_var: item_my_role diff --git a/roles/system/tasks/main.yml b/roles/system/tasks/main.yml index 578cac0..91d3f72 100644 --- a/roles/system/tasks/main.yml +++ b/roles/system/tasks/main.yml @@ -14,6 +14,7 @@ - gimp - tree - wireshark + - units - name: Install .gitconfig template: src: "{{ role_path }}/templates/.gitconfig.j2"