feat: Add abspath to collection.
This commit is contained in:
31
plugins/README.md
Normal file
31
plugins/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Collections Plugins Directory
|
||||
|
||||
This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that
|
||||
is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that
|
||||
would contain module utils and modules respectively.
|
||||
|
||||
Here is an example directory of the majority of plugins currently supported by Ansible:
|
||||
|
||||
```
|
||||
└── plugins
|
||||
├── action
|
||||
├── become
|
||||
├── cache
|
||||
├── callback
|
||||
├── cliconf
|
||||
├── connection
|
||||
├── filter
|
||||
├── httpapi
|
||||
├── inventory
|
||||
├── lookup
|
||||
├── module_utils
|
||||
├── modules
|
||||
├── netconf
|
||||
├── shell
|
||||
├── strategy
|
||||
├── terminal
|
||||
├── test
|
||||
└── vars
|
||||
```
|
||||
|
||||
A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html).
|
||||
22
plugins/filter/abspath.yml
Normal file
22
plugins/filter/abspath.yml
Normal 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
9
plugins/filter/files.py
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user