# Need permissions changed of folder + files together using Ansible synchronize module

**URL:** <https://forum.ansible.com/t/need-permissions-changed-of-folder-files-together-using-ansible-synchronize-module/34474>\
**Category:** Ansible Project\
**Created:** [January 20, 2021, 3:29am UTC](https://forum.ansible.com/t/need-permissions-changed-of-folder-files-together-using-ansible-synchronize-module/34474 "2021-01-20T03:29:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [January 20, 2021, 3:29am UTC](https://forum.ansible.com/t/need-permissions-changed-of-folder-files-together-using-ansible-synchronize-module/34474/1 "2021-01-20T03:29:34Z")

</div>

[Unable to default omit when synchronize attributes are multiline in Ansible](https://stackoverflow.com/questions/65802443/unable-to-default-omit-when-synchronize-attributes-are-multiline-in-ansible)

Below Ansible works fine when final\_file\_perm is defined:

- name: Copying from “{{ inventory\_hostname }}” to this ansible server.  
synchronize:  
src: “{{ item }}”  
dest: “{{ playbook\_dir }}/tmpfiles/{{ Latest\_Build\_Number }}/”  
rsync\_opts: “{{ final\_file\_perm | default(omit) }}”  
mode: pull  
with\_items: - “{{ source\_file.split() }}”

However, my requirement is to have multiple multiline rsync\_opts on new line like below:

rsync\_opts:

- “–chmod=F0775”

- “–chmod=D0775”  

- name: Copying from “{{ inventory\_hostname }}” to this ansible server.  
synchronize:  
src: “{{ item }}”  
dest: “{{ playbook\_dir }}/tmpfiles/{{ Latest\_Build\_Number }}/”  
rsync\_opts:

- “{{ final\_file\_perm | default(omit) }}”

- “{{ final\_folder\_perm | default(omit) }}”  
mode: pull  
with\_items: - “{{ source\_file.split() }}”

The above does not work and give me the following error:

TASK [Copying from “remhost” to this ansible server.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* failed: [remhost] (item=/u/files/inst.zip) =\> {“changed”: false, “cmd”: “/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/share/centrifydc/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \_\_omit\_place\_holder\_\_6fd53eb1f5a7fbe7c6691ba6f3aada2e52378343 \_\_omit\_place\_holder\_\_6fd53eb1f5a7fbe7c6691ba6f3aada2e52378343 --out-format=\<\>%i %n%L remuser@remhost:/u/files/inst.zip /web/playbooks/filecopy/tmpfiles/124/”, “item”: “/u/files/inst.zip”, “msg”: “Unexpected remote arg: remuser@remhost:/u/files/inst.zip\nrsync error: syntax or usage error (code 1) at main.c(1344) [sender=3.1.2]\n”, “rc”: 1} to retry, use: --limit @/web/playbooks/filecopy/copyfiles.retry

I also tried the following:

rsync\_opts: [‘{{ final\_file\_perm | default(omit) }}’, ‘{{ final\_folder\_perm | default(omit) }}’]

But, i get the same error.

Note: this works fine when final\_file\_perm and final\_folder\_perm are defined. Errors only when they are undefined and I wish to omit them.

Can you please propose a solution where I can use default(omit) for attributes on multi newlines?
