# Single quote characters were lost while using lineinfile for replacing

**URL:** <https://forum.ansible.com/t/single-quote-characters-were-lost-while-using-lineinfile-for-replacing/19871>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [November 27, 2015, 7:05am UTC](https://forum.ansible.com/t/single-quote-characters-were-lost-while-using-lineinfile-for-replacing/19871 "2015-11-27T07:05:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_John](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Tim\_John](https://forum.ansible.com/u/Tim_John)\
**Post date:** [November 27, 2015, 7:05am UTC](https://forum.ansible.com/t/single-quote-characters-were-lost-while-using-lineinfile-for-replacing/19871/1 "2015-11-27T07:05:04Z")

</div>

Hi,

I’m trying to use lineinfile module to replacing a line which matches the regular expression. The file content is:

```plaintext
**#TIMEZONE='America/Chicago'**

```

_ **P.S.** Ignore the Markdown tags_

```yaml
---
- hosts: servers
remote_user: root
tasks:
- name: customize timezone configuration
lineinfile: dest=/tmp/test.txt regexp="^#TIME_ZONE.*$" line="TIME_ZONE='Asia/Yakutsk'" state=present

```

The first playbook (above) works just fine, the result line would be TIMEZONE=‘Asia/Yakutsk’. But the result of the second playbook (below) is TIME\_ZONE=Asia/Yakutsk. See? The single quote characters were missing! Why does that happen? And How Can I make the second playbook work correctly?

```yaml
---
- hosts: servers
remote_user: root
tasks:
- name: customize timezone configuration
lineinfile: dest=/tmp/test.txt regexp={{ item.default }} line={{ item.custom }} state=present
with_items:
- { default: "^#TIME_ZONE.*$", custom: "TIME_ZONE='Asia/Yakutsk'" }

```

Ansible Version: 1.5.4  
Ansible Host: Ubuntu 14.04.1 x86\_64 (3.16.0-30-generic)  
Manipulated Server: CentOS 7.0 x86\_64 (3.10.0-123.el7)  
Ansible configuration: default
