检查其中一个文件是否存在于ansible中
我正在尝试检查其中一个文件是否存在于ansible中 用于检查单个文件的代码,该代码运行良好检查其中一个文件是否存在于ansible中,ansible,yaml,Ansible,Yaml,我正在尝试检查其中一个文件是否存在于ansible中 用于检查单个文件的代码,该代码运行良好 - hosts: all tasks: - name: Ansible check file exists example. stat: path: /Users/data/info.text register: file_details - debug: msg: "The file exists" when: file
- hosts: all
tasks:
- name: Ansible check file exists example.
stat:
path: /Users/data/info.text
register: file_details
- debug:
msg: "The file exists"
when: file_details.stat.exists
但我想检查是否存在/Users/data/info.text或/Users/data/info.html,这里我尝试使用or运算符,但它表示yml文件无效
- hosts: all
tasks:
- name: Ansible check file exists example.
stat:
path: /Users/data/info.text or /Users/data/info.html
register: file_details
- debug:
msg: "The file exists"
when: file_details.stat.exists
试试这个
-统计:
路径:“{item}}”
注册:文件详细信息
循环:
-信息文本
-info.html
-调试:
msg:文件存在
当:file_details.results|map(attribute='stat.exists')是全部