ansible.errors.AnsibleFileNotFound

Hi,

Ansible 2.9.11
AWX 14.1.0

I run 2 playbooks. One runs on the ansible controler itself and dowloadings a file to /tmp. the 2nd playbook copies that file to a target server. Both playbooks run fine in Ansible CLI but the 2nd one fails at the copy module with file not found. I don’t understand why the file isn’t found under AWX. Any help would be appreciated.

Following the output of the task:

TASK [copy cmk agent deb to target server] *************************************
task path: /tmp/awx_43_0pq_lkbj/project/install_cmk_agent.yml:12
<192.168.105.101> ESTABLISH SSH CONNECTION FOR USER: sysadmin
<192.168.105.101> SSH: EXEC sshpass -d10 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘User=“sysadmin”’ -o ConnectTimeout=10 -o ControlPath=/tmp/awx_43_0pq_lkbj/cp/31bea51285 192.168.105.101 ‘/bin/sh -c ‘"’“‘echo ~sysadmin && sleep 0’”’“‘’
<192.168.105.101> (0, b’/home/sysadmin\n’, b’bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)\n’)
<192.168.105.101> ESTABLISH SSH CONNECTION FOR USER: sysadmin
<192.168.105.101> SSH: EXEC sshpass -d10 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘User=“sysadmin”’ -o ConnectTimeout=10 -o ControlPath=/tmp/awx_43_0pq_lkbj/cp/31bea51285 192.168.105.101 '/bin/sh -c '”‘"’( umask 77 && mkdir -p “echo /home/sysadmin/.ansible/tmp”&& mkdir /home/sysadmin/.ansible/tmp/ansible-tmp-1601711309.6230288-5662-129587635544301 && echo ansible-tmp-1601711309.6230288-5662-129587635544301=“echo /home/sysadmin/.ansible/tmp/ansible-tmp-1601711309.6230288-5662-129587635544301” ) && sleep 0’“'”‘’
<192.168.105.101> (0, b’ansible-tmp-1601711309.6230288-5662-129587635544301=/home/sysadmin/.ansible/tmp/ansible-tmp-1601711309.6230288-5662-129587635544301\n’, b’bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)\n’)
<192.168.105.101> ESTABLISH SSH CONNECTION FOR USER: sysadmin
<192.168.105.101> SSH: EXEC sshpass -d10 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘User=“sysadmin”’ -o ConnectTimeout=10 -o ControlPath=/tmp/awx_43_0pq_lkbj/cp/31bea51285 192.168.105.101 ‘/bin/sh -c ‘"’“‘rm -f -r /home/sysadmin/.ansible/tmp/ansible-tmp-1601711309.6230288-5662-129587635544301/ > /dev/null 2>&1 && sleep 0’”’"‘’
<192.168.105.101> (0, b’‘, b’bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)\n’)
The full traceback is:
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/ansible/plugins/action/copy.py”, line 464, in run
source = self._find_needle(‘files’, source)
File “/usr/lib/python3.6/site-packages/ansible/plugins/action/init.py”, line 1192, in _find_needle
return self._loader.path_dwim_relative_stack(path_stack, dirname, needle)
File “/usr/lib/python3.6/site-packages/ansible/parsing/dataloader.py”, line 327, in path_dwim_relative_stack
raise AnsibleFileNotFound(file_name=source, paths=[to_native(p) for p in search])
ansible.errors.AnsibleFileNotFound: Could not find or access ‘/tmp/agents/check-mk-agent.deb’ on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [vpn31]: FAILED! => {
“changed”: false,
“invocation”: {
“dest”: “/tmp”,
“group”: “sysadmin”,
“mode”: “0755”,
“module_args”: {
“dest”: “/tmp”,
“group”: “sysadmin”,
“mode”: “0755”,
“owner”: “sysadmin”,
“src”: “/tmp/agents/check-mk-agent.deb”
},
“owner”: “sysadmin”,
“src”: “/tmp/agents/check-mk-agent.deb”
},
“msg”: “Could not find or access ‘/tmp/agents/check-mk-agent.deb’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”

}

Permissions:
ls -l /tmp
drwxr-xr-x 3 sysadmin sysadmin 4096 Sep 27 15:47 agents

ls -l /tmp/agents/
-rw-r–r-- 1 sysadmin sysadmin 26640 Sep 27 15:47 check-mk-agent.deb
-rw-r–r-- 1 sysadmin sysadmin 5214208 Sep 27 15:47 check_mk_agent.msi
-rw-r–r-- 1 sysadmin sysadmin 33728 Sep 27 15:47 check-mk-agent.rpm

regards Robert

Hi,
without seeing playbook hard to say, but

I personally would use a webdav server to move files between source/destination, this way no matter were u run playbook file location will be same.

Good Luck!

I cannot post a messages, always deleted. Trying to post it partially.
Hi,

Following my 2 playbooks.
Why I want to use that method. I have several servers running in different security zones. Only the ansible controller has access to that servers via ssh. This method don’t require an additional firewall rule and I want to avoid it.

regards Robert

The playbook coding is always deleted. Trying as attachment.
Playbook1: download file to ansible controller.
This playbook runs on the ansible controller as target and it runs fine in both CLI and AWX. The file will be created at the given location.

Playbook2: copy file to target server
This runs on the target server where to install the package. It runs fine in CLI but fails in AWX

(attachments)

Playbook1 (127 Bytes)
Playbook2 (170 Bytes)

I’ve found the reason. AWX is running in a container. The directory where the file resides must be mounted into the container.