# Unable to add variables in lineinfile paramteres?

**URL:** <https://forum.ansible.com/t/unable-to-add-variables-in-lineinfile-paramteres/13051>\
**Category:** Ansible Project\
**Created:** [July 2, 2013, 5:59am UTC](https://forum.ansible.com/t/unable-to-add-variables-in-lineinfile-paramteres/13051 "2013-07-02T05:59:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priyadarshi\_Kunal](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@Priyadarshi\_Kunal](https://forum.ansible.com/u/Priyadarshi_Kunal)\
**Post date:** [July 2, 2013, 5:59am UTC](https://forum.ansible.com/t/unable-to-add-variables-in-lineinfile-paramteres/13051/1 "2013-07-02T05:59:57Z")

</div>

Hi,

I have been trying the following:

tasks:

- name: Disabling IPV6  
lineinfile: dest=/etc/sysctl.conf regexp=${item.regexp} line=${item.line}  
with\_items:
- {regexp=^net.ipv6.conf.all.disable\_ipv6 line=“net.ipv6.conf.all.disable\_ipv6 = 1”}
- {regexp=^net.ipv6.conf.default.disable\_ipv6 line=“net.ipv6.conf.default.disable\_ipv6 = 1”}
- {regexp=^net.ipv6.conf.lo.disable\_ipv6 line=“net.ipv6.conf.lo.disable\_ipv6 = 1”}

But the lineinfile module treats my variables as actual regex string and adds literal “${item.line}” string in my destination file.

How do I put the variable references for lineinfile module regexp and line parameters so that the values are substituted?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 2, 2013, 6:32pm UTC](https://forum.ansible.com/t/unable-to-add-variables-in-lineinfile-paramteres/13051/2 "2013-07-02T18:32:59Z")

</div>

It looks like you do not have your YAML hash defined well, it should look like this:

{ regexp: “some value”, line: “some other value” }
