Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible synchronize mode permissions

Tags:

ansible

rsync

I'm using an Ansible playbook to copy files between my host and a server. The thing is, I have to run the script repeatedly in order to upload some updates. At the beginning I was using the "copy" module of Ansible, but to improve performance of the synchronizing of files and directories, I've now switched to use the "synchronize" module. That way I can ensure Ansible uses rsync instead of sftp or scp.

With the "copy" module, I was able to specify the file's mode in the destination host by adding the mode option (e.g. mode=644). I want to do that using synchronize, but it only has the perms option that accepts yes or no as values.

Is there a way to specify the file's mode using "synchronize", without having to inherit it?

Thx!

like image 915
dubafek Avatar asked Oct 04 '16 15:10

dubafek


1 Answers

Finally I solved it using rsync_opts

- name: sync file
  synchronize:
    src: file.py
    dest: /home/myuser/file.py
    rsync_opts:
      - "--chmod=F644"
like image 60
dubafek Avatar answered Oct 05 '22 20:10

dubafek