Impossible to transfer data with synchronize/rsync (code 12) io.c(232)

hello,
i’ve this version of rsync :

(env) alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ rsync --version
rsync  version 3.3.0-22-g0902b52f  protocol version 31
Copyright (C) 1996-2024 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
    hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
    xattrs, optional secluded-args, iconv, prealloc, stop-at, no crtimes
Optimizations:
    SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
    xxh128 xxh3 xxh64 (xxhash) md5 md4 sha1 none
Compress list:
    zstd lz4 zlibx zlib none
Daemon auth list:
    sha512 sha256 sha1 md5 md4

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
(env) alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/

,the version of rsync on my remote server :


alexandre@ubuntu:~$ rsync --version
rsync  version 3.3.0-22-g0902b52f  protocol version 31
Copyright (C) 1996-2024 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
    hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, no ACLs,
    xattrs, optional secluded-args, iconv, prealloc, stop-at, no crtimes
Optimizations:
    SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
    xxh128 xxh3 xxh64 (xxhash) md5 md4 sha1 none
Compress list:
    zstd lz4 zlibx zlib none
Daemon auth list:
    sha512 sha256 sha1 md5 md4

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
alexandre@ubuntu:~$

the permissions of rsync ,on my remote server :

ls -ld /usr/local/bin/rsync
-rwxr-xr-x 1 root root 1587224 Nov  4 11:51 /usr/local/bin/rsync

i’ve this playbook:


cat ./playbook.yml 
- hosts: servers
  become: yes
  vars:
    symfony_root: /var/www/AnalyticaTechCode
    local_project_root: "/home/alexandre/Documents/AnalyticaTechCode"

  tasks:
    - name: Ensure directory exists
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: www-data
        group: www-data
        mode: '0755'

    - name: Synchronize project files
      synchronize:
        src: "/home/alexandre/Documents/AnalyticaTechCode/"
        dest: "/var/www/AnalyticaTechCode"
        rsync_opts:
          - "--rsync-path='sudo rsync'"
      become: no

    - name: Set final permissions
      file:
        path: "{{ symfony_root }}"
        owner: www-data
        group: www-data
        mode: '0755'
        recurse: yes

this iventory.ini:

(env) alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ cat ./inventory.ini 
[servers]
ubuntu ansible_host=xx.xx.xx.xx ansible_user=alexandre 


[all:vars]
ansible_python_interpreter=/usr/bin/python3

(env) alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$

and when i execute this command , i’ve this error:

(env) alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ ansible-playbook playbook.yml --ask-pass --ask-become-pass
SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [servers] ****************************************************************************************

TASK [Gathering Facts] ********************************************************************************
ok: [ubuntu]

TASK [Ensure directory exists] ************************************************************************
ok: [ubuntu]

TASK [Synchronize project files] **********************************************************************
alexandre@xx.xx.xx.xx's password: 
fatal: [ubuntu]: FAILED! => {"changed": false, "cmd": "/usr/local/bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo rsync' --out-format='<<CHANGED>>%i %n%L' /home/alexandre/Documents/AnalyticaTechCode/ alexandre@xx.xx.xx.xx:/var/www/AnalyticaTechCode", "msg": "Warning: Permanently added 'xx.xx.xx.xx' (ED25519) to the list of known hosts.\r\nsudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\nsudo: a password is required\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at io.c(232) [sender=3.3.0-22-g0902b52f]\n", "rc": 12}

PLAY RECAP ********************************************************************************************
ubuntu                     : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

(env) alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$

what can i do ? could you help me ?
Regards

the synchronize module has a dedicated rsync_path parameter:

https://docs.ansible.com/ansible/latest/collections/ansible/posix/synchronize_module.html#parameter-rsync_path

Can you try that instead of the rsync_opts parameter?

same problem with same error code :

alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ sudo gedit  ./playbook.yml 
^C
alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ ansible-playbook playbook.yml --ask-pass 
SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [servers] ****************************************************************************************

TASK [Gathering Facts] ********************************************************************************
ok: [ubuntu]

TASK [Ensure directory exists] ************************************************************************
ok: [ubuntu]

TASK [Synchronize project files] **********************************************************************
alexandre@xx.xx.xx.xx's password: 
fatal: [ubuntu]: FAILED! => {"changed": false, "cmd": "/usr/local/bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u root rsync' --out-format='<<CHANGED>>%i %n%L' /home/alexandre/Documents/AnalyticaTechCode/ alexandre@xx.xx.xx.xx:/var/www/AnalyticaTechCode", "msg": "Warning: Permanently added 'xx.xx.xx.xx' (ED25519) to the list of known hosts.\r\nsudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\nsudo: a password is required\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at io.c(232) [sender=3.3.0-22-g0902b52f]\n", "rc": 12}

PLAY RECAP ********************************************************************************************
ubuntu                     : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ sudo cat  ./playbook.yml 
- hosts: servers
  become: yes
  vars:
    symfony_root: /var/www/AnalyticaTechCode
    local_project_root: "/home/alexandre/Documents/AnalyticaTechCode"

  tasks:
    - name: Ensure directory exists
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: www-data
        group: www-data
        mode: '0755'

    - name: Synchronize project files
      ansible.posix.synchronize:
        src: "{{ local_project_root }}/"
        dest: "{{ symfony_root }}"

    - name: Set final permissions
      file:
        path: "{{ symfony_root }}"
        owner: www-data
        group: www-data
        mode: '0755'
        recurse: yes

