I wish to search for a string ("AC245") in all files with extension *.db
under /home/examples directory.
If the string is found I wish to abort the play immediately marking the
playbook as FAILED.
Apart from aborting the play using "meta: end_play" I was able to achieve
everything.
Can you help suggest how can I update my current code to add the end_play
feature as soon as the string is found in any *.db file ?
---
- name: "Find the details here "
hosts: localhost
any_errors_fatal: true
serial: 1
tasks:
- name: Ansible find files multiple patterns examples
find:
paths: /home/examples
patterns: "*.db"
recurse: yes
register: files_matched
- name: Search for Number in the matched files
command: grep -i {{ myString }} {{ item.path }}
register: command_result
failed_when: command_result.rc == 0
with_items:
- "{{ files_matched.files }}"
You can run the above find.yml using this command: ansible-playbook
find.yml -e "myString=AC245"
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/78b2c946-ab15-46bc-a54c-ff709339a124%40googlegroups.com.