Ansible playbook “chmod” files and folders works on small directory trees, but dies on large directory trees

We’re trying to keep the files and folders all set to the same group so that all users connecting to our SFTP chrooted directory get access to the same folders. We’re using a default group assigned at login for all users, so that’s why we’re trying to keep the same group. Not our choice, this was a vendor requirement on the default group. Some users are not setting proper group/perms when they’re creating folders or writing files. Our default is to write files at 0755, and we need to override that in this chrooted file system. We don’t want to change any hidden files and folders. The following Ansible tasks work fine when touching a small file system, but when assigned to the larger file system we get the following error:



TASK [manage_directories : Recursively change ownership | chmod_files_folders_recursively.yml 21]
ERROR! A worker was found in a dead state


It seems as though it’s running out of memory or some stack overflow. We’ve confirmed the task starts in an strace, but are not seeing memory go much higher on the machine while watching htop. Again, it works fine on a smaller sub-set of files/folders, just not the main directory with around 144K objects.


  • name: Recursively find all files | chmod_files_folders_recursively.yml 1
    find:
    path: /some/specific/path
    file_type: any
    hidden: false
    recurse: true
    register: folder_contents

  • name: Recursively change ownership | chmod_files_folders_recursively.yml 21
    file:
    path: “{{ item.path }}”
    group: somegroup
    mode: ‘2775’
    loop: “{{ folder_contents.files }}”