Papouche Guinslyzinho
Papouche Guinslyzinho

Reputation: 5458

How to resolve ansible issue: Failed to get information on remote file ... Not a directory

When I run a playbook ansible-playbook my-playbook.ymlI am getting this error. But I don't have any file on remote named test.yml.

error

TASK [linux-common : copy files to server] *************************************
Saturday 01 August 2020  01:16:19 -0400 (0:00:00.904)       0:00:55.791 ******* 
ok: [172.125.29.147] => (item=/root/downloads/README.md)
fatal: [172.125.29.147]: FAILED! => {"msg": "Failed to get information on remote file (/app/ansible/test.yml): Not a directory"}

On the remote host. A directory named 'app' has been created but no files is in it.

try-playbook.yml

 ---
 - hosts: flaskbox_dev
 
   remote_user: root
   roles:
     - linux-common

[playbook roles]linux-common/tasks/main.yml

- name: copy files to server
  copy: 
    src: "{{ item }}"
    dest: /app
  loop:
    - /root/odesi_downloads/README.md
    - ./ansible
    - ./tasks.todo
    - ./conf.d
    - ./cronjobs
    - ./dockerfiles
    - ./dotfiles
    - ./flaskapp
    - ./requirements
    - ./screenshots
    - ./Makefile
    - ./README.md
    - ./run.py
    - ./.coveragerc
    - ./inventory
    - ./pytest.ini
    - ./tests
    - ./app_test.py
  register: copy_output
- debug: var=copy_output

I have been using my playbook for 2 weeks and that is the first time that I have that issue. I upgraded ansible to 2.9.11 and still have the same issue.

Upvotes: 2

Views: 16334

Answers (1)

Papouche Guinslyzinho
Papouche Guinslyzinho

Reputation: 5458

I had to create the folder /app before copying my file

 - name: Create Folder /app if not exist
   file:
     path: /app
     mode: 0755
     state: directory

- name: copy files to server
  copy: 
    src: "{{ item }}"
    dest: /app
  loop:
    - /root/odesi_downloads/README.md
    - ./ansible
    - ./tasks.todo
    - ./conf.d
    - ./cronjobs
    - ./dockerfiles
    - ./dotfiles
    - ./flaskapp
    - ./requirements
    - ./screenshots
    - ./Makefile
    - ./README.md
    - ./run.py
    - ./.coveragerc
    - ./inventory
    - ./pytest.ini
    - ./tests
    - ./app_test.py
  register: copy_output
- debug: var=copy_output

Upvotes: 1

Related Questions