| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright (c) 2021, Cisco Systems |
| 5 |
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = r""" |
| 8 |
module: networks_alerts_settings |
| 9 |
short_description: Resource module for networks _alerts _settings |
| 10 |
description: |
| 11 |
- Manage operation update of the resource networks _alerts _settings. |
| 12 |
- Update the alert configuration for this network. |
| 13 |
version_added: '1.0.0' |
| 14 |
extends_documentation_fragment: |
| 15 |
- cisco.meraki.module |
| 16 |
author: Francisco Munoz (@fmunoz) |
| 17 |
options: |
| 18 |
alerts: |
| 19 |
description: Alert-specific configuration for each type. Only alerts that pertain |
| 20 |
to the network can be updated. |
| 21 |
elements: dict |
| 22 |
suboptions: |
| 23 |
alertDestinations: |
| 24 |
description: A hash of destinations for this specific alert. |
| 25 |
suboptions: |
| 26 |
allAdmins: |
| 27 |
description: If true, then all network admins will receive emails for |
| 28 |
this alert. |
| 29 |
type: bool |
| 30 |
emails: |
| 31 |
description: A list of emails that will receive information about the |
| 32 |
alert. |
| 33 |
elements: str |
| 34 |
type: list |
| 35 |
httpServerIds: |
| 36 |
description: A list of HTTP server IDs to send a Webhook to for this alert. |
| 37 |
elements: str |
| 38 |
type: list |
| 39 |
smsNumbers: |
| 40 |
description: A list of phone numbers that will receive text messages about |
| 41 |
the alert. Only available for sensors status alerts. |
| 42 |
elements: str |
| 43 |
type: list |
| 44 |
snmp: |
| 45 |
description: If true, then an SNMP trap will be sent for this alert if |
| 46 |
there is an SNMP trap server configured for this network. |
| 47 |
type: bool |
| 48 |
type: dict |
| 49 |
enabled: |
| 50 |
description: A boolean depicting if the alert is turned on or off. |
| 51 |
type: bool |
| 52 |
filters: |
| 53 |
description: A hash of specific configuration data for the alert. Only filters |
| 54 |
specific to the alert will be updated. |
| 55 |
suboptions: |
| 56 |
conditions: |
| 57 |
description: Conditions. |
| 58 |
elements: dict |
| 59 |
suboptions: |
| 60 |
direction: |
| 61 |
description: Direction. |
| 62 |
type: str |
| 63 |
duration: |
| 64 |
description: Duration. |
| 65 |
type: int |
| 66 |
threshold: |
| 67 |
description: Threshold. |
| 68 |
type: float |
| 69 |
type: |
| 70 |
description: Type of condition. |
| 71 |
type: str |
| 72 |
unit: |
| 73 |
description: Unit. |
| 74 |
type: str |
| 75 |
type: list |
| 76 |
failureType: |
| 77 |
description: Failure Type. |
| 78 |
type: str |
| 79 |
lookbackWindow: |
| 80 |
description: Loopback Window (in sec). |
| 81 |
type: int |
| 82 |
minDuration: |
| 83 |
description: Min Duration. |
| 84 |
type: int |
| 85 |
name: |
| 86 |
description: Name. |
| 87 |
type: str |
| 88 |
period: |
| 89 |
description: Period. |
| 90 |
type: int |
| 91 |
priority: |
| 92 |
description: Priority. |
| 93 |
type: str |
| 94 |
regex: |
| 95 |
description: Regex. |
| 96 |
type: str |
| 97 |
selector: |
| 98 |
description: Selector. |
| 99 |
type: str |
| 100 |
serials: |
| 101 |
description: Serials. |
| 102 |
elements: str |
| 103 |
type: list |
| 104 |
ssidNum: |
| 105 |
description: SSID Number. |
| 106 |
type: int |
| 107 |
tag: |
| 108 |
description: Tag. |
| 109 |
type: str |
| 110 |
threshold: |
| 111 |
description: Threshold. |
| 112 |
type: int |
| 113 |
timeout: |
| 114 |
description: Timeout. |
| 115 |
type: int |
| 116 |
type: dict |
| 117 |
type: |
| 118 |
description: The type of alert. |
| 119 |
type: str |
| 120 |
type: list |
| 121 |
defaultDestinations: |
| 122 |
description: The network-wide destinations for all alerts on the network. |
| 123 |
suboptions: |
| 124 |
allAdmins: |
| 125 |
description: If true, then all network admins will receive emails. |
| 126 |
type: bool |
| 127 |
emails: |
| 128 |
description: A list of emails that will receive the alert(s). |
| 129 |
elements: str |
| 130 |
type: list |
| 131 |
httpServerIds: |
| 132 |
description: A list of HTTP server IDs to send a Webhook to. |
| 133 |
elements: str |
| 134 |
type: list |
| 135 |
snmp: |
| 136 |
description: If true, then an SNMP trap will be sent if there is an SNMP trap |
| 137 |
server configured for this network. |
| 138 |
type: bool |
| 139 |
type: dict |
| 140 |
muting: |
| 141 |
description: Mute alerts under certain conditions. |
| 142 |
suboptions: |
| 143 |
byPortSchedules: |
| 144 |
description: Mute wireless unreachable alerts based on switch port schedules. |
| 145 |
suboptions: |
| 146 |
enabled: |
| 147 |
description: If true, then wireless unreachable alerts will be muted when |
| 148 |
caused by a port schedule. |
| 149 |
type: bool |
| 150 |
type: dict |
| 151 |
type: dict |
| 152 |
networkId: |
| 153 |
description: NetworkId path parameter. Network ID. |
| 154 |
type: str |
| 155 |
requirements: |
| 156 |
- meraki >= 2.4.9 |
| 157 |
- python >= 3.5 |
| 158 |
seealso: |
| 159 |
- name: Cisco Meraki documentation for networks updateNetworkAlertsSettings |
| 160 |
description: Complete reference of the updateNetworkAlertsSettings API. |
| 161 |
link: https://developer.cisco.com/meraki/api-v1/#!update-network-alerts-settings |
| 162 |
notes: |
| 163 |
- SDK Method used are |
| 164 |
networks.Networks.update_network_alerts_settings, |
| 165 |
- Paths used are |
| 166 |
put /networks/{networkId}/alerts/settings, |
| 167 |
""" |
| 168 |
|
| 169 |
EXAMPLES = r""" |
| 170 |
- name: Update all |
| 171 |
cisco.meraki.networks_alerts_settings: |
| 172 |
meraki_api_key: "{{ meraki_api_key }}" |
| 173 |
meraki_base_url: "{{ meraki_base_url }}" |
| 174 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 175 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 176 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 177 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 178 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 179 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 180 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 181 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 182 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 183 |
meraki_output_log: "{{ meraki_output_log }}" |
| 184 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 185 |
meraki_log_path: "{{ meraki_log_path }}" |
| 186 |
meraki_print_console: "{{ meraki_print_console }}" |
| 187 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 188 |
meraki_simulate: "{{ meraki_simulate }}" |
| 189 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 190 |
meraki_caller: "{{ meraki_caller }}" |
| 191 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 192 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 193 |
state: present |
| 194 |
alerts: |
| 195 |
- alertDestinations: |
| 196 |
allAdmins: false |
| 197 |
emails: |
| 198 |
- [email protected] |
| 199 |
httpServerIds: |
| 200 |
- aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vd2ViaG9va3M= |
| 201 |
smsNumbers: |
| 202 |
- '+15555555555' |
| 203 |
snmp: false |
| 204 |
enabled: true |
| 205 |
filters: |
| 206 |
conditions: |
| 207 |
- direction: + |
| 208 |
duration: 0 |
| 209 |
threshold: 72.5 |
| 210 |
type: temperature |
| 211 |
unit: celsius |
| 212 |
failureType: 802.1X auth fail |
| 213 |
lookbackWindow: 360 |
| 214 |
minDuration: 60 |
| 215 |
name: Filter |
| 216 |
period: 1800 |
| 217 |
priority: '' |
| 218 |
regex: '[a-z]' |
| 219 |
selector: '{"smartSensitivity":"medium","smartEnabled":false,"eventReminderPeriodSecs":10800}' |
| 220 |
serials: |
| 221 |
- Q234-ABCD-0001 |
| 222 |
- Q234-ABCD-0002 |
| 223 |
- Q234-ABCD-0003 |
| 224 |
ssidNum: 1 |
| 225 |
tag: tag1 |
| 226 |
threshold: 30 |
| 227 |
timeout: 60 |
| 228 |
type: gatewayDown |
| 229 |
defaultDestinations: |
| 230 |
allAdmins: true |
| 231 |
emails: |
| 232 |
- [email protected] |
| 233 |
httpServerIds: |
| 234 |
- aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vd2ViaG9va3M= |
| 235 |
snmp: true |
| 236 |
muting: |
| 237 |
byPortSchedules: |
| 238 |
enabled: true |
| 239 |
networkId: string |
| 240 |
""" |
| 241 |
RETURN = r""" |
| 242 |
meraki_response: |
| 243 |
description: A dictionary or list with the response returned by the Cisco Meraki Python SDK |
| 244 |
returned: always |
| 245 |
type: dict |
| 246 |
sample: > |
| 247 |
{ |
| 248 |
"defaultDestinations": { |
| 249 |
"emails": [ |
| 250 |
"string" |
| 251 |
], |
| 252 |
"allAdmins": true, |
| 253 |
"snmp": true, |
| 254 |
"httpServerIds": [ |
| 255 |
"string" |
| 256 |
] |
| 257 |
}, |
| 258 |
"alerts": [ |
| 259 |
{ |
| 260 |
"type": "string", |
| 261 |
"enabled": true, |
| 262 |
"alertDestinations": { |
| 263 |
"emails": [ |
| 264 |
"string" |
| 265 |
], |
| 266 |
"smsNumbers": [ |
| 267 |
"string" |
| 268 |
], |
| 269 |
"allAdmins": true, |
| 270 |
"snmp": true, |
| 271 |
"httpServerIds": [ |
| 272 |
"string" |
| 273 |
] |
| 274 |
}, |
| 275 |
"filters": { |
| 276 |
"conditions": [ |
| 277 |
{ |
| 278 |
"type": "string", |
| 279 |
"unit": "string", |
| 280 |
"duration": 0, |
| 281 |
"direction": "string", |
| 282 |
"threshold": 0 |
| 283 |
} |
| 284 |
], |
| 285 |
"failureType": "string", |
| 286 |
"lookbackWindow": 0, |
| 287 |
"minDuration": 0, |
| 288 |
"name": "string", |
| 289 |
"period": 0, |
| 290 |
"priority": "string", |
| 291 |
"regex": "string", |
| 292 |
"selector": "string", |
| 293 |
"serials": [ |
| 294 |
"string" |
| 295 |
], |
| 296 |
"ssidNum": 0, |
| 297 |
"tag": "string", |
| 298 |
"threshold": 0, |
| 299 |
"timeout": 0 |
| 300 |
} |
| 301 |
} |
| 302 |
], |
| 303 |
"muting": { |
| 304 |
"byPortSchedules": { |
| 305 |
"enabled": true |
| 306 |
} |
| 307 |
} |
| 308 |
} |
| 309 |
""" |