I believe that using the template lookup instead of the file lookup is
what you want.  So something like:

   body: "{{ lookup('template',
'roles/grafana/templates/datasource.json.js') }}"

-Toshio

On Tue, Sep 22, 2015 at 11:38 AM, Pär Svensson <[email protected]> wrote:
> Hello!
>
> I'm trying to make a task that uses a REST api to do some final
> configuration of a previously installed component.
> I want to make a POST request with a body that is a template that uses host
> specific variables.
>
> The closest i've come up with is the following:
>
> - name: Adding datasource via http api
>   uri:
>     url: http://{{ inventory_hostname }}:3000/api/datasources
>     method: POST
>     body_format: json
>     HEADER_Content-Type: "application/json"
>     body: "{{ lookup('file' , 'roles/grafana/templates/datasource.json.j2')
> }}"
>
> which sends the template-file as body, but unfortunately without any
> variables substituted...
>
> Any idea how i should approach the problem?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/43016a1f-b11b-4e7a-bc11-c6358185f677%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG9juEq9i1aXjpK6DxfB2_5mBBQdPX6ckULu7vcA3YHXGHuSwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to