Skip to content

Commit

Permalink
Merge pull request #108 from k-aziz/master
Browse files Browse the repository at this point in the history
Only restart dock between commands #53
  • Loading branch information
geerlingguy authored Jun 3, 2024
2 parents a32170b + e74f9a9 commit 7f5765b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
12 changes: 8 additions & 4 deletions roles/dock/tasks/dock-add.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
4 changes: 3 additions & 1 deletion roles/dock/tasks/dock-position.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions roles/dock/tasks/dock-remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
9 changes: 9 additions & 0 deletions roles/dock/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -24,4 +30,7 @@
- item.pos is defined
- item.pos > 0
loop: "{{ dockitems_persist }}"
loop_control:
extended: true
extended_allitems: false
tags: ['dock']
7 changes: 6 additions & 1 deletion roles/homebrew/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/uninstall-homebrew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7f5765b

Please sign in to comment.