diff --git a/tasks/dock-add.yml b/tasks/dock-add.yml index fe9c843..8a4349c 100644 --- a/tasks/dock-add.yml +++ b/tasks/dock-add.yml @@ -1,12 +1,14 @@ --- -- name: See if Dock item {{ item }} exists. +- name: See if Dock item {{ item.name | default(item) }} exists. ansible.builtin.command: "dockutil --find '{{ item.name }}'" register: dockitem_exists - failed_when: '"No such file or directory" in dockitem_exists.stdout' + failed_when: > + "No such file or directory" in dockitem_exists.stdout + or "command not found" in dockitem_exists.stdout changed_when: false tags: ['dock'] -- name: Ensure Dock item {{ item }} exists. +- name: Ensure Dock item {{ item.name | default(item) }} exists. ansible.builtin.command: "dockutil --add '{{ item.path }}'" when: dockitem_exists.rc >0 tags: ['dock'] diff --git a/tasks/dock-remove.yml b/tasks/dock-remove.yml index c22bd0d..32d99e3 100644 --- a/tasks/dock-remove.yml +++ b/tasks/dock-remove.yml @@ -1,13 +1,15 @@ --- -- name: find if dock item exists +- name: See if dock item {{ 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' + failed_when: > + "No such file or directory" in dockitem_exists.stdout + or "command not found" in dockitem_exists.stdout tags: ['dock'] -- name: Ensure unwanted dock items removed. +- name: Ensure Dock item {{ item }} is removed. ansible.builtin.command: cmd: dockutil --remove '{{ item }}' when: dockitem_exists.rc == 0