On Thu, 29 Aug 2019 10:04:55 -0700 (PDT)
Tuyen Nguyen <[email protected]> wrote:

> - set_fact:
>     my_data: "{{lookup('file','patchlist.txt')|from_yaml}}"
> and then in the whitelist option of win_updates:
>       whitelist: "{{my_data}}"
> 
> The only caveat is that I need to make my patchlist.txt file to be in the 
> form of
> 
> - patch1
> - patch2
> 
> instead of it normally being
> patch1
> patch2
> 
> Is there an easy way as part of the Ansible playbook or in the lookup 
> function itself to read the normal file and then convert it to having the - 
> automatically?  Or should I add a new play in the playbook to add the "- " 
> in front of the file?

If you want to get list of lines try this

      - set_fact:
          my_patch_list: "{{ my_patch_list|default([]) + [item] }}"
        loop: "{{ lookup('file','patchlist.txt').splitlines() }}"

Cheers,

        -vlado

-- 
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/20190829194710.472d5fe8%40gmail.com.

Attachment: pgpkatZteQYrs.pgp
Description: OpenPGP digital signature

Reply via email to