expanduser

Often, paths to various things are supplied with a user shortcut, such as ~/.stackrc. However, some tasks may require the full path to the file. Rather than the complicated command and register calls, the expanduser filter provides a way to expand the path to the full definition. In this example, the username is jfreeman:

---
- name: demo the filters
hosts: localhost
gather_facts: false
tasks:
- name: demo filter
debug:
msg: "{{ '~/.stackrc' | expanduser }}"

The output is shown in the following screenshot:

We have successfully expanded the path here, which could be useful for creating configuration files or performing other file operations that might need an absolute rather than a relative path name.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.225