Worked - Just had to add {{ OOC | join(', ') }} to clean up the output. Thank you Vladimir.
On Fri, Oct 23, 2020 at 4:35 PM Vladimir Botka <vbo...@gmail.com> wrote: > Set variable OOC_status in the block and use it to select the list of > the hosts. See the inline code below (not tested) > > On Fri, 23 Oct 2020 12:47:45 -0700 (PDT) > "colli...@gmail.com" <collinsj...@gmail.com> wrote: > > > I am trying to get a list of devices that are out of compliance with > Cisco > > licensing... > > > > - name: Get License Information > > cisco.ios.ios_command: > > commands: "show license summary" > > register: license3 > > > > - name: Assert that it is registered and authorized > > block: > > - name: Set status omit host > set_fact: > OOC_status: false > > > - name: Asset that it is authorized > > assert: > > that: > > - "'Status: AUTHORIZED' in license3.stdout[0]" > > fail_msg: "Device is not Authorized" > > success_msg: "Device Authorized" > > rescue: > > - name: Set status add host > set_fact: > OOC_status: true > > - name: Add devices to the OOC list > set_fact: > OOC: "{{ hostvars|dict2items| > json_query('[?value.OOC_status].key') }}" > run_once: true > > - name: Send a team message ... > > -- > 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAANJ-QSEf2zVWRWk7_mf35nhkyGm_C6vj%3DDTxLurixrXFMG40w%40mail.gmail.com.