without your option

and now i’ve this error , with modification in playbook.yml :

alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ ansible-playbook playbook.yml --ask-pass --ask-become-pass
SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [servers] ************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************
ok: [ubuntu]

TASK [Ensure directory exists] ********************************************************************************************************************************************************************************************
ok: [ubuntu]

TASK [Synchronize project files] ******************************************************************************************************************************************************************************************
alexandre@xx.xx.xx.xx's password: 
alexandre@xx.xx.xx.xx's password: 
fatal: [ubuntu -> localhost]: FAILED! => {"changed": false, "cmd": "/usr/local/bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --exclude=.git --out-format='<<CHANGED>>%i %n%L' /home/alexandre/Documents/AnalyticaTechCode/ alexandre@xx.xx.xx.xx:/var/www/AnalyticaTechCode", "msg": "Warning: Permanently added '85.215.166.46' (ED25519) to the list of known hosts.\r\nPermission denied, please try again.\r\nrsync: [generator] chgrp \"/var/www/AnalyticaTechCode/.\" failed: Operation not permitted (1)\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/.idea\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/.stfolder\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/ansible\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/assets\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/bin\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/config\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/migrations\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/node_modules\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/projetWeb\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/public\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/src\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/templates\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/translations\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/var\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [generator] recv_generator: mkdir \"/var/www/AnalyticaTechCode/vendor\" failed: Permission denied (13)\n*** Skipping any contents from this failed directory ***\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.env.rLs1hJ\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.gitignore.yj1Y8T\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.README.md.vtsOiW\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.composer.json.7w7EnQ\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.composer.lock.xS3XMj\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.connection.sh.YZ8eau\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.deploy.sh.gVqCLH\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.deploy2.sh.a6xRL8\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.docker-compose.override.yml.NJHD4E\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.docker-compose.yml.j2pj2F\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.download.sh.espi1b\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.install.yaml.lBadN2\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.nodesource_setup.sh.HdxMKC\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.package-lock.json.0eFgD3\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.package.json.pKFahX\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.packages.txt.2oBegW\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.rec-apache-1.inv.yXBYRm\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.sudo.9mgZev\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.symfony.lock.QUcDE1\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.webpack.config.js.7OB4lD\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.yarn-error.log.ZjpKSe\" failed: Permission denied (13)\nrsync: [receiver] mkstemp \"/var/www/AnalyticaTechCode/.yarn.lock.rKog0F\" failed: Permission denied (13)\nrsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.3.0-22-g0902b52f]\n", "rc": 23}

PLAY RECAP ****************************************************************************************************************************************************************************************************************
ubuntu                     : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$ cat ./playbook.yml 
- hosts: servers
  become: yes
  vars:
    symfony_root: /var/www/AnalyticaTechCode
    local_project_root: "/home/alexandre/Documents/AnalyticaTechCode"

  tasks:
    - name: Ensure directory exists
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: www-data
        group: www-data
        mode: '0755'

    - name: Synchronize project files
      ansible.posix.synchronize:
        src: "{{ local_project_root }}/"
        dest: "{{ symfony_root }}"
        rsync_opts:
          - "--exclude=.git"
      delegate_to: localhost
      become: no

    - name: Set final permissions
      file:
        path: "{{ symfony_root }}"
        owner: www-data
        group: www-data
        mode: '0755'
        recurse: yes

alexandre@alexandre-Matebook:~/Documents/AnalyticaTechCode/ansible$

ok I have reindented the lines of the yaml file correctly, and I have modified the permissions of mopn folder and files inside, this gives it several command , especially for the permissions on the remote server, we have:

ssh alexandre@xx.xx.xx.xx
ls -l /var/www
sudo chown alexandre:www-data /var/www/AnalyticaTechCode
sudo chmod 775 /var/www/AnalyticaTechCode

et my yaml contains that :

- hosts: servers
  become: yes
  vars:
    symfony_root: /var/www/AnalyticaTechCode
    local_project_root: "/home/alexandre/Documents/AnalyticaTechCode"

  tasks:
    - name: Ensure directory exists
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: alexandre
        group: www-data
        mode: '0755'

    - name: Ensure correct permissions on symfony_root
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: alexandre
        group: www-data
        mode: '0775'
        recurse: yes

    - name: Synchronize project files
      ansible.posix.synchronize:
        src: "{{ local_project_root }}/"
        dest: "{{ symfony_root }}"
        rsync_opts:
          - "--exclude=.git"
        owner: no
        group: no
      delegate_to: localhost
      become: no

and I have no more problem .

1 Like

or better, if we consider that the owner and the group are not necessary.

- hosts: servers
  become: yes
  vars:
    symfony_root: /var/www/AnalyticaTechCode
    local_project_root: "/home/alexandre/Documents/AnalyticaTechCode"

  tasks:
    - name: Ensure directory exists
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: alexandre
        group: www-data
        mode: '0755'

    - name: Ensure correct permissions on symfony_root
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: alexandre
        group: www-data
        mode: '0775'
        recurse: yes

    - name: Synchronize project files
      ansible.posix.synchronize:
        src: "{{ local_project_root }}/"
        dest: "{{ symfony_root }}"
        rsync_opts:
          - "--exclude=.git"
      delegate_to: localhost
      become: no

    - name: Set final permissions
      file:
        path: "{{ symfony_root }}"
        state: directory
        owner: www-data
        group: www-data
        mode: '0755'
        recurse: yes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.