Ansible: Unable to find in expected paths

Software

I was copying a file on a remote server to another location, to modify with required settings. I often prefer this to using templates, so I’m always working with the latest config.

- name: Move config to expected place
  copy:
  src: "[SOURCE FILE]"
    dest: "[DESTINATION FILE]"
    force: no  ## don't overwrite

But when I ran the playbook:

fatal: [IP]: FAILED! => {  
    "changed": false,  
    "failed": true,  
    "msg": "Unable to find '[SOURCE FILE]' in expected paths."  
}

Turns out, copy transfers from local to remote by default, so it couldn’t find it. If you include the following directive, the source is defined as remote:

[..]
remote_src: yes

Done.

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

You can leave me a comment by contacting me, and I might publish your thoughts. Please read the FAQs first though.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!