Misko
Misko

Reputation: 1606

Ansible: is it possible to Jinja2 filter the content picked up by lookup()?

I'm sending a REST API query using Ansible uri module. The body content is picked up from a file:

body: "{{ lookup('file',mp_config_path + item.file) }}"

There are some variables in my file - is it possible to tell ansible to run Jinja2 filters on it before sending it to the uri module?

Upvotes: 0

Views: 1381

Answers (1)

techraf
techraf

Reputation: 68469

And how about using template lookup?

body: "{{ lookup('template',mp_config_path + item.file) }}"

or:

- uri:
    body: "{{ item }}"
    # other parameters
  with_template: "{{ mp_config_path + item.file }}"

Upvotes: 2

Related Questions