Copy module not working with sudo or su

Hi all,

I can’t find why my code is not working when running copy with another user than root. It works fine with root and also other modules like template or yum are working fine with “no root” permissions…

I tried with sudo and then move to su with no luck… thanks in advance!

Error:

failed: [vofe4] => {“failed”: true, “item”: “”, “md5sum”: “99d5c87b8ae2f7cd88ed1afb47959943”, “parsed”: false}
invalid output was:
SUDO-SUCCESS-sfilimasfllysodrjbihhgpdiaurkvyn
Traceback (most recent call last):
File “/home/alosada/.ansible/tmp/ansible-tmp-1404915322.93-16253228171966/copy”, line 1386, in
main()
File “/home/alosada/.ansible/tmp/ansible-tmp-1404915322.93-16253228171966/copy”, line 213, in main
module.atomic_move(src, dest)
File “/home/alosada/.ansible/tmp/ansible-tmp-1404915322.93-16253228171966/copy”, line 1237, in atomic_move
os.chown(tmp_dest.name, st.st_uid, st.st_gid)
UnboundLocalError: local variable ‘st’ referenced before assignment

FATAL: all hosts have already failed – aborting

My code:

ansible-playbook -i production -l webservers ossec-client.yml -k -S -R root --ask-su-pass --tags ossec_rpm -v

file: ossec-client.yml

  • hosts: all
    su: yes
    su_user: root
    roles:
  • ossec-client

file: roles/ossec-client/tasks/main.yml

#COPY MOD_JK

  • name: Creates a writeable repository
    file: path=/usr/local/src/ossec state=directory owner=alosada group=alosada
    tags: ossec_rpm

  • name: Copy ossec-hids-2.8-45.el6.art.x86_64.rpm compiled for Linux 64bits
    copy: src=ossec-hids-2.8-45.el6.art.x86_64.rpm dest=/usr/local/src/ossec/ossec-hids-2.8-45.el6.art.x86_64.rpm
    tags: ossec_rpm

Version: ansible 1.6 (devel bb723bedee) last updated 2014/03/24 16:53:13 (GMT +200)

Update first to the latest Ansible.

If you can produce this error with 1.6.5, please file a bug in GitHub, as tracebacks are errors and need to be handled.