Hello,
I am trying to get a list of devices that are out of compliance with Cisco licensing. I would like to take failed out of compliance devices and add them to a list. Then send it to Microsoft Teams.
What I am looking for is a list to just send to Teams once, instead of trying to send multiple calls for each failure. Teams does not like it when you make multiple calls in quick succession.
The way that I am currently doing it is taking the host name and splitting each letter and joining with a comma. This was just my last attempt. I also tried with_items but it seems to just be tied to each host and not a global variable. Which makes sense in most cases… Any help would be appreciated.
-
name: Get License Information
cisco.ios.ios_command:
commands: “show license summary”
register: license3 -
name: Assert that it is registered and authorized
block: -
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: Add the device to the OOC list
set_fact: #### This is the piece that does not work.
OOC: “{{ inventory_hostname | join(', ') }}” -
name: Send a team message of OUT OF COMPLIANCE devices
uri:
url: “webhook”
method: POST
status_code: 200
body_format: json
body: |
{
“title”: “Smart License Out of Compliance Devices”,
“text”: “{{ OOC }},”
}
run_once: True
tags: notifications -
name: Debug
debug:
var: OOC
verbosity: 0
run_once: True