find module regex on destination of a link?

18 views
Skip to first unread message

Goetz Leupold

unread,
Sep 18, 2017, 3:38:18 AM9/18/17
to Ansible Project
Hello,

got the following contents in a dir(/usr/java):
#lrwxrwxrwx 1 root root   16 Jul  4  2016 default -> /usr/java/latest
#drwxr-xr-x 8 root root 4096 Mar 17  2017 jdk1.8.0_121
#drwxr-xr-x 8 root root 4096 Jul 12 13:41 jdk1.8.0_141
#drwxr-xr-x 8 root root 4096 Apr  1  2016 jdk1.8.0_92
#lrwxrwxrwx 1 root root   22 Sep 15 14:29 latest -> /usr/java/jdk1.8.0_141

With:
  - name: Find links pointing to java installations in {{ java_install_dir }}
    find:
      paths: "{{ java_install_dir }}"
      file_type: link
      patterns: "^(default|latest).*$"
      use_regex: yes
    register: links
i get 2 results. It' fine.

With:
...
      patterns: "^(default|latest).*jdk.*$"
...
I get no results.
With:
...
      patterns: "^(default|latest).*$"
      contains: "jdk" # yes, a dirty try checking link content
...
i get 2 results.

My goal is to get only one result(latest). What do i do wrong? Thank you for any suggests.
Reply all
Reply to author
Forward
0 new messages