I am trying to check one of the file exist or not in ansible.
Code for checking single file, which works perfectly.
- 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
But I want to check if /Users/data/info.text or /Users/data/info.html exist or not, here I'm trying to use or operator, but it is saying invalid yml file.
- 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