I thought we were on Jinja 3?

On Wed, Oct 20, 2021, 6:48 PM Clint Denham <clintden...@gmail.com> wrote:

> Can you post a little of update_results?
>
> Sometimes with this error you just need to include the list reference. 0
> being the first list.
>
> update_results.0.updstes[k]
>
> Once we get the entire update_results we can see for sure.
>
> On Wed, Oct 20, 2021, 12:25 PM John-Paul Pagano <john.pag...@time.com>
> wrote:
>
>>  ansible-playbook [core 2.11.5]
>>   python version = 3.9.7 (default, Sep  3 2021, 12:45:31) [Clang 12.0.0
>> (clang-1200.0.32.29)]
>>   jinja version = 2.11.3
>>
>> Hi,
>>
>> I'm trying to write a play that will connect to a managed Windows node,
>> gather a list of Windows Updates that are available to be installed on it,
>> and output that list to stdout. Below is what I've cobbled together, but it
>> doesn't fully work. While the list is dumped as expected to the local file
>> "win_updates.log", it is not also copied to stdout. The error I get is
>> "msg": "The task includes an option with an undefined variable. The error
>> was: list object has no element".
>>
>> It appears that the 'k' variable in the for loop in the Jinja 2 routine
>> is unset, presumably because the "update_results" variable in the play
>> isn't available to it. Can you help me understand what I'm doing wrong?
>>
>> Thanks!
>>
>> - name: List all updates that might be installed
>>   hosts: all
>>
>>   tasks:
>>
>>     - name: Find possible updates
>>     become: true
>>     become_method: runas
>>     become_user: SYSTEM
>>     win_updates:
>>       category_names: '*'
>>       state: searched
>>       log_path: C:/Users/MY_USER/win_updates.log
>>     register: update_results
>>
>>   - debug:
>>       msg: |
>>         {% for k in update_results.updates %}
>>         {{ update_results.updates[k].title }}
>>         {% endfor %}
>>
>> --
>> 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 ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/c4d495a1-cac5-4c84-9f66-67280941f14dn%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/c4d495a1-cac5-4c84-9f66-67280941f14dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAA92%3DYNs4WG%2BGoMtfNdC-qWhuR_vvL--XOA3jfA%3DiF1ZsMy%2BqA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAA92%3DYNs4WG%2BGoMtfNdC-qWhuR_vvL--XOA3jfA%3DiF1ZsMy%2BqA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACejsYn%3Dj-QRVLGhGQp_Rku3AqSgPtrKjegxV_JNc2cs%2B1Gfcg%40mail.gmail.com.

Reply via email to