I am trying to develop an ansible module which would traverse subfolders under a main folder and list all .SQL files inside the sub-folders which were modified in the last 30 minutes. Below is my code:
name: Install SQL scripts on Private PostgreSQL Instance
hosts: localhost
gather_facts: no
I’m not completely sure, but patterns: "*.sql" and use_regex: yes doesn’t match, as *.sql is a filename-expansion pattern and not a regular expression.
For it to be a regexp it would need to be something like ^.*\.sql$
Right, but does the subfolders dictionary contain the list of sub-directories? I’m asking as DDL/ is a relative path and I’m wondering if a absolute path might be needed here?
If you want to use Ansible over SSH using public keys then you first need to get SSH working with public keys, perhaps there are logs on your switch which might indicate why it isn’t working?
Or run ssh -vvvv to get verbose output in case this explains why it is not working?
But you didn’t show us what happened! Saying you tried it but it didn’t work gives us nothing to help you with. When Chris asked about the folder structure and gave the ansible.builtin.debug task to answer the question, you instead told us what you think the folder structure is, which is only somewhat interesting. But we aren’t trying to debug you; we’re trying to debug your tasks. What matters is what they see, not what you think is there.
I’ve seen nothing so far that convinces me your first “find” task is finding anything. What’s the output from this: