Hi,
I’m using the following two tasks to replace the OpenJDK menu entry file on a Linux desktop. The file is a bit of a moving target, and its name sometimes changes from one release to the next.
# OpenJDK Policy Tool menu file is a moving target
- name: Find OpenJDK menu entry location
ansible.builtin.find:
paths: /usr/share/applications
patterns: 'java*openjdk*.desktop'
register: java_menufile
- name: Don't show OpenJDK Policy Tool in the menu
ansible.builtin.copy:
dest: "{{ java_menufile.files[0].path }}"
content: |
[Desktop Entry]
NoDisplay=true
owner: root
group: root
mode: 0644
notify: Update desktop database
I’d like to add a little security here which says something like “don’t perform the second task if the search yields no results”.
I tried adding this:
when: java_menufile.stat.exists
But this doesn’t seem to work. I must be doing something wrong.
Any suggestions ?