ansible/ansible — pull request #8468 by renard (2014-08-06 09:05:38+00:00)
Title: Add regular expression escaping filter.

##### Issue Type:

Feature Pull Request

##### Ansible Version:

```
ansible 1.7 (devel 0bb1c85)
```

##### Environment:

All

##### Summary:

Add a `re_escape` filter to allow escaping special re chars. This is useful
for example for the `lineinfile` module if you have special characters.

##### How to use:

```yml
- name: Create sudo entry
lineinfile:
dest: "/etc/sudoers.d/{{ item.name }}"
mode: 0440
create: yes
regexp: '^{{ item.line|re_escape() }}'
line: '{{ item.line | default() }}'
state: '{{ item.state | default("present") }}'
with_items:
- { name: john, line: 'Host_Alias HOSTS = dev*' }
- { name: john, line: 'john HOSTS=(ALL) NOPASSWD:ALL' }

```