feat: Add abspath to collection.

This commit is contained in:
2022-12-10 23:54:41 +01:00
commit d7b79fda63
6 changed files with 163 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
DOCUMENTATION:
name: abspath
author: Laur Ivan
version_added: "1.0"
short_description: Make a path absolute
positional: _input
description:
- Converts the given path to a absolute path.
options:
_input:
description: A path.
type: str
required: true
EXAMPLES: |
# foobar => ../test/me.txt
testing: "{{ '~/me.txt' | abspath }}"
otherrelpath: "{{ mypath | relpath }}"
RETURN:
_value:
description: The absolute path.
type: str

9
plugins/filter/files.py Normal file
View File

@@ -0,0 +1,9 @@
from functools import partial
from ansible.utils.unicode import unicode_wrap
class FilterModule(object):
''' Ansible file jinja2 filters '''
def filters(self):
return {
'abspath': partial(unicode_wrap, os.path.abspath)
}