path - Get parent directory in Ansible? -
is there way evaluate relative path in ansible?
tasks: - name: run docker containers include: tasks/dockerup.yml src_code='..'
essentially interested in passing source code path task. happens source code parent path of {{ansible_inventory}}
there doesn't seem accomplish out of box.
---- further info ----
project structure:
myproj app deploy deploy.yml
so trying access app
deploy.yml
.
i had @ source , found filter wasn't aware of. forget previous string operations, it's simple:
{{ inventory_dir | dirname }}
previous answer:
this should it:
{{ inventory_dir.split("/")[0:-1]|join("/") }}
previous answer:
does {{ inventory_dir }}
want?
also available,
inventory_dir
pathname of directory holding ansible’s inventory host file
or if mean "parent directory" path of role task in, {{ role_path }}
might trick.
and finally,
role_path
return current role’s pathname (since 1.8). work inside role.
Comments
Post a Comment