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 infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

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

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.