Search code examples
directorycopyansiblemode

Ansible fails 50% of the time when copying folder to remote


I want to copy a folder from local src to destination .

The playbook fails 1/2 times without changing anything in the code.

here is the error:

TASK [Copy Source Files] *******************************************
fatal: [124....]: FAILED! => {"changed": false, ...        
        "details": "bad symbolic permission for mode: True", 
        "failed": true, "gid": 0, "group": "root", 
        "mode": "0755", 
        "msg": "mode must be in octal or symbolic form", 
        "owner": "root", 
        "path": "/home/ubuntu/src", "size": 4096, "state": "directory", "uid": 0}
    to retry, use: --limit @/Users/Perso/ansible_tests/playbook.retry

PLAY RECAP *********************************************************

and here is the corresponding task of the playbook:

- name: "Copy Source Files"
  copy:
    src: ./src
    dest: /home/ubuntu/
    directory_mode: yes
    owner: root
    group: root
    force: true

I saw somewhere that this is/was a known issue.

Any ideas? Thanks!


Solution

  • Your error message clearly states that you have errors in directory_mode parameter. As per documentation directory_mode used for setting mode for newly created directories. So yes doesn't make sense here, you should use correct form to set permissions, i.e. 0755 or u=rwx,g=rx,o=rx