Skip to content

Instantly share code, notes, and snippets.

@gorvin
Created June 1, 2017 08:05
Show Gist options
  • Save gorvin/f3ba28d75726717ab2478d6dbf88840d to your computer and use it in GitHub Desktop.
Save gorvin/f3ba28d75726717ab2478d6dbf88840d to your computer and use it in GitHub Desktop.
Ensure absolute path in ansible playbook
- set_fact:
relpath: "one/two/three"
abspath: "/four/five/six"
- debug: var={{item}}
with_items:
- relpath
- abspath
- set_fact:
"{{item.name}}": "/{{item.value}}"
when: 'not(item.value | match("^/.*"))'
with_items:
- { name: relpath, value: "{{relpath}}" }
- { name: abspath, value: "{{abspath}}" }
- debug: var={{item}}
with_items:
- relpath
- abspath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment