On Tue, 20 Aug 2024 16:16:17 -0600 Alex Wanderley <[email protected]> wrote:
> Hi,
>
> OK, answering my own question, I was able to send the parsed vm_list
> content to a file using this task:
>
> - name: Copy list to file
> ansible.builtin.lineinfile:
> dest: <path_to_file_here>
> line: "{{ item['guest_name'] }}"
> state: present
> create: yes
> loop: "{{ vm_list.virtual_machines }}"
>
> There would be a different/better way of accomplishing that...?
Try this
- copy:
dest: <path_to_file_here>
content: |
{% for i in vm_list.virtual_machines %}
{{ i.guest_name }}
{% endfor %}
See
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_templating.html
--
Vladimir Botka
--
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/20240821005716.701bac09%40gmail.com.
pgp8Vv9Q_CxrZ.pgp
Description: OpenPGP digital signature
