Skip to content

lloydhazlett/ansible-string-split-filter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ansible-string-split-filter

A simple Ansible Jinja2 filter to split a string into a list.

Setup

See the plugin documentation.

Usage

split(delimiter)

split_regex(pattern) #regex syntax is identical to Pythons)#

Examples

In a Jinja 2 template:

# hostname = dev.example.com
ldap_server = "dc={{ hostname | split('.') | join(',dc=') }}"

Output:

ldap_server = dc=dev,dc=example,dc=com

The same example, using split_regex:

ldap_server = "dc={{ hostname | split_regex('\.') | join(',dc=') }}"

Contributing

Any improvements are welcome. This is actually my first time publishing reusable code, so any feedback on making open-source code more useful is also appreciated!

About

An extremely simple Ansible Jinja2 filter to split a string into a list.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%