found_files:changed: falsefiles:- path: /etc/yum.repos.d/example1.repomode: '0644'size: 1542- path: /etc/yum.repos.d/example2.repomode: '0644'size: 2842matched: 2
1.find模块返回的格式
2.在后面调用的时候按照相应的key 取对应的value
3.支持正则表达式
4.debug模块可以查看结构
例子:
---
- hosts: localhostgather_facts: falsetasks:- name: Find specific repo files on localhostfind:paths: /etc/yum.repos.d/patterns: "mysql*"register: found_files- name: Display found repo filesdebug:var: found_files.files- hosts: test_playbookgather_facts: falsetasks:- name: Copy repo files to target nodescopy:src: "{{ item.path }}"dest: /etc/yum.repos.d/loop: "{{ hostvars['localhost']['found_files']['files'] }}"