-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch1.yml
41 lines (33 loc) · 824 Bytes
/
fetch1.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- hosts: localhost
gather_facts: no
tasks:
- name: create src temp file
tempfile:
state: directory
register: src_config
- name: set src tempfile path
set_fact:
src_file: "{{ src_config.path }}"
- hosts: "{{ server1 }}"
gather_facts: no
vars:
src_file1: "{{ hostvars['localhost'].src_file }}/"
tasks:
- debug: var=src_file1
- name: fetch content of src directory
find:
paths: /home/ubuntu/config
recurse: yes
register: src_files
- name: fetch files from the remote directory
fetch:
src: "{{ item.path }}"
dest: "{{ src_file1 }}"
flat: yes
with_items: "{{ src_files.files }}"
- hosts: localhost
tasks:
- shell: "ls {{src_file}}"
register: files
- debug: var=files