From 1aebbee720d75c918c9a7fcae7dabba36e72fc59 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 27 May 2021 11:44:43 -0500 Subject: [PATCH] Fixes #112: Dock control tasks skipped if dockutil not installed or not in PATH. --- tasks/dock-add.yml | 8 +++++--- tasks/dock-remove.yml | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) 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