How to use find & exec in a Ansible Playbook?

Hi @myservertechnik I was just about to reply and say use the builtin find and file modules. I was also working on an example for find.

- name: Find all directories that match text
  ansible.builtin.find:
    paths: "{{ target_directory }}"
    patterns: "some_text*"
    recurse: true
    file_type: directory

In this example I’ve created a variable for the path named “target_directory” which is convenient if you need to specify that more than once. I also noticed in your original command you set -type d which I believe corresponds to file_type: directory.

As I’m sure you’re aware there are plenty of examples of chmod in the docs: ansible.builtin.file module – Manage files and file properties — Ansible Documentation

Hope this helps.