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 }} 

other useful filters


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.

from http://docs.ansible.com/ansible/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -