less than 1 minute read

Apped some string to a list of string

  vars:
    file_name:
      - 'my_file'
      - 'some_other_file'
  tasks:
    - name: List all similar files 
      ansible.builtin.find:
        paths:
          - "/tmp/"
        patterns: "{{ ['*'] | product(file_name) | map('join') | list }}"
      register: _matched

or

        patterns: "{{ file_name | map('regex_replace', '^(.*)$', '*\\1*') }}"

Leave a comment