Lookup failing from file

Running a playbook where contents are read from a file. It is an XML file.

Playbook yaml:

Hi Anuj, what version of Ansible are you using?

Hi Anuj, what version of Ansible are you using?

1.7.1

Observation: It behaves strangely when there are spaces within a pair of quotes. And, my xml file has spaces within quotes in it.

If you do msg=“the value of contents is ‘{{XmlFileContents}}’” does it still raise an error?

If you do msg="the value of contents is '{{XmlFileContents}}'" does it
still raise an error?

Yes, it still raises the same error.

Ok, could you open an issue for this on GitHub and I’ll take a look at it ASAP. You might also want to try checking out the version from GitHub and see if the issue is resolved there.

Thanks!

Anuj Agrawal <anujagrawal83@gmail.com> napisał:

Running a playbook where contents are read from a file. It is an XML
file.

Playbook yaml:
---

- hosts: all
gather_facts: false

vars:
   XmlFileContents: "{{ lookup('file',
'files/spring-proxy-handler-config.xml') }}"

tasks:
   - debug: msg="the value of contents is {{XmlFileContents}}"

Error:
fatal: [myhost.com] => A variable inserted a new parameter into the
module
args. Be sure to quote variables if they contain equal signs (for
example:
"{{var}}").

It is a xml file containing some config and the file definitely has
some
equal signs in it. However, I do not understand the error message and,
hence, cannot figure out a solution to my problem.

A workaround for this is using complex args:
- debug:
    msg: '{{ XmlFileContents }}'