1

A playbook that ran perfectly on earlier versions of Awx now fails after we've upgraded AWX to 4.0.0 (with Ansible 2.8.1) in that "Copy" cannot find any local files.

When copying a file to a remote server using Copy, Ansible complains it cannot find that file. I have tried various locations, including within the virtualenv dirs such as /var/opt/rh/rh-python36/ and /opt/rh/rh-python36/root/tmp/ (rh-python36 is the env selected for this playbook, others fail much earlier)

As an experiment, I created a uniquely named file on the remote server and used remote_src to copy that file to the AWX host. AWX succeeded in doing this and completed the playbook. "Great", I thought, and then searched for the file (using mlocate: updatedb && locate testfile) as well as find /|grep testfile - and that file simply does not exist.

It's like AWX is creating a temporary file structure for the session of this playbook and them removing it, which seems to make Copy a difficult thing to use in either direction.

Can someone please shed some light?


- hosts: "all"
  become: true

- name: Copy a test file
  hosts: "all"
  tasks:
  - name: copy a test file
    copy:
      src: /tmp/testfile
      dest: /tmp/testfile
      owner: root
      group: root
      mode: '0644'

Traceback (most recent call last): File "/opt/rh/rh-python36/root/lib/python3.6/site-packages/ansible/plugins/action/copy.py", line 464, in run source = self._find_needle('files', source) File "/opt/rh/rh-python36/root/lib/python3.6/site-packages/ansible/plugins/action/init.py", line 1166, in _find_needle return self._loader.path_dwim_relative_stack(path_stack, dirname, needle) File "/opt/rh/rh-python36/root/lib/python3.6/site-packages/ansible/parsing/dataloader.py", line 319, in path_dwim_relative_stack raise AnsibleFileNotFound(file_name=source, paths=[to_text(p) for p in search]) ansible.errors.AnsibleFileNotFound: Could not find or access '/tmp/testfile' on the Ansible Controller. If you are using a module and expect the file to exist on the remote, see the remote_src option

2 Answers 2

1

Before running the playbook, Ansible AWX makes a copy of the files from the project path to the path /tmp path. If your project is large, it can cause a delay when starting the job.

If your playbook uses absolute paths, problems can also occur, as the job will actually run the playbook from /tmp.

Run any playbook and check the awx_task container, the path /tmp will temporarily receive a copy of your project files

0

Ah. After many hours of fighting it, I have a solution, but it doesn't feel like the right one.

I tried removing the leading / from the src, making it "tmp/testfile" and re-ran the playbook.

THIS time AWX/Ansible gave a more useful error message:

   ansible.errors.AnsibleFileNotFound: Could not find or access 'tmp/satestfile'
    Searched in:
        /var/lib/awx/projects/simon/files/tmp/satestfile
        /var/lib/awx/projects/simon/tmp/satestfile
        /var/lib/awx/projects/simon/files/tmp/satestfile…

So it is saving things on the main directory structure, but doesn't like absolute paths, which seems odd.

I then created the testfile in one of the named directories and AWX completed the task successfully.

Would still like an explanation if anyone understands this better than I.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.