found_files:
changed: false
files:
- path: /etc/yum.repos.d/example1.repo
mode: '0644'
size: 1542
- path: /etc/yum.repos.d/example2.repo
mode: '0644'
size: 2842
matched: 2
1.find模块返回的格式
2.在后面调用的时候按照相应的key 取对应的value
3.支持正则表达式
例子:
---
- hosts: localhost
gather_facts: false
tasks:
- name: Find specific repo files on localhost
find:
paths: /etc/yum.repos.d/
patterns: "mysql*"
register: found_files
- name: Display found repo files
debug:
var: found_files.files
- hosts: test_playbook
gather_facts: false
tasks:
- name: Copy repo files to target nodes
copy:
src: "{{ item.path }}"
dest: /etc/yum.repos.d/
loop: "{{ hostvars['localhost']['found_files']['files'] }}"