You need to get all ever logged in users on Windows. There should not be a Public folder in the list.

This design does not work:

 - name: TEST find 4 win block: - win_find: paths: C:\Users\ file_type: directory excludes: Public register: win_find_out - debug: msg: "{{ win_find_out.files }}" 

There is another parameter patterns , but !Public , ?!Public or not (Public) do not work - exhaust disappears altogether.

ansible 2.7.5

  • I do not see the exlude at the docks. There is a regexp - a pattern like this would be ^.+(?!Public).+$ Share your experience with ansibl and Windows ... maybe in a chat :) - Hellseher
  • @Hellseher, there is in docs.ansible.com/ansible/latest/modules/find_module.html . I somehow did not think that there could be a different code base for the parameters. - don Rumata
  • @Hellseher, no, not a ride. Falling public. What do you want to know and in which chat to tell you exactly? - don Rumata
  • @Hellseher, well, where are the questions? - don Rumata 8:49 pm

1 answer 1

You can use the following regular expression:

 ^(?!.*Public) 

See the regular expression demo online .

Details

  • ^ - beginning of line
  • (?!.*Public) - an excluding forward preview block that will not return a match if there is immediately after the current position
    • .* - 0 or more characters other than the newline character
    • Public - Public string

If the line may contain line breaks, add (?s) to the beginning:

 (?s)^(?!.*Public)