当前位置: 首页 > news >正文

ansible_find模块

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.支持正则表达式
4.debug模块可以查看结构

例子:

---
- 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'] }}"

相关文章:

  • 使用vscode上传git远程仓库流程(Gitee)
  • Vue3 响应式工具函数isRef()、unref()、isReactive()、isReadonly()、isProxy()
  • Springcould -第一个Eureka应用 --- day02
  • SpringBootAdmin源码修改编译002_踩坑记录一堆坑_记录过程_没有成功---VUE工作笔记0027
  • uniapp+uview-plus实现微信小程序自定义tabbar
  • 待机模式中WKUP上升沿模拟开机与关机
  • css总结(记录一下...)
  • 从底层原理上理解ClickHouse 中的稀疏索引
  • freeRTOS 任务的创建、挂起、恢复
  • Java代码审计篇 | ofcms系统审计思路讲解 - 篇4 | XXE漏洞审计
  • 在 Ubuntu 20.04 上安装 Python 3.12:详细教程
  • C++学习笔记之引用(基础)
  • ardunio超声波测距实验
  • Docker和anaconda的区别?
  • 单向循环链表
  • Spring Cloud集成Gateaway
  • Linux:git
  • Linux——进程状态
  • 基于SpringBoot的扶贫助农管理系统
  • 滑动窗口算法—字符串的排列
  • 跨文化戏剧的拓荒者与传承者——洪深与复旦剧社的百年回响
  • 中国至越南河内国际道路运输线路正式开通
  • 首个偏头痛急性治疗药物可缓解前期症状
  • 中国创面修复学科发起者之一陆树良教授病逝,享年64岁
  • 新疆交通运输厅厅长西尔艾力·外力履新吐鲁番市市长候选人
  • 上海交大计算机学院成立,设多个拔尖人才特色班