Im trying to build a very simple plugin filter within a role. However, when I go to test the plugin it doesnt detect it. Ansible version is 2.9.
dir
(base) root@8c08139d265e:/workspace# tree
.
├── Dockerfile
├── Makefile
├── README.md
├── defaults
│ └── main.yml
├── filter_plugins
│ ├── __init__.py
│ └── sample_filter.py
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── requirements.txt
├── tasks
│ └── main.yml
├── tests
│ ├── inventory
│ └── test.yml
└── vars
└── main.yml
Plugin
(base) root@8c08139d265e:/workspace# cat filter_plugins/sample_filter.py
class FilterModule(object):
def filters(self):
return {'cloud_truth': cloud_truth}
def cloud_truth(a):
print(type(a))
return a.replace("the cloud", "somebody else's computer")
test
(base) root@8c08139d265e:/workspace# cat tests/test.yml
---
- name: test cloud_truth filter
hosts: localhost
roles:
- .
vars:
statement: "I store my files in the cloud"
tasks:
- name: make a statement
debug:
msg: "{{ statement | cloud_truth }}"
error
TASK [make a statement] *****************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "template error while templating string: no filter named 'cloud_truth'. String: {{ statement | cloud_truth }}"}
Thanks,