Could not find or access a file that is in the local directory

25,182

Solution only for "Files"


okay, I am gonna keep this, just in case someone will stumble upon the same problem as I did ... the thing i messed up is that src: is looking into the roles templates files ... the error has told me that its accessing the full path which is not true ... its accessing only a templates file and it continues from there ...

fixed code:

- name: Copying required files
  template:
    src: docker-compose.yml
    dest: /tmp/docker_registry
Share:
25,182
StyleZ
Author by

StyleZ

I am a computer science student [ Bc ; 4.year -> 8. semester ] Last work experience : Tieto (DataCenter testcase automation) Currently working at : Red Hat Software Quality Engineer // since february 2021 Currently working at : Lasaris Lab FI MUNI C# developer // since september 2020 Hatsune Mike profile picture from here -> https://wall.alphacoders.com/big.php?i=826298 The guy sitting profile picture here => https://www.pinterest.co.uk/pin/626492998166824198/

Updated on August 07, 2020

Comments

  • StyleZ
    StyleZ over 3 years

    I have got an error in my project, when I am trying to copy from local directory to remote one

    error message:

    fatal: [xxx]: FAILED! => {
    "changed": false, "msg": "could not find 
    src=/Users/xxx/Desktop/Docker/The_Task/./roles/docker_registry/templates,
    Could not find or access 
    '/Users/xxx/Desktop/Docker/The_Task/./roles/docker_registry/templates' 
    on the Ansible Controller.\n
    If you are using a module and expect the file to exist on the remote, see the remote_src option"
    }
    

    playbook.yml

    - name: Copying required files
      template:
        src: ./roles/docker_registry/templates
        dest: /tmp/docker_registry
    

    if i do:

    cd /Users/xxx/Desktop/Docker/The_Task/./roles/docker_registry/templates
    

    it changes directory to the directory i want to ... the error seems to be from ansible side. ( it doesnt work with absolute path eighter )

    if I use the default copy module, then it works pretty much fine

    - name: copy files [local -> remote]
      copy:
        src: ./roles/docker_registry/templates
        dest: /tmp/docker_registry
    

    any idea what should i do to make it work ? [ its copying from LOCAL -> REMOTE ]


    But still i can not copy the whole dir into the remote machine

    • StyleZ
      StyleZ over 4 years
      50% closed ( solved only for files, not directories )