diff --git a/README.md b/README.md index a7126e4..a2276e7 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ You can override any of the defaults configured in `default.config.yml` by creat pip_packages: - name: mkdocs + + configure_dock: true + dockitems_remove: [] + dockitems_persist: [] Any variable can be overridden in `config.yml`; see the supporting roles' documentation for a complete list of available variables. diff --git a/default.config.yml b/default.config.yml index 229e3cb..149b009 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,31 +6,17 @@ configure_terminal: false configure_osx: true configure_dock: [] -configure_dock: [] -dockitems_to_remove: [] -# Example: to remove all / some items added by default on Big Sur uncomment use example below -# dockitems_to_remove: -# - Launchpad -# - Safari -# - Messages -# - Mail -# - Maps -# - Photos -# - FaceTime -# - Calendar -# - Contacts -# - Reminders -# - Notes -# - TV -# - Music -# - Podcasts -# - 'App Store' +# Set to 'true' to configure the Dock via dockutil. +configure_dock: false +dockitems_remove: [] +# - Launchpad +# - TV +# - Podcasts +# - 'App Store' +dockitems_persist: [] +# - name: "Sublime Text" +# path: "/Applications/Sublime Text.app/" -dockitems_to_persist: - - name: "Google Chrome" - path: "/Applications/Google Chrome.app/" - - name: "Sublime Text" - path: "/Applications/Sublime Text.app/" configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/tasks/adddock.yml b/tasks/adddock.yml deleted file mode 100644 index 40568aa..0000000 --- a/tasks/adddock.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- 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'] diff --git a/tasks/dock-add.yml b/tasks/dock-add.yml new file mode 100644 index 0000000..fe9c843 --- /dev/null +++ b/tasks/dock-add.yml @@ -0,0 +1,12 @@ +--- +- name: See if Dock item {{ item }} exists. + ansible.builtin.command: "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 {{ item }} exists. + ansible.builtin.command: "dockutil --add '{{ item.path }}'" + when: dockitem_exists.rc >0 + tags: ['dock'] diff --git a/tasks/remdock.yml b/tasks/dock-remove.yml similarity index 100% rename from tasks/remdock.yml rename to tasks/dock-remove.yml diff --git a/tasks/dock.yml b/tasks/dock.yml index c617e46..d1130ee 100644 --- a/tasks/dock.yml +++ b/tasks/dock.yml @@ -1,22 +1,23 @@ --- -- name: Install dockutil +- 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 configured Dock items. + ansible.builtin.include_tasks: tasks/dock-remove.yml + loop: "{{ dockitems_remove }}" - name: Ensure required dock items exist. - ansible.builtin.include_tasks: tasks/adddock.yml - with_items: "{{ dockitems_to_persist }}" + ansible.builtin.include_tasks: tasks/dock-add.yml + loop: "{{ dockitems_persist }}" -- name: Ensure correct dock order +- 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 }}" + loop: "{{ dockitems_persist }}" diff --git a/tasks/osx.yml b/tasks/osx.yml index c6c5b45..ec12cd5 100644 --- a/tasks/osx.yml +++ b/tasks/osx.yml @@ -3,4 +3,3 @@ - name: Run .osx dotfiles. command: "{{ osx_script }}" changed_when: false - tags: ['osx']