I want to make a list of servers that don't have a particular file.
I made the following Ansible playbook:
- name: "If file not in /apps"
hosts: all
tasks:
- name: Find apps
find:
paths: /apps/
patterns: "*"
file_type: directory
register: apps
- name: Show file paths
with_items: "{{ apps.files }}"
debug:
msg: "{{ item.path }}"
This returns a message with the app directories. I would like to check if a certain file is present in a subfolder, and if the file is not present, I want to run a script.
A pseudocode example of what I want:
for folder in "/apps/*":
if file not in folder:
print(item.path)
How do I do that? I just can't find anything and I've been trying for several hours now.