Hi,

> Yes. Or if you feel like ignoring the warnings^* about using
> variables in copy's "content":
> 
>      - name: Write to the file
>        ansible.builtin.copy:
>          content: |
>            {% for server in servers %}
>            {{ server }}
>            {% endfor %}
>          dest: "{{my_inv}}"
> 
> ^* I do it quite often, looking for cases where the promised
> unexpected surprises happen, but I haven't found them yet. It'll
> probably happen some day when it least convenient. :)

I got bitten by this somewhen in the past when the input for `content`
turned out to be valid JSON. Ansible parsed it and converted it to the
Python representation of the dictionary, which wasn't valid JSON
anymore (`"` converted to `'`).

But that's something rather special, for many simple templates such as
yours it's no problem at all (and I also use `content` for that).

Cheers,
Felix

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20230801073414.40030793%40rovaniemi.

Reply via email to