OK, that took care of it. Worked great! I appreciate the timely response!
Thanks, Harry On Tuesday, October 19, 2021 at 2:22:15 PM UTC-4 Matt Martz wrote: > from a quick glance, it looks like you would change `v.value` to `v.1` > > On Tue, Oct 19, 2021 at 1:02 PM [email protected] <[email protected]> > wrote: > >> So if I set the fact as follows: >> >> - name: Set package facts >> set_fact: >> packages: "{{ ansible_facts.packages|dictsort }}" >> >> How would I traverse that in my template?: >> >> {% for v in hostvars[i]['packages'] %} >> {% for pkg in v.value %} >> Package: {{ pkg.name }} Version: {{ pkg.version}} Arch: {{ pkg.arch >> }} Release: {{ pkg.release }} >> {% endfor %} >> {% endfor %} >> >> Thanks, >> Harry >> >> On Tuesday, October 19, 2021 at 1:32:41 PM UTC-4 Matt Martz wrote: >> >>> I'd recommend that you use `dictsort` instead of `dict2items` It >>> achieves the goal very similarly, but sorts by default, and would avoid the >>> error you are getting. >>> >>> The biggest difference is instead of having `item.key` and `item.value`, >>> you have `item.0` and `item.1`. >>> >>> >>> https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.dictsort >>> >>> On Tue, Oct 19, 2021 at 12:29 PM [email protected] <[email protected]> >>> wrote: >>> >>>> I am trying to sort a list when setting a fact in Ansible as follows: >>>> >>>> - name: Get installed packages >>>> become: true >>>> become_method: sudo >>>> package_facts: >>>> register: installed >>>> >>>> - name: Set package facts >>>> set_fact: >>>> packages: "{{ ansible_facts.packages|dict2items|sort }}" >>>> >>>> This works when I run it from the command line, but when I do this >>>> within Ansible Tower, I get the following error: >>>> >>>> Unexpected templating type error occurred on ({{ >>>> ansible_facts.packages|dict2items|sort }}): '<' not supported between >>>> instances of 'dict' and 'dict' >>>> >>>> I know this isn't a Tower list, but would anyone have any idea why this >>>> would work in the Ansible CLI but not in Tower? >>>> >>>> Thanks, >>>> Harry >>>> >>>> -- >>>> 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/132882cc-f901-4ed7-b768-72f052b0645fn%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/ansible-project/132882cc-f901-4ed7-b768-72f052b0645fn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> Matt Martz >>> @sivel >>> sivel.net >>> >> -- >> 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/8ffa97c9-2a4b-4ed9-80ca-b3cee0e78fa3n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/8ffa97c9-2a4b-4ed9-80ca-b3cee0e78fa3n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Matt Martz > @sivel > sivel.net > -- 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/854ebd21-7c3e-44e8-8e79-583ecef9ecdan%40googlegroups.com.
