You are conflating 2 different systems for 'relative path resolution':

The first applies to 'remote actions' run from 'cwd' on the target machine,
normally the home dir of the login user. But with local action translates
to the directory from which you invoked Ansible. This is what `file` is
using, it is hard to predict this from the play as I show below.

The second applies only to some plugins that use 'master' as a source (via
action plugins) like template/copy, etc follow a set of paths like this:
(<typedir> can be files/ vars/ or templates/ depending on plugin)

if inrole:
   role_dir/<typedir>/
   role_dir/tasks/
   role_dir/

play_dir/<typedir>/
play_dir/

In 1.9 this was somewhat broken and it pathed across this tree multiple
times and in 1.9.4 it even included 'cwd', but the above is the way this
was always meant to work as you can execute Ansible from anywhere (i.e
/tmp, /etc/, /dev/) and you cannot construct a playbook predictably that
way.

So I recommend you rewrite the `file` and `fetch` tasks to use role_path or
playbook_dir variables to use a predictable path, otherwise if you execute
from a different directory you will start having issues again.

Relying on cwd makes these all these commands work differently:
ansible-playbook ../path/to/plays/play.yml

ansible-playbook ./play.yml

ansible-playbook plays/play.yml

----------
Brian Coca

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7cHiDmWZgVF7d_wY94nLObcuLObMP-J4v%3DWWRC9X4dYQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to