Fixes #112: Dock control tasks skipped if dockutil not installed or not in PATH.

This commit is contained in:
Jeff Geerling 2021-05-27 11:44:43 -05:00
parent c6fef3ad23
commit 1aebbee720
2 changed files with 10 additions and 6 deletions

View file

@ -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 }}'" ansible.builtin.command: "dockutil --find '{{ item.name }}'"
register: dockitem_exists 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 changed_when: false
tags: ['dock'] tags: ['dock']
- name: Ensure Dock item {{ item }} exists. - name: Ensure Dock item {{ item.name | default(item) }} exists.
ansible.builtin.command: "dockutil --add '{{ item.path }}'" ansible.builtin.command: "dockutil --add '{{ item.path }}'"
when: dockitem_exists.rc >0 when: dockitem_exists.rc >0
tags: ['dock'] tags: ['dock']

View file

@ -1,13 +1,15 @@
--- ---
- name: find if dock item exists - name: See if dock item {{ item }} exists.
ansible.builtin.command: ansible.builtin.command:
cmd: dockutil --find '{{ item }}' cmd: dockutil --find '{{ item }}'
register: dockitem_exists register: dockitem_exists
changed_when: false 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'] tags: ['dock']
- name: Ensure unwanted dock items removed. - name: Ensure Dock item {{ item }} is removed.
ansible.builtin.command: ansible.builtin.command:
cmd: dockutil --remove '{{ item }}' cmd: dockutil --remove '{{ item }}'
when: dockitem_exists.rc == 0 when: dockitem_exists.rc == 0