Y
Y
yukpun2020-10-05 17:44:37
Regular Expressions
yukpun, 2020-10-05 17:44:37

How to copy files using Ansible and regular expressions?

I need to copy files from my local machine (from where I run ansible-playbook) to a remote machine. When doing this, copy only the filtered regex.
I tried to copy using with_items - but it is used only on the remote machine
. I used with_fileglob but I can't make friends with it with regular expressions.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yukpun, 2020-10-05
@LeganSV

The task was solved.
Must be added to the block with the search for delegate_to: localhost

- name: Prepare list of packages to copy
        find:
          paths: "/srv/test_files/"
          patterns: '(^((?!.*dbg).)*arm64.*$)'
          use_regex: yes
        register: file_list
        delegate_to: localhost

D
Dmitry, 2020-10-05
@q2digger

As an idea, without code (I'm writing from a phone)
In the first task, find the files using find , the result is in a variable. In the second task, work with this variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question