Skip to content

Commit

Permalink
Merge pull request #7 from mraerino/refactor_checkmode
Browse files Browse the repository at this point in the history
Refactor checkmode
  • Loading branch information
fubarhouse authored Oct 16, 2017
2 parents 302bbdd + ce55d34 commit 481a0a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---
# handlers file for fubarhouse.macdock
- name: restart dock
shell: "/usr/bin/killall Dock"
23 changes: 12 additions & 11 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
with_items: "{{ dockitems_disabled }}"
changed_when: false
failed_when: false
check_mode: no
when: dockitems_remove_all|bool == false

- name: Dockutil | Remove all dock items
Expand All @@ -20,44 +21,44 @@

- name: Dockutil | Remove all unwanted dock items
shell: "dockutil --remove '{{ item.item }}' --no-restart"
register: removed_items_task
with_items: "{{ dockutil_removeditems.results }}"
loop_control:
label: "{{item.item}}"
when:
- dockitems_remove_all|bool == false
- (item.item ~ " was found in persistent-apps") in item.stdout
notify: restart dock

- name: Dockutil | Get information on configured setup
shell: "dockutil --find '{{ item.name }}'"
register: dockutil_newdata
with_items: "{{ dockitems_enabled }}"
changed_when: false
failed_when: false
check_mode: no

- name: Dockutil | Adding items
shell: "dockutil --add '{{ item.item.path }}' --position {{ item.item.pos }} --no-restart"
register: added_items_task
with_items: "{{ dockutil_newdata.results }}"
loop_control:
label: "{{item.item}}"
when: (item.item.name ~ " was not found in") in item.stdout
notify: restart dock

- name: Dockutil | Get information on current setup
shell: "dockutil --find '{{ item.name }}'"
register: dockutil_currdata
with_items: "{{ dockitems_enabled }}"
changed_when: false
failed_when: false
check_mode: no

- name: Dockutil | Moving items
shell: "dockutil --move '{{ item.item.name }}' --position {{ item.item.pos }} --no-restart"
register: moved_items_task
with_items: "{{ dockutil_currdata.results }}"
loop_control:
label: "{{item.item}}"
when:
- (item.item.name ~ " was found in persistent-apps at slot " ~ item.item.pos ~ " in") not in item.stdout
- (item.item.name ~ " was not found") not in item.stdout

- name: Dockutil | Restart Dock
shell: "/usr/bin/killall Dock"
changed_when: false
when: >
removed_items_task.changed|bool == true or
moved_items_task.changed|bool == true or
added_items_task.changed|bool == true
notify: restart dock

0 comments on commit 481a0a2

Please sign in to comment.