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/20201023233544.4aee4de2%40gmail.com.

Attachment: pgp2TuaROGjGJ.pgp
Description: OpenPGP digital signature

Reply via email to