我想知道除了 Ansible 模块之外是否还有其他模块command
这会给我一个包含模式的文件列表(递归搜索)?
在 Unix 上我会这样做
find . -type f -exec grep -l pattern {} \;
结果将是我要迭代以用另一个值更改一个值的文件列表
您可以使用查找模块 https://docs.ansible.com/ansible/2.7/modules/find_module.html去做这个。这contains
参数接受正则表达式来搜索文件内容:
- name: Find files
find:
paths: /var/log
contains: pattern
register: found_files
结果find
模块包含属性files
,以及匹配文件的列表,以及matched
,以及匹配文件的数量。您可以使用以下方法存储结果register
属性上的find
命令 (found_files
above).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)