Filter plugins
While Jinja2 includes a number of filters, Ansible has made filters pluggable to extend the Jinja2 functionality. Ansible includes a number of filters that are useful for Ansible operations, and users of Ansible can add more. Existing plugins can be found in plugins/filter/.
To demonstrate the development of a filter plugin, we will create a simple filter plugin to do a silly thing to text strings. We will create a filter that will replace any occurrence of the words the cloud with the string somebody else's computer. We'll define our filter in a file within a new directory, filter_plugins/, in our existing working directory. The name of the file doesn't matter, as we'll define the name of the filter within the file; so, let's ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access