M
M
Mika Slepinin2016-11-07 14:25:46
linux
Mika Slepinin, 2016-11-07 14:25:46

How to search on localhost in Ansible and add the files found by mask to a remote host?

Good afternoon! Share, if anyone has, an example of a playbook with which Ansible can search for a file mask (for example, *.jpg, *.pdf) on a localhost, and send them to a remote server.
I will be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konkase, 2016-11-08
@mikalaikaia

- local_action: find paths="/tmp/" patterns="*.log" recurse=yes
  register: output
  
- copy: src="{{ item.path }}" dest="{{ item.path }}"
  with_items: "{{ output.files }}"

S
Sanes, 2016-11-07
@Sanes

There is no ready. But I would look at this option. We select files and put them in a variable, then we poison the synchronize module to a remote host.
This is how I check for Apache2 on the server:

- name: 'Check Apache2'
  command: 'dpkg-query -l apache2'
  register: 'check_apache2'

- name: 'Purge Apache2'
   apt: 'name=apache2 state=absent purge=yes'  
   when: check_apache2.stdout.find('no packages found') == -1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question