mirror of
https://github.com/geerlingguy/mac-dev-playbook
synced 2024-11-23 20:33:04 +00:00
working dockutil
This commit is contained in:
parent
baae72b63e
commit
2574bb2952
5 changed files with 73 additions and 18 deletions
|
@ -3,3 +3,4 @@ nocows = True
|
|||
roles_path = ./roles:/etc/ansible/roles
|
||||
inventory = inventory
|
||||
become = true
|
||||
stdout_callback = yaml
|
||||
|
|
|
@ -6,8 +6,29 @@ configure_terminal: false
|
|||
configure_osx: true
|
||||
configure_dock: []
|
||||
|
||||
configure_dock: []
|
||||
|
||||
configure_dock: True
|
||||
dockitems_to_remove:
|
||||
- Launchpad
|
||||
- Safari
|
||||
- Messages
|
||||
- Mail
|
||||
- Maps
|
||||
- Photos
|
||||
- FaceTime
|
||||
- Calendar
|
||||
- Contacts
|
||||
- Reminders
|
||||
- Notes
|
||||
- TV
|
||||
- Music
|
||||
- Podcasts
|
||||
- 'App Store'
|
||||
remove_spacers: true
|
||||
dockitems_to_persist:
|
||||
- name: iTerm
|
||||
path: "/Applications/iTerm.app/"
|
||||
- name: "Google Chrome"
|
||||
path: "/Applications/Google Chrome.app/"
|
||||
configure_sudoers: false
|
||||
sudoers_custom_config: ''
|
||||
# Example:
|
||||
|
|
13
tasks/adddock.yml
Normal file
13
tasks/adddock.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
- name: find if dock {{ item }} exists
|
||||
ansible.builtin.command:
|
||||
cmd: dockutil --find '{{ item.name }}'
|
||||
register: dockitem_exists
|
||||
failed_when: '"No such file or directory" in dockitem_exists.stdout'
|
||||
changed_when: false
|
||||
tags: ['dock']
|
||||
- name: Ensure dock {{ item }} exists
|
||||
ansible.builtin.command:
|
||||
cmd: dockutil --add '{{ item.path }}'
|
||||
when: dockitem_exists.rc >0
|
||||
tags: ['dock']
|
|
@ -1,20 +1,26 @@
|
|||
---
|
||||
- name: Install dockutil
|
||||
homebrew:
|
||||
name: dockutil
|
||||
state: present
|
||||
notify:
|
||||
- Clear homebrew cache
|
||||
- name: ensure dock items
|
||||
block:
|
||||
- name: Install dockutil
|
||||
homebrew:
|
||||
name: dockutil
|
||||
state: present
|
||||
notify:
|
||||
- Clear homebrew cache
|
||||
- name: remove dockitems
|
||||
ansible.builtin.include_tasks: tasks/remdock.yml
|
||||
loop: "{{ dockitems_to_remove }}"
|
||||
|
||||
- name: Remove all crap from Dock
|
||||
shell: dockutil --remove '{{ item }}'
|
||||
ignore_errors: true
|
||||
with_items: "{{ dockitems_to_remove }}"
|
||||
- name: Ensure required dock items exist.
|
||||
ansible.builtin.include_tasks: tasks/adddock.yml
|
||||
with_items: "{{ dockitems_to_persist }}"
|
||||
|
||||
- name: Check if items in dock exist
|
||||
shell: dockutil --find '{{ item.name }}' || dockutil --add '{{ item.path }}'
|
||||
with_items: "{{ dockitems_to_persist }}"
|
||||
- name: Ensure correct dock order
|
||||
ansible.builtin.command:
|
||||
cmd: dockutil --move '{{ item.name }}' --position '{{ item.pos }}'
|
||||
when:
|
||||
- item.pos is defined
|
||||
- item.pos length >0
|
||||
loop: "{{ dockitems_to_persist }}"
|
||||
|
||||
- name: Fix order
|
||||
shell: dockutil --move '{{ item.name }}' --position '{{ item.pos }}'
|
||||
with_items: "{{ dockitems_to_persist }}"
|
||||
tags: ['dock']
|
||||
|
|
14
tasks/remdock.yml
Normal file
14
tasks/remdock.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- name: find if dock item exists
|
||||
ansible.builtin.command:
|
||||
cmd: dockutil --find '{{ item }}'
|
||||
register: dockitem_exists
|
||||
changed_when: false
|
||||
failed_when: '"No such file or directory" in dockitem_exists.stdout'
|
||||
tags: ['dock']
|
||||
- name: Ensure unwanted dock items removed.
|
||||
ansible.builtin.command:
|
||||
cmd: dockutil --remove '{{ item }}'
|
||||
when: dockitem_exists.rc == 0
|
||||
tags: ['dock']
|
||||
|
Loading…
Reference in a new issue