Unable to add variables in lineinfile paramteres?

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?

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

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