From 7a2f301f4e2884140d89819ee47ac8d71780ed54 Mon Sep 17 00:00:00 2001 From: Kashim Aziz Date: Sun, 2 Jun 2024 15:45:26 +0100 Subject: [PATCH 1/2] Force update for newly installed brew --- roles/homebrew/tasks/main.yml | 7 ++++++- tests/uninstall-homebrew.sh | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/homebrew/tasks/main.yml b/roles/homebrew/tasks/main.yml index defe736..8066010 100644 --- a/roles/homebrew/tasks/main.yml +++ b/roles/homebrew/tasks/main.yml @@ -34,6 +34,11 @@ become: true when: "ansible_distribution_version is version('10.13', '<')" +- name: Check if homebrew already exists. + stat: + path: "{{ homebrew_brew_bin_path }}/brew" + register: pre_installed_brew + - name: Ensure Homebrew directory exists. file: path: "{{ homebrew_install_path }}" @@ -114,7 +119,7 @@ block: - name: Force update brew after installation. command: "{{ homebrew_brew_bin_path }}/brew update --force" - when: not homebrew_binary.stat.exists + when: not pre_installed_brew.stat.exists - name: Where is the cache? command: "{{ homebrew_brew_bin_path }}/brew --cache" diff --git a/tests/uninstall-homebrew.sh b/tests/uninstall-homebrew.sh index d6d4c96..40e1bf1 100755 --- a/tests/uninstall-homebrew.sh +++ b/tests/uninstall-homebrew.sh @@ -11,3 +11,4 @@ sudo ./uninstall.sh --force sudo rm -rf /usr/local/Homebrew sudo rm -rf /usr/local/Caskroom sudo rm -rf /usr/local/bin/brew +sudo rm -rf /opt/homebrew From e74f9a95ca97339a7499d8bf4f7d2c9e5a8292fd Mon Sep 17 00:00:00 2001 From: Kashim Aziz Date: Sun, 2 Jun 2024 15:45:53 +0100 Subject: [PATCH 2/2] Add conditional --no-restart flag to dock operations --- roles/dock/tasks/dock-add.yml | 12 ++++++++---- roles/dock/tasks/dock-position.yml | 4 +++- roles/dock/tasks/dock-remove.yml | 8 ++++++-- roles/dock/tasks/main.yml | 9 +++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/roles/dock/tasks/dock-add.yml b/roles/dock/tasks/dock-add.yml index b911ada..5d1ec01 100644 --- a/roles/dock/tasks/dock-add.yml +++ b/roles/dock/tasks/dock-add.yml @@ -15,14 +15,18 @@ tags: ['dock'] - name: Ensure Dock item {{ item.name | default(item) }} exists. - ansible.builtin.command: "dockutil --add '{{ item.path }}' --label '{{ item.name }}'" - when: dockitem_exists.rc >0 or + ansible.builtin.command: | + dockutil --add '{{ item.path }}' --label '{{ item.name }}' + {% if not ansible_loop.last %}--no-restart{% endif %} + when: dockitem_exists.rc > 0 or dockitem_exists.rc == 0 and current_section == 'recent-apps' tags: ['dock'] - name: Pause for 7 seconds between dock changes. ansible.builtin.pause: seconds: 7 - when: dockitem_exists.rc >0 or - dockitem_exists.rc == 0 and current_section == 'recent-apps' + when: + - dockitem_exists.rc > 0 or + dockitem_exists.rc == 0 and current_section == 'recent-apps' + - ansible_loop.last tags: ['dock'] diff --git a/roles/dock/tasks/dock-position.yml b/roles/dock/tasks/dock-position.yml index 5ddae05..d5a2a2b 100644 --- a/roles/dock/tasks/dock-position.yml +++ b/roles/dock/tasks/dock-position.yml @@ -12,5 +12,7 @@ - name: Move dock item to the correct position. ansible.builtin.command: - cmd: dockutil --move '{{ item.name | default(item) }}' --position '{{ item.pos }}' + cmd: | + dockutil --move '{{ item.name | default(item) }}' --position '{{ item.pos }}' + {% if not ansible_loop.last %}--no-restart{% endif %} when: current_position|int != item.pos|int diff --git a/roles/dock/tasks/dock-remove.yml b/roles/dock/tasks/dock-remove.yml index f979b9b..4f4d4e3 100644 --- a/roles/dock/tasks/dock-remove.yml +++ b/roles/dock/tasks/dock-remove.yml @@ -11,12 +11,16 @@ - name: Ensure Dock item {{ item }} is removed. ansible.builtin.command: - cmd: dockutil --remove '{{ item }}' + cmd: | + dockutil --remove '{{ item }}' + {% if not ansible_loop.last %}--no-restart{% endif %} when: dockitem_exists.rc == 0 tags: ['dock'] - name: Pause for 7 seconds between dock changes. ansible.builtin.pause: seconds: 7 - when: dockitem_exists.rc == 0 + when: + - dockitem_exists.rc == 0 + - ansible_loop.last tags: ['dock'] diff --git a/roles/dock/tasks/main.yml b/roles/dock/tasks/main.yml index a03f0ef..58f4e1f 100644 --- a/roles/dock/tasks/main.yml +++ b/roles/dock/tasks/main.yml @@ -11,11 +11,17 @@ - name: Remove configured Dock items. ansible.builtin.include_tasks: dock-remove.yml loop: "{{ dockitems_remove }}" + loop_control: + extended: true + extended_allitems: false tags: ['dock'] - name: Ensure required dock items exist. ansible.builtin.include_tasks: dock-add.yml loop: "{{ dockitems_persist }}" + loop_control: + extended: true + extended_allitems: false tags: ['dock'] - name: Ensure dock items are in correct position. @@ -24,4 +30,7 @@ - item.pos is defined - item.pos > 0 loop: "{{ dockitems_persist }}" + loop_control: + extended: true + extended_allitems: false tags: ['dock']