On Fri, 22 Mar 2024 14:15:03 -0400
Michael DiDomenico <mdidomeni...@gmail.com> wrote:

> ... copy a bunch of ssl ca certs into a directory ...
> create *.0 symlinks to each of the certs

FWIW, instead of handlers, get the lists of the certs and
links, and iterate the difference


    - find:
        paths: /tmp/ansible/certs
        patterns: '*.crt'
      register: out_crt

    - find:
        paths: /tmp/ansible/certs
        patterns: '*.0'
        file_type: link
      register: out_lnk

    - file:
        state: link
        src: /tmp/ansible/certs/{{ item }}.crt
        dest: /tmp/ansible/certs/{{ item }}.0
      loop: "{{ certs | difference(links) }}"
      vars:
        certs: "{{ out_crt.files |
                   json_query('[].path') |
                   map('basename') |
                   map('splitext') |
                   map('first') }}"
        links: "{{ out_lnk.files |
                   json_query('[].path') |
                   map('basename') |
                   map('splitext') |
                   map('first') }}"

Fit the paths to your needs.

-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20240322210112.70847341%40planb.

Attachment: pgpd7f2n8VtxB.pgp
Description: OpenPGP digital signature

Reply via email to