Do conditionals work with the replace module?

Do conditionals work with the replace module?

I have something like this:

`

  • name: Set date for demo 1
    replace: dest={{ workdirectory2 }}/junk.java regexp=‘2016’ replace=“{{ hostvars[‘localhost’][‘year’] }}”
    when: (is_demo and “‘{{ hostvars[‘localhost’][‘soft’] }}’ == ‘newapp’”)
    `

And it appears to ignore the “when” conditional entirely and always executes the replace.

J

So, this DOES work:

`

  • name: Set date for demo 1
    replace: dest={{ workdirectory2 }}/junk.java regexp=‘2016’ replace=“{{ hostvars[‘localhost’][‘year’] }}”
    when: (is_demo and ‘{{ hostvars[‘localhost’][‘soft’] }}’ == ‘newapp’)
    `

Simply removing the double quotes around the 2nd part of the conditional makes it work. So the new question is: Is that a bug?

J

no, you are doing and " " string before, which is always true. unless its an empty string. The when will not arbitrarily look inside quotes in hopes there is another conditional in there.