Hi,
I am getting [Errno 13] Permission denied
with become: yes
and a user that can access the desired file with sudo.
The file access permission is 0600 (root:root) and connection: local
is set.
Example:
Consider machine with 2 users;
root
& bob
. bob
has privilege access with sudo.
Consider playbook task:
- name: Copy file
become: yes
copy:
src: "/etc/fakepath/file"
dest: "/home/bob/fakepath/file"
owner: bob
group: bob
mode: 0644
Running this playbook:
ansible-playbook -vvv -i inventory.yml playbook.yml -u bob -K
Output:
TASK [local/system-backup : Copy file] **********************************************************************************************
task path: /home/bob/roles/fakerole/tasks/main.yml:22
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: bob
<localhost> EXEC /bin/sh -c 'echo ~bob && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/bob/.ansible/tmp/ansible-tmp-1547058060.7636507-83324408153016 `" && echo ansible-tmp-1547058060.7636507-83324408153016="` echo /home/bob/.ansible/tmp/ansible-tmp-1547058060.7636507-83324408153016 `" ) && sleep 0'
fatal: [localhost]: FAILED! => {
"msg": "an error occurred while trying to read the file '/etc/fakepath/file': [Errno 13] Permission denied: b'/etc/fakepath/file'"
}
Information:
-
ansible_connection: local
-
ansible-playbook 2.7.5
-
python version = 3.6.7
Any pointers to copy the file with chown (bob:bob) would be really helpful.
Thank You.
Best,
Ajay Tripathi