Skip to content

Instantly share code, notes, and snippets.

@dochang
Created May 17, 2016 09:02
Show Gist options
  • Save dochang/6125f855c4f52e75f62243a71d414730 to your computer and use it in GitHub Desktop.
Save dochang/6125f855c4f52e75f62243a71d414730 to your computer and use it in GitHub Desktop.
A backported filter plugin for Ansible 1.9.x. Put it into `filter_plugins`.
import re
def regex_escape(string):
'''Escape all regular expressions special characters from STRING.'''
return re.escape(string)
class FilterModule(object):
'''Backported Ansible 2 filters for Ansible 1.9.x'''
def filters(self):
return {
'regex_escape': regex_escape,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment