mercredi 29 juillet 2020

ansible how do i search for a directory/subdirectory like 'home/ansible'

In Ansible v2.8.2, how do I search for a subset of a directory tree, like 'home/ansible'?

I have attempted using the find module:

    - name: Find ansible directory
      become: true
      find:
          paths: /
          recurse: yes
          file_type: directory
          use_regex: yes
          patterns: 'home/ansible'
      register: ansible_dirs

    - name: post ansible dirs
      debug:
          msg:
              - ""

I get the error: /proc/20828/task/20828/fd/6 was skipped as it does not seem to be a valid file or it cannot be accessed

If I change patterns to 'home' or 'ansible' it works, but gives me more results then I need.

I suppose I could take this larger result set and whittle it down to what I need, but I was hoping there was an out-of-the-box method to use.

Any help is greatly appreciated, thanks!

3 commentaires: