module is missing interpreter line during ansible file copy

I am trying to copy a file from local to the remote VM using ansible, but got below error.

My Playbook:

This sounds like some sort of bug or misconfiguration. Ansible modules are short code files. All of the modules that come with ansible (copy comes with ansible) are written in python and have certain substitutions performed on them. One of those substitutions is changing the shebang line to point to the python interpreter on the remote machine. To do this ansible must find an existing shebang line in the module.

The error you’re getting is because ansible was unable to find a shebang line to substitute in the file that it thinks is the copy module.

I’ve just double checked and the copy module does have the required shebang line: https://github.com/ansible/ansible-modules-core/blob/devel/files/copy.py

Some things to try:

  • what version of ansible are you running? We can check to make sure the error isn’t present there.

  • does this also happen with ad hoc tasks using /usr/bin/ansible?
    ansible -I “linux.cloudapp.net,” ‘*’ -m copy -a “src=waagent dest=/etc/sudoers.d/waagent owner=root group=root mode=0644” -u root

  • does this also happen if you try running ansible from another directory? cd / && ansible[…]

-Toshio

Thanks, I was trying to replace the default file with 0440 rights, thats why i got this error. I copied it with different filename in same path, works like a charm!