| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
from __future__ import absolute_import, division, print_function |
| 8 |
__metaclass__ = type |
| 9 |
|
| 10 |
|
| 11 |
DOCUMENTATION = ''' |
| 12 |
--- |
| 13 |
module: azure_rm_appgateway |
| 14 |
version_added: "0.1.2" |
| 15 |
short_description: Manage Application Gateway instance |
| 16 |
description: |
| 17 |
- Create, update and delete instance of Application Gateway. |
| 18 |
|
| 19 |
options: |
| 20 |
resource_group: |
| 21 |
description: |
| 22 |
- The name of the resource group. |
| 23 |
required: True |
| 24 |
type: str |
| 25 |
name: |
| 26 |
description: |
| 27 |
- The name of the application gateway. |
| 28 |
required: True |
| 29 |
type: str |
| 30 |
location: |
| 31 |
description: |
| 32 |
- Resource location. If not set, location from the resource group will be used as default. |
| 33 |
type: str |
| 34 |
sku: |
| 35 |
description: |
| 36 |
- SKU of the application gateway resource. |
| 37 |
type: dict |
| 38 |
suboptions: |
| 39 |
name: |
| 40 |
description: |
| 41 |
- Name of an application gateway SKU. |
| 42 |
type: str |
| 43 |
choices: |
| 44 |
- 'standard_small' |
| 45 |
- 'standard_medium' |
| 46 |
- 'standard_large' |
| 47 |
- 'standard_v2' |
| 48 |
- 'waf_medium' |
| 49 |
- 'waf_large' |
| 50 |
- 'waf_v2' |
| 51 |
tier: |
| 52 |
description: |
| 53 |
- Tier of an application gateway. |
| 54 |
type: str |
| 55 |
choices: |
| 56 |
- 'standard' |
| 57 |
- 'standard_v2' |
| 58 |
- 'waf' |
| 59 |
- 'waf_v2' |
| 60 |
capacity: |
| 61 |
description: |
| 62 |
- Capacity (instance count) of an application gateway. |
| 63 |
type: int |
| 64 |
ssl_policy: |
| 65 |
description: |
| 66 |
- SSL policy of the application gateway resource. |
| 67 |
type: dict |
| 68 |
suboptions: |
| 69 |
disabled_ssl_protocols: |
| 70 |
description: |
| 71 |
- List of SSL protocols to be disabled on application gateway. |
| 72 |
type: list |
| 73 |
elements: str |
| 74 |
choices: |
| 75 |
- 'tls_v1_0' |
| 76 |
- 'tls_v1_1' |
| 77 |
- 'tls_v1_2' |
| 78 |
policy_type: |
| 79 |
description: |
| 80 |
- Type of SSL Policy. |
| 81 |
type: str |
| 82 |
choices: |
| 83 |
- 'predefined' |
| 84 |
- 'custom' |
| 85 |
policy_name: |
| 86 |
description: |
| 87 |
- Name of Ssl C(predefined) policy. |
| 88 |
type: str |
| 89 |
choices: |
| 90 |
- 'ssl_policy20150501' |
| 91 |
- 'ssl_policy20170401' |
| 92 |
- 'ssl_policy20170401_s' |
| 93 |
cipher_suites: |
| 94 |
description: |
| 95 |
- List of SSL cipher suites to be enabled in the specified order to application gateway. |
| 96 |
type: list |
| 97 |
elements: str |
| 98 |
choices: |
| 99 |
- tls_ecdhe_rsa_with_aes_256_gcm_sha384 |
| 100 |
- tls_ecdhe_rsa_with_aes_128_gcm_sha256 |
| 101 |
- tls_ecdhe_rsa_with_aes_256_cbc_sha384 |
| 102 |
- tls_ecdhe_rsa_with_aes_128_cbc_sha256 |
| 103 |
- tls_ecdhe_rsa_with_aes_256_cbc_sha |
| 104 |
- tls_ecdhe_rsa_with_aes_128_cbc_sha |
| 105 |
- tls_dhe_rsa_with_aes_256_gcm_sha384 |
| 106 |
- tls_dhe_rsa_with_aes_128_gcm_sha256 |
| 107 |
- tls_dhe_rsa_with_aes_256_cbc_sha |
| 108 |
- tls_dhe_rsa_with_aes_128_cbc_sha |
| 109 |
- tls_rsa_with_aes_256_gcm_sha384 |
| 110 |
- tls_rsa_with_aes_128_gcm_sha256 |
| 111 |
- tls_rsa_with_aes_256_cbc_sha256 |
| 112 |
- tls_rsa_with_aes_128_cbc_sha256 |
| 113 |
- tls_rsa_with_aes_256_cbc_sha |
| 114 |
- tls_rsa_with_aes_128_cbc_sha |
| 115 |
- tls_ecdhe_ecdsa_with_aes_256_gcm_sha384 |
| 116 |
- tls_ecdhe_ecdsa_with_aes_128_gcm_sha256 |
| 117 |
- tls_ecdhe_ecdsa_with_aes_256_cbc_sha384 |
| 118 |
- tls_ecdhe_ecdsa_with_aes_128_cbc_sha256 |
| 119 |
- tls_ecdhe_ecdsa_with_aes_256_cbc_sha |
| 120 |
- tls_ecdhe_ecdsa_with_aes_128_cbc_sha |
| 121 |
- tls_dhe_dss_with_aes_256_cbc_sha256 |
| 122 |
- tls_dhe_dss_with_aes_128_cbc_sha256 |
| 123 |
- tls_dhe_dss_with_aes_256_cbc_sha |
| 124 |
- tls_dhe_dss_with_aes_128_cbc_sha |
| 125 |
- tls_rsa_with_3des_ede_cbc_sha |
| 126 |
- tls_dhe_dss_with_3des_ede_cbc_sha |
| 127 |
min_protocol_version: |
| 128 |
description: |
| 129 |
- Minimum version of SSL protocol to be supported on application gateway. |
| 130 |
type: str |
| 131 |
choices: |
| 132 |
- 'tls_v1_0' |
| 133 |
- 'tls_v1_1' |
| 134 |
- 'tls_v1_2' |
| 135 |
gateway_ip_configurations: |
| 136 |
description: |
| 137 |
- List of subnets used by the application gateway. |
| 138 |
type: list |
| 139 |
elements: dict |
| 140 |
suboptions: |
| 141 |
subnet: |
| 142 |
description: |
| 143 |
- Reference of the subnet resource. A subnet from where application gateway gets its private address. |
| 144 |
type: dict |
| 145 |
suboptions: |
| 146 |
id: |
| 147 |
description: |
| 148 |
- Full ID of the subnet resource. Required if I(name) and I(virtual_network_name) are not provided. |
| 149 |
type: str |
| 150 |
name: |
| 151 |
description: |
| 152 |
- Name of the subnet. Only used if I(virtual_network_name) is also provided. |
| 153 |
type: str |
| 154 |
virtual_network_name: |
| 155 |
description: |
| 156 |
- Name of the virtual network. Only used if I(name) is also provided. |
| 157 |
type: str |
| 158 |
name: |
| 159 |
description: |
| 160 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 161 |
type: str |
| 162 |
authentication_certificates: |
| 163 |
description: |
| 164 |
- Authentication certificates of the application gateway resource. |
| 165 |
type: list |
| 166 |
elements: dict |
| 167 |
suboptions: |
| 168 |
data: |
| 169 |
description: |
| 170 |
- Certificate public data - base64 encoded pfx. |
| 171 |
type: str |
| 172 |
name: |
| 173 |
description: |
| 174 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 175 |
type: str |
| 176 |
redirect_configurations: |
| 177 |
description: |
| 178 |
- Redirect configurations of the application gateway resource. |
| 179 |
type: list |
| 180 |
elements: dict |
| 181 |
suboptions: |
| 182 |
redirect_type: |
| 183 |
description: |
| 184 |
- Redirection type. |
| 185 |
type: str |
| 186 |
choices: |
| 187 |
- 'permanent' |
| 188 |
- 'found' |
| 189 |
- 'see_other' |
| 190 |
- 'temporary' |
| 191 |
target_listener: |
| 192 |
description: |
| 193 |
- Reference to a listener to redirect the request to. |
| 194 |
type: str |
| 195 |
request_routing_rules: |
| 196 |
description: |
| 197 |
- List of c(basic) request routing rule names within the application gateway to which the redirect is bound. |
| 198 |
version_added: "1.10.0" |
| 199 |
type: list |
| 200 |
elements: str |
| 201 |
url_path_maps: |
| 202 |
description: |
| 203 |
- List of URL path map names (c(path_based_routing) rules) within the application gateway to which the redirect is bound. |
| 204 |
type: list |
| 205 |
elements: str |
| 206 |
version_added: "1.10.0" |
| 207 |
path_rules: |
| 208 |
description: |
| 209 |
- List of URL path rules within a c(path_based_routing) rule to which the redirect is bound. |
| 210 |
type: list |
| 211 |
elements: dict |
| 212 |
suboptions: |
| 213 |
name: |
| 214 |
description: |
| 215 |
- Name of the URL rule. |
| 216 |
type: str |
| 217 |
path_map_name: |
| 218 |
description: |
| 219 |
- Name of URL path map. |
| 220 |
type: str |
| 221 |
version_added: "1.10.0" |
| 222 |
include_path: |
| 223 |
description: |
| 224 |
- Include path in the redirected url. |
| 225 |
type: bool |
| 226 |
include_query_string: |
| 227 |
description: |
| 228 |
- Include query string in the redirected url. |
| 229 |
type: bool |
| 230 |
name: |
| 231 |
description: |
| 232 |
- Name of the resource that is unique within a resource group. |
| 233 |
type: str |
| 234 |
rewrite_rule_sets: |
| 235 |
description: |
| 236 |
- List of rewrite configurations for the application gateway resource. |
| 237 |
type: list |
| 238 |
elements: dict |
| 239 |
version_added: "1.11.0" |
| 240 |
suboptions: |
| 241 |
name: |
| 242 |
description: |
| 243 |
- Name of the rewrite rule set. |
| 244 |
type: str |
| 245 |
required: True |
| 246 |
rewrite_rules: |
| 247 |
description: |
| 248 |
- List of rewrite rules. |
| 249 |
required: True |
| 250 |
type: list |
| 251 |
elements: dict |
| 252 |
suboptions: |
| 253 |
name: |
| 254 |
description: |
| 255 |
- Name of the rewrite rule. |
| 256 |
required: True |
| 257 |
type: str |
| 258 |
rule_sequence: |
| 259 |
description: |
| 260 |
- Sequence of the rule that determines the order of execution within the set. |
| 261 |
required: True |
| 262 |
type: int |
| 263 |
conditions: |
| 264 |
description: |
| 265 |
- Conditions based on which the action set execution will be evaluated. |
| 266 |
type: list |
| 267 |
elements: dict |
| 268 |
default: [] |
| 269 |
suboptions: |
| 270 |
variable: |
| 271 |
description: |
| 272 |
- The parameter for the condition. |
| 273 |
type: str |
| 274 |
required: True |
| 275 |
pattern: |
| 276 |
description: |
| 277 |
- The pattern, either fixed string or regular expression, that evaluates the truthfulness of the condition. |
| 278 |
type: str |
| 279 |
required: True |
| 280 |
ignore_case: |
| 281 |
description: |
| 282 |
- Setting this value to true will force the pattern to do a case in-sensitive comparison. |
| 283 |
type: bool |
| 284 |
default: True |
| 285 |
negate: |
| 286 |
description: |
| 287 |
- Setting this value to true will force to check the negation of the condition given by the user. |
| 288 |
type: bool |
| 289 |
default: False |
| 290 |
action_set: |
| 291 |
description: |
| 292 |
- Set of actions to be done as part of the rewrite rule. |
| 293 |
required: True |
| 294 |
type: dict |
| 295 |
suboptions: |
| 296 |
request_header_configurations: |
| 297 |
description: |
| 298 |
- List of actions to be taken on request headers. |
| 299 |
type: list |
| 300 |
elements: dict |
| 301 |
default: [] |
| 302 |
suboptions: |
| 303 |
header_name: |
| 304 |
description: |
| 305 |
- Name of the header. |
| 306 |
type: str |
| 307 |
required: True |
| 308 |
header_value: |
| 309 |
description: |
| 310 |
- Value of the header. |
| 311 |
- Leave the parameter unset to remove the header. |
| 312 |
type: str |
| 313 |
default: '' |
| 314 |
response_header_configurations: |
| 315 |
description: |
| 316 |
- List of actions to be taken on response headers. |
| 317 |
type: list |
| 318 |
elements: dict |
| 319 |
default: [] |
| 320 |
suboptions: |
| 321 |
header_name: |
| 322 |
description: |
| 323 |
- Name of the header. |
| 324 |
type: str |
| 325 |
required: True |
| 326 |
header_value: |
| 327 |
description: |
| 328 |
- Value of the header. |
| 329 |
- Leave the parameter unset to remove the header. |
| 330 |
type: str |
| 331 |
default: '' |
| 332 |
url_configuration: |
| 333 |
description: |
| 334 |
- Action to be taken on the URL. |
| 335 |
type: dict |
| 336 |
suboptions: |
| 337 |
modified_path: |
| 338 |
description: |
| 339 |
- Value to which the URL path will be rewriten. |
| 340 |
- Leave parameter unset to keep the original URL path. |
| 341 |
type: str |
| 342 |
modified_query_string: |
| 343 |
description: |
| 344 |
- Value to which the URL query string will be rewriten. |
| 345 |
- Leave parameter unset to keep the original URL query string. |
| 346 |
type: str |
| 347 |
reroute: |
| 348 |
description: |
| 349 |
- If set to true, will re-evaluate the path map provided in path-based request routing rules using modified path. |
| 350 |
type: bool |
| 351 |
default: False |
| 352 |
ssl_certificates: |
| 353 |
description: |
| 354 |
- SSL certificates of the application gateway resource. |
| 355 |
type: list |
| 356 |
elements: dict |
| 357 |
suboptions: |
| 358 |
data: |
| 359 |
description: |
| 360 |
- Base-64 encoded pfx certificate. |
| 361 |
- Only applicable in PUT Request. |
| 362 |
type: str |
| 363 |
password: |
| 364 |
description: |
| 365 |
- Password for the pfx file specified in I(data). |
| 366 |
- Only applicable in PUT request. |
| 367 |
type: str |
| 368 |
name: |
| 369 |
description: |
| 370 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 371 |
type: str |
| 372 |
key_vault_secret_id: |
| 373 |
description: |
| 374 |
- Secret Id of (base-64 encoded unencrypted pfx) 'Secret' or 'Certificate' object stored in KeyVault. |
| 375 |
- When using this option, the application gateway must have a user-assigned managed identity with access to the Key Vault. |
| 376 |
- Mutually exclusive with I(data) and I(password). |
| 377 |
default: '' |
| 378 |
type: str |
| 379 |
trusted_root_certificates: |
| 380 |
version_added: "1.15.0" |
| 381 |
description: |
| 382 |
- Trusted Root certificates of the application gateway resource. |
| 383 |
type: list |
| 384 |
elements: dict |
| 385 |
suboptions: |
| 386 |
name: |
| 387 |
description: |
| 388 |
- Name of the trusted root certificate that is unique within an Application Gateway. |
| 389 |
type: str |
| 390 |
data: |
| 391 |
description: |
| 392 |
- Certificate public data. |
| 393 |
type: str |
| 394 |
key_vault_secret_id: |
| 395 |
description: |
| 396 |
- Secret Id of (base-64 encoded unencrypted pfx) 'Secret' or 'Certificate' object stored in KeyVault. |
| 397 |
default: '' |
| 398 |
type: str |
| 399 |
frontend_ip_configurations: |
| 400 |
description: |
| 401 |
- Frontend IP addresses of the application gateway resource. |
| 402 |
type: list |
| 403 |
elements: dict |
| 404 |
suboptions: |
| 405 |
private_ip_address: |
| 406 |
description: |
| 407 |
- PrivateIPAddress of the network interface IP Configuration. |
| 408 |
type: str |
| 409 |
private_ip_allocation_method: |
| 410 |
description: |
| 411 |
- PrivateIP allocation method. |
| 412 |
type: str |
| 413 |
choices: |
| 414 |
- 'static' |
| 415 |
- 'dynamic' |
| 416 |
subnet: |
| 417 |
description: |
| 418 |
- Reference of the subnet resource. |
| 419 |
type: dict |
| 420 |
suboptions: |
| 421 |
id: |
| 422 |
description: |
| 423 |
- Full ID of the subnet resource. Required if I(name) and I(virtual_network_name) are not provided. |
| 424 |
type: str |
| 425 |
name: |
| 426 |
description: |
| 427 |
- Name of the subnet. Only used if I(virtual_network_name) is also provided. |
| 428 |
type: str |
| 429 |
virtual_network_name: |
| 430 |
description: |
| 431 |
- Name of the virtual network. Only used if I(name) is also provided. |
| 432 |
type: str |
| 433 |
public_ip_address: |
| 434 |
description: |
| 435 |
- Reference of the PublicIP resource. |
| 436 |
type: raw |
| 437 |
name: |
| 438 |
description: |
| 439 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 440 |
type: str |
| 441 |
frontend_ports: |
| 442 |
description: |
| 443 |
- List of frontend ports of the application gateway resource. |
| 444 |
type: list |
| 445 |
elements: dict |
| 446 |
suboptions: |
| 447 |
port: |
| 448 |
description: |
| 449 |
- Frontend port. |
| 450 |
type: str |
| 451 |
name: |
| 452 |
description: |
| 453 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 454 |
type: str |
| 455 |
backend_address_pools: |
| 456 |
description: |
| 457 |
- List of backend address pool of the application gateway resource. |
| 458 |
type: list |
| 459 |
elements: dict |
| 460 |
suboptions: |
| 461 |
backend_addresses: |
| 462 |
description: |
| 463 |
- List of backend addresses. |
| 464 |
type: list |
| 465 |
elements: dict |
| 466 |
suboptions: |
| 467 |
fqdn: |
| 468 |
description: |
| 469 |
- Fully qualified domain name (FQDN). |
| 470 |
type: str |
| 471 |
ip_address: |
| 472 |
description: |
| 473 |
- IP address. |
| 474 |
type: str |
| 475 |
name: |
| 476 |
description: |
| 477 |
- Resource that is unique within a resource group. This name can be used to access the resource. |
| 478 |
type: str |
| 479 |
probes: |
| 480 |
description: |
| 481 |
- Probes available to the application gateway resource. |
| 482 |
type: list |
| 483 |
elements: dict |
| 484 |
suboptions: |
| 485 |
name: |
| 486 |
description: |
| 487 |
- Name of the I(probe) that is unique within an Application Gateway. |
| 488 |
type: str |
| 489 |
protocol: |
| 490 |
description: |
| 491 |
- The protocol used for the I(probe). |
| 492 |
type: str |
| 493 |
choices: |
| 494 |
- 'http' |
| 495 |
- 'https' |
| 496 |
host: |
| 497 |
description: |
| 498 |
- Host name to send the I(probe) to. |
| 499 |
type: str |
| 500 |
path: |
| 501 |
description: |
| 502 |
- Relative path of I(probe). |
| 503 |
- Valid path starts from '/'. |
| 504 |
- Probe is sent to <Protocol>://<host>:<port><path>. |
| 505 |
type: str |
| 506 |
timeout: |
| 507 |
description: |
| 508 |
- The probe timeout in seconds. |
| 509 |
- Probe marked as failed if valid response is not received with this timeout period. |
| 510 |
- Acceptable values are from 1 second to 86400 seconds. |
| 511 |
type: int |
| 512 |
interval: |
| 513 |
description: |
| 514 |
- The probing interval in seconds. |
| 515 |
- This is the time interval between two consecutive probes. |
| 516 |
- Acceptable values are from 1 second to 86400 seconds. |
| 517 |
type: int |
| 518 |
unhealthy_threshold: |
| 519 |
description: |
| 520 |
- The I(probe) retry count. |
| 521 |
- Backend server is marked down after consecutive probe failure count reaches UnhealthyThreshold. |
| 522 |
- Acceptable values are from 1 second to 20. |
| 523 |
type: int |
| 524 |
pick_host_name_from_backend_http_settings: |
| 525 |
description: |
| 526 |
- Whether host header should be picked from the host name of the backend HTTP settings. Default value is false. |
| 527 |
type: bool |
| 528 |
default: False |
| 529 |
port: |
| 530 |
description: |
| 531 |
- Custom port which will be used for probing the backend servers. |
| 532 |
- The valid value ranges from 1 to 65535. |
| 533 |
- In case not set, port from http settings will be used. |
| 534 |
- This property is valid for C(Standard_v2) and C(WAF_v2) only. |
| 535 |
type: int |
| 536 |
match: |
| 537 |
description: |
| 538 |
- Criterion for classifying a healthy probe response. |
| 539 |
type: dict |
| 540 |
suboptions: |
| 541 |
status_codes: |
| 542 |
description: |
| 543 |
- Allowed ranges of healthy status codes. |
| 544 |
- Default range of healthy status codes is 200-399. |
| 545 |
type: list |
| 546 |
elements: str |
| 547 |
backend_http_settings_collection: |
| 548 |
description: |
| 549 |
- Backend http settings of the application gateway resource. |
| 550 |
type: list |
| 551 |
elements: dict |
| 552 |
suboptions: |
| 553 |
probe: |
| 554 |
description: |
| 555 |
- Probe resource of an application gateway. |
| 556 |
type: raw |
| 557 |
port: |
| 558 |
description: |
| 559 |
- The destination port on the backend. |
| 560 |
type: int |
| 561 |
protocol: |
| 562 |
description: |
| 563 |
- The protocol used to communicate with the backend. |
| 564 |
type: str |
| 565 |
choices: |
| 566 |
- 'http' |
| 567 |
- 'https' |
| 568 |
cookie_based_affinity: |
| 569 |
description: |
| 570 |
- Cookie based affinity. |
| 571 |
type: str |
| 572 |
choices: |
| 573 |
- 'enabled' |
| 574 |
- 'disabled' |
| 575 |
connection_draining: |
| 576 |
version_added: "1.15.0" |
| 577 |
description: |
| 578 |
- Connection draining of the backend http settings resource. |
| 579 |
type: dict |
| 580 |
suboptions: |
| 581 |
drain_timeout_in_sec: |
| 582 |
description: |
| 583 |
- The number of seconds connection draining is active. Acceptable values are from 1 second to 3600 seconds. |
| 584 |
type: int |
| 585 |
enabled: |
| 586 |
description: |
| 587 |
- Whether connection draining is enabled or not. |
| 588 |
type: bool |
| 589 |
request_timeout: |
| 590 |
description: |
| 591 |
- Request timeout in seconds. |
| 592 |
- Application Gateway will fail the request if response is not received within RequestTimeout. |
| 593 |
- Acceptable values are from 1 second to 86400 seconds. |
| 594 |
type: int |
| 595 |
authentication_certificates: |
| 596 |
description: |
| 597 |
- List of references to application gateway authentication certificates. |
| 598 |
- Applicable only when C(cookie_based_affinity) is enabled, otherwise quietly ignored. |
| 599 |
type: list |
| 600 |
elements: dict |
| 601 |
suboptions: |
| 602 |
id: |
| 603 |
description: |
| 604 |
- Resource ID. |
| 605 |
type: str |
| 606 |
trusted_root_certificates: |
| 607 |
version_added: "1.15.0" |
| 608 |
description: |
| 609 |
- Array of references to application gateway trusted root certificates. |
| 610 |
- Can be the name of the trusted root certificate or full resource ID. |
| 611 |
type: list |
| 612 |
elements: raw |
| 613 |
host_name: |
| 614 |
description: |
| 615 |
- Host header to be sent to the backend servers. |
| 616 |
type: str |
| 617 |
pick_host_name_from_backend_address: |
| 618 |
description: |
| 619 |
- Whether host header should be picked from the host name of the backend server. Default value is false. |
| 620 |
type: bool |
| 621 |
affinity_cookie_name: |
| 622 |
description: |
| 623 |
- Cookie name to use for the affinity cookie. |
| 624 |
type: str |
| 625 |
path: |
| 626 |
description: |
| 627 |
- Path which should be used as a prefix for all C(http) requests. |
| 628 |
- Null means no path will be prefixed. Default value is null. |
| 629 |
type: str |
| 630 |
name: |
| 631 |
description: |
| 632 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 633 |
type: str |
| 634 |
http_listeners: |
| 635 |
description: |
| 636 |
- List of HTTP listeners of the application gateway resource. |
| 637 |
type: list |
| 638 |
elements: dict |
| 639 |
suboptions: |
| 640 |
frontend_ip_configuration: |
| 641 |
description: |
| 642 |
- Frontend IP configuration resource of an application gateway. |
| 643 |
type: raw |
| 644 |
frontend_port: |
| 645 |
description: |
| 646 |
- Frontend port resource of an application gateway. |
| 647 |
type: raw |
| 648 |
protocol: |
| 649 |
description: |
| 650 |
- Protocol of the C(http) listener. |
| 651 |
type: str |
| 652 |
choices: |
| 653 |
- 'http' |
| 654 |
- 'https' |
| 655 |
host_name: |
| 656 |
description: |
| 657 |
- Host name of C(http) listener. |
| 658 |
type: str |
| 659 |
ssl_certificate: |
| 660 |
description: |
| 661 |
- SSL certificate resource of an application gateway. |
| 662 |
type: raw |
| 663 |
require_server_name_indication: |
| 664 |
description: |
| 665 |
- Applicable only if I(protocol) is C(https). Enables SNI for multi-hosting. |
| 666 |
type: bool |
| 667 |
name: |
| 668 |
description: |
| 669 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 670 |
type: str |
| 671 |
url_path_maps: |
| 672 |
description: |
| 673 |
- List of URL path maps of the application gateway resource. |
| 674 |
type: list |
| 675 |
elements: dict |
| 676 |
suboptions: |
| 677 |
name: |
| 678 |
description: |
| 679 |
- Name of the resource that is unique within the application gateway. This name can be used to access the resource. |
| 680 |
type: str |
| 681 |
default_backend_address_pool: |
| 682 |
description: |
| 683 |
- Backend address pool resource of the application gateway which will be used if no path matches occur. |
| 684 |
- Mutually exclusive with I(default_redirect_configuration). |
| 685 |
type: str |
| 686 |
default_backend_http_settings: |
| 687 |
description: |
| 688 |
- Backend http settings resource of the application gateway; used with I(default_backend_address_pool). |
| 689 |
type: str |
| 690 |
default_rewrite_rule_set: |
| 691 |
description: |
| 692 |
- Default rewrite rule set for the path map. |
| 693 |
- Can be the name of the rewrite rule set or full resource ID. |
| 694 |
version_added: "1.11.0" |
| 695 |
type: str |
| 696 |
path_rules: |
| 697 |
description: |
| 698 |
- List of URL path rules. |
| 699 |
type: list |
| 700 |
elements: dict |
| 701 |
suboptions: |
| 702 |
name: |
| 703 |
description: |
| 704 |
- Name of the resource that is unique within the path map. |
| 705 |
type: str |
| 706 |
backend_address_pool: |
| 707 |
description: |
| 708 |
- Backend address pool resource of the application gateway which will be used if the path is matched. |
| 709 |
- Mutually exclusive with I(redirect_configuration). |
| 710 |
type: str |
| 711 |
backend_http_settings: |
| 712 |
description: |
| 713 |
- Backend http settings resource of the application gateway; used for the path's I(backend_address_pool). |
| 714 |
type: str |
| 715 |
rewrite_rule_set: |
| 716 |
description: |
| 717 |
- Rewrite rule set for the path map. |
| 718 |
- Can be the name of the rewrite rule set or full resource ID. |
| 719 |
type: str |
| 720 |
version_added: "1.11.0" |
| 721 |
redirect_configuration: |
| 722 |
description: |
| 723 |
- Name of redirect configuration resource of the application gateway which will be used if the path is matched. |
| 724 |
- Mutually exclusive with I(backend_address_pool). |
| 725 |
type: str |
| 726 |
version_added: "1.10.0" |
| 727 |
paths: |
| 728 |
description: |
| 729 |
- List of paths. |
| 730 |
type: list |
| 731 |
elements: str |
| 732 |
default_redirect_configuration: |
| 733 |
description: |
| 734 |
- Name of redirect configuration resource of the application gateway which will be used if no path matches occur. |
| 735 |
- Mutually exclusive with I(default_backend_address_pool). |
| 736 |
type: str |
| 737 |
version_added: "1.10.0" |
| 738 |
request_routing_rules: |
| 739 |
description: |
| 740 |
- List of request routing rules of the application gateway resource. |
| 741 |
type: list |
| 742 |
elements: dict |
| 743 |
suboptions: |
| 744 |
rule_type: |
| 745 |
description: |
| 746 |
- Rule type. |
| 747 |
type: str |
| 748 |
choices: |
| 749 |
- 'basic' |
| 750 |
- 'path_based_routing' |
| 751 |
backend_address_pool: |
| 752 |
description: |
| 753 |
- Backend address pool resource of the application gateway. Not used if I(rule_type) is C(path_based_routing). |
| 754 |
type: raw |
| 755 |
backend_http_settings: |
| 756 |
description: |
| 757 |
- Backend C(http) settings resource of the application gateway. |
| 758 |
type: raw |
| 759 |
http_listener: |
| 760 |
description: |
| 761 |
- Http listener resource of the application gateway. |
| 762 |
type: raw |
| 763 |
name: |
| 764 |
description: |
| 765 |
- Name of the resource that is unique within a resource group. This name can be used to access the resource. |
| 766 |
type: str |
| 767 |
redirect_configuration: |
| 768 |
description: |
| 769 |
- Redirect configuration resource of the application gateway. |
| 770 |
type: raw |
| 771 |
url_path_map: |
| 772 |
description: |
| 773 |
- URL path map resource of the application gateway. Required if I(rule_type) is C(path_based_routing). |
| 774 |
type: raw |
| 775 |
rewrite_rule_set: |
| 776 |
description: |
| 777 |
- Rewrite rule set for the path map. |
| 778 |
- Can be the name of the rewrite rule set or full resource ID. |
| 779 |
type: raw |
| 780 |
version_added: "1.11.0" |
| 781 |
priority: |
| 782 |
description: |
| 783 |
- Priority of the request routing rule. |
| 784 |
type: int |
| 785 |
required: true |
| 786 |
autoscale_configuration: |
| 787 |
version_added: "1.15.0" |
| 788 |
description: |
| 789 |
- Autoscale configuration of the application gateway resource. |
| 790 |
type: dict |
| 791 |
suboptions: |
| 792 |
max_capacity: |
| 793 |
description: |
| 794 |
- Upper bound on number of Application Gateway capacity. |
| 795 |
type: int |
| 796 |
min_capacity: |
| 797 |
description: |
| 798 |
- Lower bound on number of Application Gateway capacity. |
| 799 |
type: int |
| 800 |
enable_http2: |
| 801 |
version_added: "1.15.0" |
| 802 |
description: |
| 803 |
- Whether HTTP2 is enabled on the application gateway resource. |
| 804 |
type: bool |
| 805 |
default: False |
| 806 |
web_application_firewall_configuration: |
| 807 |
version_added: "1.15.0" |
| 808 |
description: |
| 809 |
- Web application firewall configuration of the application gateway resource. |
| 810 |
- > |
| 811 |
Note that as of version 2.8.0, I(firewall_policy) is required instead of deprecated options. |
| 812 |
See https://github.com/ansible-collections/azure/pull/1697. |
| 813 |
type: dict |
| 814 |
suboptions: |
| 815 |
disabled_rule_groups: |
| 816 |
description: |
| 817 |
- (Deprecated) The disabled rule groups. |
| 818 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 819 |
type: list |
| 820 |
elements: dict |
| 821 |
default: [] |
| 822 |
suboptions: |
| 823 |
rule_group_name: |
| 824 |
description: |
| 825 |
- The name of the rule group that will be disabled. |
| 826 |
type: str |
| 827 |
rules: |
| 828 |
description: |
| 829 |
- The list of rules that will be disabled. If null, all rules of the rule group will be disabled. |
| 830 |
type: list |
| 831 |
elements: int |
| 832 |
default: [] |
| 833 |
enabled: |
| 834 |
description: |
| 835 |
- (Deprecated) Whether the web application firewall is enabled or not. |
| 836 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 837 |
type: bool |
| 838 |
exclusions: |
| 839 |
description: |
| 840 |
- (Deprecated) The exclusion list. |
| 841 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 842 |
type: list |
| 843 |
elements: dict |
| 844 |
default: [] |
| 845 |
suboptions: |
| 846 |
match_variable: |
| 847 |
description: |
| 848 |
- The variable to be excluded. |
| 849 |
type: str |
| 850 |
selector: |
| 851 |
description: |
| 852 |
- When match_variable is a collection, operator used to specify which elements in the collection this exclusion applies to. |
| 853 |
type: str |
| 854 |
selector_match_operator: |
| 855 |
description: |
| 856 |
- When match_variable is a collection, operate on the selector to specify |
| 857 |
which elements in the collection this exclusion applies to. |
| 858 |
type: str |
| 859 |
file_upload_limit_in_mb: |
| 860 |
description: |
| 861 |
- (Deprecated) Maximum file upload size in Mb for WAF. |
| 862 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 863 |
type: int |
| 864 |
firewall_mode: |
| 865 |
description: |
| 866 |
- (Deprecated) Web application firewall mode. |
| 867 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 868 |
type: str |
| 869 |
choices: |
| 870 |
- 'Detection' |
| 871 |
- 'Prevention' |
| 872 |
max_request_body_size: |
| 873 |
description: |
| 874 |
- (Deprecated) Maximum request body size for WAF. |
| 875 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 876 |
type: int |
| 877 |
max_request_body_size_in_kb: |
| 878 |
description: |
| 879 |
- (Deprecated) Maximum request body size in Kb for WAF. |
| 880 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 881 |
type: int |
| 882 |
request_body_check: |
| 883 |
description: |
| 884 |
- (Deprecated) Whether allow WAF to check request Body. |
| 885 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 886 |
type: bool |
| 887 |
rule_set_type: |
| 888 |
description: |
| 889 |
- (Deprecated) The type of the web application firewall rule set. |
| 890 |
- Possible values are 'OWASP'. |
| 891 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 892 |
type: str |
| 893 |
choices: |
| 894 |
- 'OWASP' |
| 895 |
rule_set_version: |
| 896 |
description: |
| 897 |
- (Deprecated) The version of the rule set type. |
| 898 |
- This value has been deprecated, and will be removed in a later version. Use I(firewall_policy) instead. |
| 899 |
type: str |
| 900 |
firewall_policy: |
| 901 |
version_added: "2.8.0" |
| 902 |
description: |
| 903 |
- Web application firewall policy for the application gateway. |
| 904 |
type: dict |
| 905 |
suboptions: |
| 906 |
id: |
| 907 |
description: |
| 908 |
- Resource ID of the firewall policy. Required if I(name) is not provided. |
| 909 |
type: str |
| 910 |
name: |
| 911 |
description: |
| 912 |
- Name of the firewall policy (in same subscription and region). Used if I(id) is not provided. |
| 913 |
type: str |
| 914 |
force_association: |
| 915 |
description: |
| 916 |
- If true, associates the firewall policy with an application gateway regardless whether the policy differs from the WAF Config. |
| 917 |
type: bool |
| 918 |
default: true |
| 919 |
gateway_state: |
| 920 |
description: |
| 921 |
- Start or Stop the application gateway. When specified, no updates will occur to the gateway. |
| 922 |
type: str |
| 923 |
choices: |
| 924 |
- started |
| 925 |
- stopped |
| 926 |
state: |
| 927 |
description: |
| 928 |
- Assert the state of the application gateway. Use C(present) to create or update and C(absent) to delete. |
| 929 |
default: present |
| 930 |
type: str |
| 931 |
choices: |
| 932 |
- absent |
| 933 |
- present |
| 934 |
|
| 935 |
extends_documentation_fragment: |
| 936 |
- azure.azcollection.azure |
| 937 |
- azure.azcollection.azure_tags |
| 938 |
- azure.azcollection.azure_identity_multiple |
| 939 |
|
| 940 |
author: |
| 941 |
- Zim Kalinowski (@zikalino) |
| 942 |
|
| 943 |
''' |
| 944 |
|
| 945 |
EXAMPLES = ''' |
| 946 |
- name: Create instance of Application Gateway |
| 947 |
azure_rm_appgateway: |
| 948 |
resource_group: myResourceGroup |
| 949 |
name: myAppGateway |
| 950 |
sku: |
| 951 |
name: standard_small |
| 952 |
tier: standard |
| 953 |
capacity: 2 |
| 954 |
gateway_ip_configurations: |
| 955 |
- subnet: |
| 956 |
id: "{{ subnet_id }}" |
| 957 |
name: app_gateway_ip_config |
| 958 |
frontend_ip_configurations: |
| 959 |
- subnet: |
| 960 |
id: "{{ subnet_id }}" |
| 961 |
name: sample_gateway_frontend_ip_config |
| 962 |
frontend_ports: |
| 963 |
- port: 90 |
| 964 |
name: ag_frontend_port |
| 965 |
backend_address_pools: |
| 966 |
- backend_addresses: |
| 967 |
- ip_address: 10.0.0.4 |
| 968 |
name: test_backend_address_pool |
| 969 |
backend_http_settings_collection: |
| 970 |
- port: 80 |
| 971 |
protocol: http |
| 972 |
cookie_based_affinity: enabled |
| 973 |
connection_draining: |
| 974 |
drain_timeout_in_sec: 60 |
| 975 |
enabled: true |
| 976 |
name: sample_appgateway_http_settings |
| 977 |
http_listeners: |
| 978 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 979 |
frontend_port: ag_frontend_port |
| 980 |
name: sample_http_listener |
| 981 |
request_routing_rules: |
| 982 |
- rule_type: basic |
| 983 |
backend_address_pool: test_backend_address_pool |
| 984 |
backend_http_settings: sample_appgateway_http_settings |
| 985 |
http_listener: sample_http_listener |
| 986 |
name: rule1 |
| 987 |
priority: 100 |
| 988 |
|
| 989 |
- name: Create instance of Application Gateway with custom trusted root certificate |
| 990 |
azure_rm_appgateway: |
| 991 |
resource_group: myResourceGroup |
| 992 |
name: myAppGateway |
| 993 |
sku: |
| 994 |
name: standard_small |
| 995 |
tier: standard |
| 996 |
capacity: 2 |
| 997 |
gateway_ip_configurations: |
| 998 |
- subnet: |
| 999 |
id: "{{ subnet_id }}" |
| 1000 |
name: app_gateway_ip_config |
| 1001 |
frontend_ip_configurations: |
| 1002 |
- subnet: |
| 1003 |
id: "{{ subnet_id }}" |
| 1004 |
name: sample_gateway_frontend_ip_config |
| 1005 |
frontend_ports: |
| 1006 |
- port: 90 |
| 1007 |
name: ag_frontend_port |
| 1008 |
trusted_root_certificates: |
| 1009 |
- name: "root_cert" |
| 1010 |
key_vault_secret_id: "https://kv/secret" |
| 1011 |
ssl_certificates: |
| 1012 |
- name: "ssl_cert" |
| 1013 |
key_vault_secret_id: "https://kv/secrets/ssl-cert" |
| 1014 |
backend_address_pools: |
| 1015 |
- backend_addresses: |
| 1016 |
- ip_address: 10.0.0.4 |
| 1017 |
name: test_backend_address_pool |
| 1018 |
backend_http_settings_collection: |
| 1019 |
- port: 80 |
| 1020 |
protocol: http |
| 1021 |
cookie_based_affinity: enabled |
| 1022 |
connection_draining: |
| 1023 |
drain_timeout_in_sec: 60 |
| 1024 |
enabled: true |
| 1025 |
name: sample_appgateway_http_settings |
| 1026 |
trusted_root_certificates: |
| 1027 |
- "root_cert" |
| 1028 |
http_listeners: |
| 1029 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 1030 |
frontend_port: ag_frontend_port |
| 1031 |
name: sample_http_listener |
| 1032 |
request_routing_rules: |
| 1033 |
- rule_type: basic |
| 1034 |
priority: 100 |
| 1035 |
backend_address_pool: test_backend_address_pool |
| 1036 |
backend_http_settings: sample_appgateway_http_settings |
| 1037 |
http_listener: sample_http_listener |
| 1038 |
name: rule1 |
| 1039 |
|
| 1040 |
- name: Create instance of Application Gateway by looking up virtual network and subnet |
| 1041 |
azure_rm_appgateway: |
| 1042 |
resource_group: myResourceGroup |
| 1043 |
name: myAppGateway |
| 1044 |
sku: |
| 1045 |
name: standard_small |
| 1046 |
tier: standard |
| 1047 |
capacity: 2 |
| 1048 |
gateway_ip_configurations: |
| 1049 |
- subnet: |
| 1050 |
name: default |
| 1051 |
virtual_network_name: my-vnet |
| 1052 |
name: app_gateway_ip_config |
| 1053 |
frontend_ip_configurations: |
| 1054 |
- subnet: |
| 1055 |
name: default |
| 1056 |
virtual_network_name: my-vnet |
| 1057 |
name: sample_gateway_frontend_ip_config |
| 1058 |
frontend_ports: |
| 1059 |
- port: 90 |
| 1060 |
name: ag_frontend_port |
| 1061 |
backend_address_pools: |
| 1062 |
- backend_addresses: |
| 1063 |
- ip_address: 10.0.0.4 |
| 1064 |
name: test_backend_address_pool |
| 1065 |
backend_http_settings_collection: |
| 1066 |
- port: 80 |
| 1067 |
protocol: http |
| 1068 |
cookie_based_affinity: enabled |
| 1069 |
name: sample_appgateway_http_settings |
| 1070 |
http_listeners: |
| 1071 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 1072 |
frontend_port: ag_frontend_port |
| 1073 |
name: sample_http_listener |
| 1074 |
request_routing_rules: |
| 1075 |
- rule_type: basic |
| 1076 |
priority: 100 |
| 1077 |
backend_address_pool: test_backend_address_pool |
| 1078 |
backend_http_settings: sample_appgateway_http_settings |
| 1079 |
http_listener: sample_http_listener |
| 1080 |
name: rule1 |
| 1081 |
|
| 1082 |
- name: Create instance of Application Gateway with path based rules |
| 1083 |
azure_rm_appgateway: |
| 1084 |
resource_group: myResourceGroup |
| 1085 |
name: myAppGateway |
| 1086 |
sku: |
| 1087 |
name: standard_small |
| 1088 |
tier: standard |
| 1089 |
capacity: 2 |
| 1090 |
gateway_ip_configurations: |
| 1091 |
- subnet: |
| 1092 |
id: "{{ subnet_id }}" |
| 1093 |
name: app_gateway_ip_config |
| 1094 |
frontend_ip_configurations: |
| 1095 |
- subnet: |
| 1096 |
id: "{{ subnet_id }}" |
| 1097 |
name: sample_gateway_frontend_ip_config |
| 1098 |
frontend_ports: |
| 1099 |
- port: 90 |
| 1100 |
name: ag_frontend_port |
| 1101 |
backend_address_pools: |
| 1102 |
- backend_addresses: |
| 1103 |
- ip_address: 10.0.0.4 |
| 1104 |
name: test_backend_address_pool |
| 1105 |
backend_http_settings_collection: |
| 1106 |
- port: 80 |
| 1107 |
protocol: http |
| 1108 |
cookie_based_affinity: enabled |
| 1109 |
name: sample_appgateway_http_settings |
| 1110 |
http_listeners: |
| 1111 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 1112 |
frontend_port: ag_frontend_port |
| 1113 |
name: sample_http_listener |
| 1114 |
request_routing_rules: |
| 1115 |
- rule_type: path_based_routing |
| 1116 |
priority: 100 |
| 1117 |
http_listener: sample_http_listener |
| 1118 |
name: rule1 |
| 1119 |
url_path_map: path_mappings |
| 1120 |
url_path_maps: |
| 1121 |
- name: path_mappings |
| 1122 |
default_backend_address_pool: test_backend_address_pool |
| 1123 |
default_backend_http_settings: sample_appgateway_http_settings |
| 1124 |
path_rules: |
| 1125 |
- name: path_rules |
| 1126 |
backend_address_pool: test_backend_address_pool |
| 1127 |
backend_http_settings: sample_appgateway_http_settings |
| 1128 |
paths: |
| 1129 |
- "/abc" |
| 1130 |
- "/123/*" |
| 1131 |
|
| 1132 |
- name: Create instance of Application Gateway with complex routing and redirect rules |
| 1133 |
azure_rm_appgateway: |
| 1134 |
resource_group: myResourceGroup |
| 1135 |
name: myComplexAppGateway |
| 1136 |
sku: |
| 1137 |
name: standard_small |
| 1138 |
tier: standard |
| 1139 |
capacity: 2 |
| 1140 |
ssl_policy: |
| 1141 |
policy_type: "predefined" |
| 1142 |
policy_name: "ssl_policy20170401_s" |
| 1143 |
ssl_certificates: |
| 1144 |
- name: ssl_cert |
| 1145 |
password: "{{ password }}" |
| 1146 |
data: "{{ lookup('file', 'certfile') }}" |
| 1147 |
gateway_ip_configurations: |
| 1148 |
- subnet: |
| 1149 |
id: "{{ subnet_output.state.id }}" |
| 1150 |
name: app_gateway_ip_config |
| 1151 |
frontend_ip_configurations: |
| 1152 |
- subnet: |
| 1153 |
id: "{{ subnet_output.state.id }}" |
| 1154 |
name: sample_gateway_frontend_ip_config |
| 1155 |
frontend_ports: |
| 1156 |
- name: "inbound-http" |
| 1157 |
port: 80 |
| 1158 |
- name: "inbound-https" |
| 1159 |
port: 443 |
| 1160 |
backend_address_pools: |
| 1161 |
- name: test_backend_address_pool1 |
| 1162 |
backend_addresses: |
| 1163 |
- ip_address: 10.0.0.1 |
| 1164 |
- name: test_backend_address_pool2 |
| 1165 |
backend_addresses: |
| 1166 |
- ip_address: 10.0.0.2 |
| 1167 |
backend_http_settings_collection: |
| 1168 |
- name: "http-profile1" |
| 1169 |
port: 443 |
| 1170 |
protocol: https |
| 1171 |
pick_host_name_from_backend_address: true |
| 1172 |
probe: "http-probe1" |
| 1173 |
cookie_based_affinity: "Disabled" |
| 1174 |
- name: "http-profile2" |
| 1175 |
port: 8080 |
| 1176 |
protocol: http |
| 1177 |
pick_host_name_from_backend_address: true |
| 1178 |
probe: "http-probe2" |
| 1179 |
cookie_based_affinity: "Disabled" |
| 1180 |
http_listeners: |
| 1181 |
- name: "inbound-http" |
| 1182 |
protocol: "http" |
| 1183 |
frontend_ip_configuration: "sample_gateway_frontend_ip_config" |
| 1184 |
frontend_port: "inbound-http" |
| 1185 |
- name: "inbound-traffic1" |
| 1186 |
protocol: "https" |
| 1187 |
frontend_ip_configuration: "sample_gateway_frontend_ip_config" |
| 1188 |
frontend_port: "inbound-https" |
| 1189 |
host_name: "traffic1.example.com" |
| 1190 |
require_server_name_indication: true |
| 1191 |
ssl_certificate: "ssl_cert" |
| 1192 |
- name: "inbound-traffic2" |
| 1193 |
protocol: "https" |
| 1194 |
frontend_ip_configuration: "sample_gateway_frontend_ip_config" |
| 1195 |
frontend_port: "inbound-https" |
| 1196 |
host_name: "traffic2.example.com" |
| 1197 |
require_server_name_indication: true |
| 1198 |
ssl_certificate: "ssl_cert" |
| 1199 |
url_path_maps: |
| 1200 |
- name: "path_mappings" |
| 1201 |
default_redirect_configuration: "redirect-traffic1" |
| 1202 |
path_rules: |
| 1203 |
- name: "path_rules" |
| 1204 |
backend_address_pool: "test_backend_address_pool1" |
| 1205 |
backend_http_settings: "http-profile1" |
| 1206 |
paths: |
| 1207 |
- "/abc" |
| 1208 |
- "/123/*" |
| 1209 |
request_routing_rules: |
| 1210 |
- name: "app-routing1" |
| 1211 |
rule_type: "basic" |
| 1212 |
priority: 100 |
| 1213 |
http_listener: "inbound-traffic1" |
| 1214 |
backend_address_pool: "test_backend_address_pool2" |
| 1215 |
backend_http_settings: "http-profile1" |
| 1216 |
- name: "app-routing2" |
| 1217 |
rule_type: "path_based_routing" |
| 1218 |
priority: 101 |
| 1219 |
http_listener: "inbound-traffic2" |
| 1220 |
url_path_map: "path_mappings" |
| 1221 |
- name: "redirect-routing" |
| 1222 |
rule_type: "basic" |
| 1223 |
priority: 102 |
| 1224 |
http_listener: "inbound-http" |
| 1225 |
redirect_configuration: "redirect-http" |
| 1226 |
probes: |
| 1227 |
- name: "http-probe1" |
| 1228 |
interval: 30 |
| 1229 |
path: "/abc" |
| 1230 |
protocol: "https" |
| 1231 |
pick_host_name_from_backend_http_settings: true |
| 1232 |
timeout: 30 |
| 1233 |
unhealthy_threshold: 2 |
| 1234 |
- name: "http-probe2" |
| 1235 |
interval: 30 |
| 1236 |
path: "/xyz" |
| 1237 |
protocol: "http" |
| 1238 |
pick_host_name_from_backend_http_settings: true |
| 1239 |
timeout: 30 |
| 1240 |
unhealthy_threshold: 2 |
| 1241 |
redirect_configurations: |
| 1242 |
- name: "redirect-http" |
| 1243 |
redirect_type: "permanent" |
| 1244 |
target_listener: "inbound-traffic1" |
| 1245 |
include_path: true |
| 1246 |
include_query_string: true |
| 1247 |
request_routing_rules: |
| 1248 |
- "redirect-routing" |
| 1249 |
- name: "redirect-traffic1" |
| 1250 |
redirect_type: "found" |
| 1251 |
target_listener: "inbound-traffic1" |
| 1252 |
include_path: true |
| 1253 |
include_query_string: true |
| 1254 |
url_path_maps: |
| 1255 |
- "path_mappings" |
| 1256 |
|
| 1257 |
- name: Create v2 instance of Application Gateway with rewrite rules |
| 1258 |
azure_rm_appgateway: |
| 1259 |
resource_group: myResourceGroup |
| 1260 |
name: myV2AppGateway |
| 1261 |
sku: |
| 1262 |
name: standard_v2 |
| 1263 |
tier: standard_v2 |
| 1264 |
capacity: 2 |
| 1265 |
ssl_policy: |
| 1266 |
policy_type: predefined |
| 1267 |
policy_name: ssl_policy20170401_s |
| 1268 |
ssl_certificates: |
| 1269 |
- name: ssl_cert |
| 1270 |
password: "{{ password }}" |
| 1271 |
data: "{{ lookup('file', ssl_cert) }}" |
| 1272 |
gateway_ip_configurations: |
| 1273 |
- subnet: |
| 1274 |
id: "{{ subnet_output.state.id }}" |
| 1275 |
name: app_gateway_ip_config |
| 1276 |
frontend_ip_configurations: |
| 1277 |
- name: "public-inbound-ip" |
| 1278 |
public_ip_address: my-appgw-pip |
| 1279 |
frontend_ports: |
| 1280 |
- name: "inbound-http" |
| 1281 |
port: 80 |
| 1282 |
- name: "inbound-https" |
| 1283 |
port: 443 |
| 1284 |
backend_address_pools: |
| 1285 |
- name: test_backend_address_pool1 |
| 1286 |
backend_addresses: |
| 1287 |
- ip_address: 10.0.0.1 |
| 1288 |
- name: test_backend_address_pool2 |
| 1289 |
backend_addresses: |
| 1290 |
- ip_address: 10.0.0.2 |
| 1291 |
backend_http_settings_collection: |
| 1292 |
- name: "http-profile1" |
| 1293 |
port: 443 |
| 1294 |
protocol: https |
| 1295 |
pick_host_name_from_backend_address: true |
| 1296 |
probe: "http-probe1" |
| 1297 |
cookie_based_affinity: "Disabled" |
| 1298 |
- name: "http-profile2" |
| 1299 |
port: 8080 |
| 1300 |
protocol: http |
| 1301 |
pick_host_name_from_backend_address: true |
| 1302 |
probe: "http-probe2" |
| 1303 |
cookie_based_affinity: "Disabled" |
| 1304 |
http_listeners: |
| 1305 |
- name: "inbound-http" |
| 1306 |
protocol: "http" |
| 1307 |
frontend_ip_configuration: "public-inbound-ip" |
| 1308 |
frontend_port: "inbound-http" |
| 1309 |
- name: "inbound-traffic1" |
| 1310 |
protocol: "https" |
| 1311 |
frontend_ip_configuration: "public-inbound-ip" |
| 1312 |
frontend_port: "inbound-https" |
| 1313 |
host_name: "traffic1.example.com" |
| 1314 |
require_server_name_indication: true |
| 1315 |
ssl_certificate: "ssl_cert" |
| 1316 |
- name: "inbound-traffic2" |
| 1317 |
protocol: "https" |
| 1318 |
frontend_ip_configuration: "public-inbound-ip" |
| 1319 |
frontend_port: "inbound-https" |
| 1320 |
host_name: "traffic2.example.com" |
| 1321 |
require_server_name_indication: true |
| 1322 |
ssl_certificate: "ssl_cert" |
| 1323 |
url_path_maps: |
| 1324 |
- name: "path_mappings" |
| 1325 |
default_redirect_configuration: "redirect-traffic1" |
| 1326 |
default_rewrite_rule_set: "configure-headers" |
| 1327 |
path_rules: |
| 1328 |
- name: "path_rules" |
| 1329 |
backend_address_pool: "test_backend_address_pool1" |
| 1330 |
backend_http_settings: "http-profile1" |
| 1331 |
paths: |
| 1332 |
- "/abc" |
| 1333 |
- "/123/*" |
| 1334 |
request_routing_rules: |
| 1335 |
- name: "app-routing1" |
| 1336 |
rule_type: "basic" |
| 1337 |
priority: 100 |
| 1338 |
http_listener: "inbound-traffic1" |
| 1339 |
backend_address_pool: "test_backend_address_pool2" |
| 1340 |
backend_http_settings: "http-profile1" |
| 1341 |
rewrite_rule_set: "configure-headers" |
| 1342 |
- name: "app-routing2" |
| 1343 |
rule_type: "path_based_routing" |
| 1344 |
priority: 101 |
| 1345 |
http_listener: "inbound-traffic2" |
| 1346 |
url_path_map: "path_mappings" |
| 1347 |
- name: "redirect-routing" |
| 1348 |
rule_type: "basic" |
| 1349 |
priority: 102 |
| 1350 |
http_listener: "inbound-http" |
| 1351 |
redirect_configuration: "redirect-http" |
| 1352 |
rewrite_rule_sets: |
| 1353 |
- name: "configure-headers" |
| 1354 |
rewrite_rules: |
| 1355 |
- name: "add-security-response-header" |
| 1356 |
rule_sequence: 1 |
| 1357 |
action_set: |
| 1358 |
response_header_configurations: |
| 1359 |
- header_name: "Strict-Transport-Security" |
| 1360 |
header_value: "max-age=31536000" |
| 1361 |
- name: "remove-backend-response-headers" |
| 1362 |
rule_sequence: 2 |
| 1363 |
action_set: |
| 1364 |
response_header_configurations: |
| 1365 |
- header_name: "Server" |
| 1366 |
- header_name: "X-Powered-By" |
| 1367 |
- name: "set-custom-header-condition" |
| 1368 |
rule_sequence: 3 |
| 1369 |
conditions: |
| 1370 |
- variable: "var_client_ip" |
| 1371 |
pattern: "1.1.1.1" |
| 1372 |
- variable: "http_req_Authorization" |
| 1373 |
pattern: "12345" |
| 1374 |
ignore_case: false |
| 1375 |
action_set: |
| 1376 |
request_header_configurations: |
| 1377 |
- header_name: "Foo" |
| 1378 |
header_value: "Bar" |
| 1379 |
probes: |
| 1380 |
- name: "http-probe1" |
| 1381 |
interval: 30 |
| 1382 |
path: "/abc" |
| 1383 |
protocol: "https" |
| 1384 |
pick_host_name_from_backend_http_settings: true |
| 1385 |
timeout: 30 |
| 1386 |
unhealthy_threshold: 2 |
| 1387 |
- name: "http-probe2" |
| 1388 |
interval: 30 |
| 1389 |
path: "/xyz" |
| 1390 |
protocol: "http" |
| 1391 |
pick_host_name_from_backend_http_settings: true |
| 1392 |
timeout: 30 |
| 1393 |
unhealthy_threshold: 2 |
| 1394 |
redirect_configurations: |
| 1395 |
- name: "redirect-http" |
| 1396 |
redirect_type: "permanent" |
| 1397 |
target_listener: "inbound-traffic1" |
| 1398 |
include_path: true |
| 1399 |
include_query_string: true |
| 1400 |
request_routing_rules: |
| 1401 |
- "redirect-routing" |
| 1402 |
- name: "redirect-traffic1" |
| 1403 |
redirect_type: "found" |
| 1404 |
target_listener: "inbound-traffic1" |
| 1405 |
include_path: true |
| 1406 |
include_query_string: true |
| 1407 |
url_path_maps: |
| 1408 |
- "path_mappings" |
| 1409 |
|
| 1410 |
- name: Create instance of Application Gateway with autoscale configuration |
| 1411 |
azure_rm_appgateway: |
| 1412 |
resource_group: myResourceGroup |
| 1413 |
name: myAppGateway |
| 1414 |
sku: |
| 1415 |
name: standard_small |
| 1416 |
tier: standard |
| 1417 |
autoscale_configuration: |
| 1418 |
max_capacity: 2 |
| 1419 |
min_capacity: 1 |
| 1420 |
gateway_ip_configurations: |
| 1421 |
- subnet: |
| 1422 |
id: "{{ subnet_id }}" |
| 1423 |
name: app_gateway_ip_config |
| 1424 |
frontend_ip_configurations: |
| 1425 |
- subnet: |
| 1426 |
id: "{{ subnet_id }}" |
| 1427 |
name: sample_gateway_frontend_ip_config |
| 1428 |
frontend_ports: |
| 1429 |
- port: 90 |
| 1430 |
name: ag_frontend_port |
| 1431 |
backend_address_pools: |
| 1432 |
- backend_addresses: |
| 1433 |
- ip_address: 10.0.0.4 |
| 1434 |
name: test_backend_address_pool |
| 1435 |
backend_http_settings_collection: |
| 1436 |
- port: 80 |
| 1437 |
protocol: http |
| 1438 |
cookie_based_affinity: enabled |
| 1439 |
name: sample_appgateway_http_settings |
| 1440 |
http_listeners: |
| 1441 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 1442 |
frontend_port: ag_frontend_port |
| 1443 |
name: sample_http_listener |
| 1444 |
request_routing_rules: |
| 1445 |
- rule_type: basic |
| 1446 |
priority: 100 |
| 1447 |
backend_address_pool: test_backend_address_pool |
| 1448 |
backend_http_settings: sample_appgateway_http_settings |
| 1449 |
http_listener: sample_http_listener |
| 1450 |
name: rule1 |
| 1451 |
|
| 1452 |
- name: Create instance of Application Gateway waf_v2 with waf configuration |
| 1453 |
azure_rm_appgateway: |
| 1454 |
resource_group: myResourceGroup |
| 1455 |
name: myAppGateway |
| 1456 |
sku: |
| 1457 |
name: waf_v2 |
| 1458 |
tier: waf_v2 |
| 1459 |
capacity: 2 |
| 1460 |
gateway_ip_configurations: |
| 1461 |
- subnet: |
| 1462 |
id: "{{ subnet_id }}" |
| 1463 |
name: app_gateway_ip_config |
| 1464 |
frontend_ip_configurations: |
| 1465 |
- subnet: |
| 1466 |
id: "{{ subnet_id }}" |
| 1467 |
name: sample_gateway_frontend_ip_config |
| 1468 |
frontend_ports: |
| 1469 |
- port: 90 |
| 1470 |
name: ag_frontend_port |
| 1471 |
backend_address_pools: |
| 1472 |
- backend_addresses: |
| 1473 |
- ip_address: 10.0.0.4 |
| 1474 |
name: test_backend_address_pool |
| 1475 |
backend_http_settings_collection: |
| 1476 |
- port: 80 |
| 1477 |
protocol: http |
| 1478 |
cookie_based_affinity: enabled |
| 1479 |
name: sample_appgateway_http_settings |
| 1480 |
http_listeners: |
| 1481 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 1482 |
frontend_port: ag_frontend_port |
| 1483 |
name: sample_http_listener |
| 1484 |
request_routing_rules: |
| 1485 |
- rule_type: basic |
| 1486 |
priority: 100 |
| 1487 |
backend_address_pool: test_backend_address_pool |
| 1488 |
backend_http_settings: sample_appgateway_http_settings |
| 1489 |
http_listener: sample_http_listener |
| 1490 |
name: rule1 |
| 1491 |
web_application_firewall_configuration: |
| 1492 |
- enabled: true |
| 1493 |
firewall_mode: Detection |
| 1494 |
rule_set_type: OWASP |
| 1495 |
rule_set_version: 3.0 |
| 1496 |
request_body_check: true |
| 1497 |
max_request_body_size_in_kb: 128 |
| 1498 |
file_upload_limit_in_mb: 100 |
| 1499 |
|
| 1500 |
- name: Create application gateway with multi parameters |
| 1501 |
azure_rm_appgateway: |
| 1502 |
resource_group: myResourceGroup |
| 1503 |
name: myappgateway |
| 1504 |
sku: |
| 1505 |
name: standard_v2 |
| 1506 |
tier: standard_v2 |
| 1507 |
capacity: 2 |
| 1508 |
gateway_ip_configurations: |
| 1509 |
- subnet: |
| 1510 |
id: "{{ subnet_id }}" |
| 1511 |
name: app_gateway_ip_config |
| 1512 |
frontend_ip_configurations: |
| 1513 |
- name: sample_gateway_frontend_ip_config |
| 1514 |
public_ip_address: "pip{{ rpfx }}" |
| 1515 |
frontend_ports: |
| 1516 |
- port: 80 |
| 1517 |
name: http_frontend_port |
| 1518 |
backend_address_pools: |
| 1519 |
- name: test_backend_address_pool # empty pool which will receive attachment to NIC. |
| 1520 |
backend_http_settings_collection: |
| 1521 |
- port: 80 |
| 1522 |
protocol: http |
| 1523 |
cookie_based_affinity: enabled |
| 1524 |
name: sample_appgateway_http_settings |
| 1525 |
http_listeners: |
| 1526 |
- frontend_ip_configuration: sample_gateway_frontend_ip_config |
| 1527 |
frontend_port: http_frontend_port |
| 1528 |
protocol: http |
| 1529 |
name: http_listener |
| 1530 |
probes: |
| 1531 |
- name: testprobes01 |
| 1532 |
protocol: http |
| 1533 |
path: '/' |
| 1534 |
timeout: 30 |
| 1535 |
host: testazure |
| 1536 |
interval: 90 |
| 1537 |
port: 80 |
| 1538 |
match: |
| 1539 |
status_codes: |
| 1540 |
- 200 |
| 1541 |
request_routing_rules: |
| 1542 |
- rule_type: basic |
| 1543 |
priority: 100 |
| 1544 |
backend_address_pool: test_backend_address_pool |
| 1545 |
backend_http_settings: sample_appgateway_http_settings |
| 1546 |
http_listener: http_listener |
| 1547 |
name: rule1 |
| 1548 |
|
| 1549 |
- name: Stop an Application Gateway instance |
| 1550 |
azure_rm_appgateway: |
| 1551 |
resource_group: myResourceGroup |
| 1552 |
name: myAppGateway |
| 1553 |
gateway_state: stopped |
| 1554 |
|
| 1555 |
- name: Start an Application Gateway instance |
| 1556 |
azure_rm_appgateway: |
| 1557 |
resource_group: myResourceGroup |
| 1558 |
name: myAppGateway |
| 1559 |
gateway_state: started |
| 1560 |
''' |
| 1561 |
|
| 1562 |
RETURN = ''' |
| 1563 |
id: |
| 1564 |
description: |
| 1565 |
- Application gateway resource ID. |
| 1566 |
returned: always |
| 1567 |
type: str |
| 1568 |
sample: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/myAppGw |
| 1569 |
name: |
| 1570 |
description: |
| 1571 |
- Name of application gateway. |
| 1572 |
returned: always |
| 1573 |
type: str |
| 1574 |
sample: myAppGw |
| 1575 |
resource_group: |
| 1576 |
description: |
| 1577 |
- Name of resource group. |
| 1578 |
returned: always |
| 1579 |
type: str |
| 1580 |
sample: myResourceGroup |
| 1581 |
location: |
| 1582 |
description: |
| 1583 |
- Location of application gateway. |
| 1584 |
returned: always |
| 1585 |
type: str |
| 1586 |
sample: centralus |
| 1587 |
operational_state: |
| 1588 |
description: |
| 1589 |
- Operating state of application gateway. |
| 1590 |
returned: always |
| 1591 |
type: str |
| 1592 |
sample: Running |
| 1593 |
provisioning_state: |
| 1594 |
description: |
| 1595 |
- Provisioning state of application gateway. |
| 1596 |
returned: always |
| 1597 |
type: str |
| 1598 |
sample: Succeeded |
| 1599 |
''' |
| 1600 |
|
| 1601 |
import time |
| 1602 |
from copy import deepcopy |
| 1603 |
import json |
| 1604 |
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ext import AzureRMModuleBaseExt |
| 1605 |
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_rest import GenericRestClient |
| 1606 |
from ansible.module_utils.common.dict_transformations import _snake_to_camel |
| 1607 |
from ansible.module_utils.six.moves.collections_abc import MutableMapping |
| 1608 |
|
| 1609 |
try: |
| 1610 |
from azure.core.exceptions import ResourceNotFoundError |
| 1611 |
from azure.core.polling import LROPoller |
| 1612 |
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id |
| 1613 |
from azure.mgmt.network.models import ManagedServiceIdentity |
| 1614 |
except ImportError: |
| 1615 |
|
| 1616 |
pass |
| 1617 |
|
| 1618 |
|
| 1619 |
class Actions: |
| 1620 |
NoAction, Create, Update, Delete, Start, Stop = range(6) |
| 1621 |
|
| 1622 |
|
| 1623 |
sku_spec = dict( |
| 1624 |
capacity=dict(type='int'), |
| 1625 |
name=dict(type='str', choices=['standard_small', 'standard_medium', 'standard_large', 'standard_v2', 'waf_medium', 'waf_large', 'waf_v2']), |
| 1626 |
tier=dict(type='str', choices=['standard', 'standard_v2', 'waf', 'waf_v2']), |
| 1627 |
) |
| 1628 |
|
| 1629 |
|
| 1630 |
ssl_policy_spec = dict( |
| 1631 |
disabled_ssl_protocols=dict(type='list', elements='str', choices=['tls_v1_0', 'tls_v1_1', 'tls_v1_2']), |
| 1632 |
policy_type=dict(type='str', choices=['predefined', 'custom']), |
| 1633 |
policy_name=dict(type='str', choices=['ssl_policy20150501', 'ssl_policy20170401', 'ssl_policy20170401_s']), |
| 1634 |
min_protocol_version=dict(type='str', choices=['tls_v1_0', 'tls_v1_1', 'tls_v1_2']), |
| 1635 |
cipher_suites=dict(type='list', elements='str', |
| 1636 |
choices=['tls_ecdhe_rsa_with_aes_256_gcm_sha384', 'tls_ecdhe_rsa_with_aes_128_gcm_sha256', 'tls_ecdhe_rsa_with_aes_256_cbc_sha384', |
| 1637 |
'tls_ecdhe_rsa_with_aes_128_cbc_sha256', 'tls_ecdhe_rsa_with_aes_256_cbc_sha', 'tls_ecdhe_rsa_with_aes_128_cbc_sha', |
| 1638 |
'tls_dhe_rsa_with_aes_256_gcm_sha384', 'tls_dhe_rsa_with_aes_128_gcm_sha256', 'tls_dhe_rsa_with_aes_256_cbc_sha', |
| 1639 |
'tls_dhe_rsa_with_aes_128_cbc_sha', 'tls_rsa_with_aes_256_gcm_sha384', 'tls_rsa_with_aes_128_gcm_sha256', |
| 1640 |
'tls_rsa_with_aes_256_cbc_sha256', 'tls_rsa_with_aes_128_cbc_sha256', 'tls_rsa_with_aes_256_cbc_sha', |
| 1641 |
'tls_rsa_with_aes_128_cbc_sha', 'tls_ecdhe_ecdsa_with_aes_256_gcm_sha384', 'tls_ecdhe_ecdsa_with_aes_128_gcm_sha256', |
| 1642 |
'tls_ecdhe_ecdsa_with_aes_256_cbc_sha384', 'tls_ecdhe_ecdsa_with_aes_128_cbc_sha256', |
| 1643 |
'tls_ecdhe_ecdsa_with_aes_256_cbc_sha', 'tls_ecdhe_ecdsa_with_aes_128_cbc_sha', 'tls_dhe_dss_with_aes_256_cbc_sha256', |
| 1644 |
'tls_dhe_dss_with_aes_128_cbc_sha256', 'tls_dhe_dss_with_aes_256_cbc_sha', 'tls_dhe_dss_with_aes_128_cbc_sha', |
| 1645 |
'tls_rsa_with_3des_ede_cbc_sha', 'tls_dhe_dss_with_3des_ede_cbc_sha']), |
| 1646 |
) |
| 1647 |
|
| 1648 |
|
| 1649 |
match_spec = dict( |
| 1650 |
status_codes=dict(type='list', elements='str') |
| 1651 |
) |
| 1652 |
|
| 1653 |
|
| 1654 |
probe_spec = dict( |
| 1655 |
host=dict(type='str'), |
| 1656 |
interval=dict(type='int'), |
| 1657 |
name=dict(type='str'), |
| 1658 |
path=dict(type='str'), |
| 1659 |
protocol=dict(type='str', choices=['http', 'https']), |
| 1660 |
timeout=dict(type='int'), |
| 1661 |
unhealthy_threshold=dict(type='int'), |
| 1662 |
pick_host_name_from_backend_http_settings=dict(type='bool', default=False), |
| 1663 |
port=dict(type='int'), |
| 1664 |
match=dict(type='dict', options=match_spec) |
| 1665 |
) |
| 1666 |
|
| 1667 |
|
| 1668 |
redirect_path_rules_spec = dict( |
| 1669 |
name=dict(type='str'), |
| 1670 |
path_map_name=dict(type='str'), |
| 1671 |
) |
| 1672 |
|
| 1673 |
|
| 1674 |
redirect_configuration_spec = dict( |
| 1675 |
include_path=dict(type='bool'), |
| 1676 |
include_query_string=dict(type='bool'), |
| 1677 |
name=dict(type='str'), |
| 1678 |
redirect_type=dict(type='str', choices=['permanent', 'found', 'see_other', 'temporary']), |
| 1679 |
target_listener=dict(type='str'), |
| 1680 |
request_routing_rules=dict(type='list', elements='str'), |
| 1681 |
url_path_maps=dict(type='list', elements='str'), |
| 1682 |
path_rules=dict(type='list', elements='dict', options=redirect_path_rules_spec), |
| 1683 |
) |
| 1684 |
|
| 1685 |
|
| 1686 |
rewrite_condition_spec = dict( |
| 1687 |
variable=dict(type='str', required=True), |
| 1688 |
pattern=dict(type='str', required=True), |
| 1689 |
ignore_case=dict(type='bool', default=True), |
| 1690 |
negate=dict(type='bool', default=False), |
| 1691 |
) |
| 1692 |
|
| 1693 |
|
| 1694 |
rewrite_header_configuration_spec = dict( |
| 1695 |
header_name=dict(type='str', required=True), |
| 1696 |
header_value=dict(type='str', default=''), |
| 1697 |
) |
| 1698 |
|
| 1699 |
|
| 1700 |
rewrite_url_configuration_spec = dict( |
| 1701 |
modified_path=dict(type='str'), |
| 1702 |
modified_query_string=dict(type='str'), |
| 1703 |
reroute=dict(type='bool', default=False), |
| 1704 |
) |
| 1705 |
|
| 1706 |
|
| 1707 |
rewrite_action_set_spec = dict( |
| 1708 |
request_header_configurations=dict(type='list', elements='dict', options=rewrite_header_configuration_spec, default=[]), |
| 1709 |
response_header_configurations=dict(type='list', elements='dict', options=rewrite_header_configuration_spec, default=[]), |
| 1710 |
url_configuration=dict(type='dict', options=rewrite_url_configuration_spec), |
| 1711 |
) |
| 1712 |
|
| 1713 |
|
| 1714 |
rewrite_rule_spec = dict( |
| 1715 |
name=dict(type='str', required=True), |
| 1716 |
rule_sequence=dict(type='int', required=True), |
| 1717 |
conditions=dict(type='list', elements='dict', options=rewrite_condition_spec, default=[]), |
| 1718 |
action_set=dict(type='dict', required=True, options=rewrite_action_set_spec), |
| 1719 |
) |
| 1720 |
|
| 1721 |
|
| 1722 |
rewrite_rule_set_spec = dict( |
| 1723 |
name=dict(type='str', required=True), |
| 1724 |
rewrite_rules=dict(type='list', elements='dict', required=True, options=rewrite_rule_spec), |
| 1725 |
) |
| 1726 |
|
| 1727 |
|
| 1728 |
path_rules_spec = dict( |
| 1729 |
name=dict(type='str'), |
| 1730 |
backend_address_pool=dict(type='str'), |
| 1731 |
backend_http_settings=dict(type='str'), |
| 1732 |
redirect_configuration=dict(type='str'), |
| 1733 |
paths=dict(type='list', elements='str'), |
| 1734 |
rewrite_rule_set=dict(type='str'), |
| 1735 |
) |
| 1736 |
|
| 1737 |
|
| 1738 |
url_path_maps_spec = dict( |
| 1739 |
name=dict(type='str'), |
| 1740 |
default_backend_address_pool=dict(type='str'), |
| 1741 |
default_backend_http_settings=dict(type='str'), |
| 1742 |
path_rules=dict( |
| 1743 |
type='list', |
| 1744 |
elements='dict', |
| 1745 |
options=path_rules_spec, |
| 1746 |
mutually_exclusive=[('backend_address_pool', 'redirect_configuration')], |
| 1747 |
required_one_of=[('backend_address_pool', 'redirect_configuration')], |
| 1748 |
required_together=[('backend_address_pool', 'backend_http_settings')], |
| 1749 |
), |
| 1750 |
default_redirect_configuration=dict(type='str'), |
| 1751 |
default_rewrite_rule_set=dict(type='str'), |
| 1752 |
) |
| 1753 |
|
| 1754 |
autoscale_configuration_spec = dict( |
| 1755 |
max_capacity=dict(type='int'), |
| 1756 |
min_capacity=dict(type='int'), |
| 1757 |
) |
| 1758 |
|
| 1759 |
waf_configuration_exclusions_spec = dict( |
| 1760 |
match_variable=dict(type='str'), |
| 1761 |
selector=dict(type='str'), |
| 1762 |
selector_match_operator=dict(type='str'), |
| 1763 |
) |
| 1764 |
|
| 1765 |
waf_configuration_disabled_rule_groups_spec = dict( |
| 1766 |
rule_group_name=dict(type='str'), |
| 1767 |
rules=dict(type='list', elements='int', default=[]), |
| 1768 |
) |
| 1769 |
|
| 1770 |
firewall_policy_spec = dict( |
| 1771 |
id=dict(type='str'), |
| 1772 |
name=dict(type='str'), |
| 1773 |
force_association=dict(type='bool', default=True), |
| 1774 |
) |
| 1775 |
|
| 1776 |
web_application_firewall_configuration_spec = dict( |
| 1777 |
enabled=dict(type='bool'), |
| 1778 |
firewall_mode=dict(type='str', choices=['Detection', 'Prevention']), |
| 1779 |
rule_set_type=dict(type='str', choices=['OWASP']), |
| 1780 |
rule_set_version=dict(type='str'), |
| 1781 |
request_body_check=dict(type='bool'), |
| 1782 |
max_request_body_size=dict(type='int'), |
| 1783 |
max_request_body_size_in_kb=dict(type='int'), |
| 1784 |
file_upload_limit_in_mb=dict(type='int'), |
| 1785 |
exclusions=dict(type='list', elements='dict', options=waf_configuration_exclusions_spec, default=[]), |
| 1786 |
disabled_rule_groups=dict(type='list', elements='dict', options=waf_configuration_disabled_rule_groups_spec, default=[]), |
| 1787 |
firewall_policy=dict(type='dict', options=firewall_policy_spec), |
| 1788 |
) |
| 1789 |
|
| 1790 |
trusted_root_certificates_spec = dict( |
| 1791 |
name=dict(type='str'), |
| 1792 |
data=dict(type='str'), |
| 1793 |
key_vault_secret_id=dict(type='str', default='') |
| 1794 |
) |
| 1795 |
|
| 1796 |
|
| 1797 |
ssl_certificates_spec = dict( |
| 1798 |
name=dict(type='str'), |
| 1799 |
data=dict(type='str'), |
| 1800 |
password=dict(type='str', no_log=True), |
| 1801 |
key_vault_secret_id=dict(type='str', default='') |
| 1802 |
) |
| 1803 |
|
| 1804 |
|
| 1805 |
class AzureRMApplicationGateways(AzureRMModuleBaseExt): |
| 1806 |
"""Configuration class for an Azure RM Application Gateway resource""" |
| 1807 |
|
| 1808 |
def __init__(self): |
| 1809 |
self.module_arg_spec = dict( |
| 1810 |
resource_group=dict( |
| 1811 |
type='str', |
| 1812 |
required=True |
| 1813 |
), |
| 1814 |
name=dict( |
| 1815 |
type='str', |
| 1816 |
required=True |
| 1817 |
), |
| 1818 |
location=dict( |
| 1819 |
type='str' |
| 1820 |
), |
| 1821 |
sku=dict( |
| 1822 |
type='dict', |
| 1823 |
options=sku_spec, |
| 1824 |
), |
| 1825 |
ssl_policy=dict( |
| 1826 |
type='dict', |
| 1827 |
options=ssl_policy_spec |
| 1828 |
), |
| 1829 |
gateway_ip_configurations=dict( |
| 1830 |
type='list', |
| 1831 |
elements='dict', |
| 1832 |
options=dict( |
| 1833 |
name=dict(type='str'), |
| 1834 |
subnet=dict( |
| 1835 |
type='dict', |
| 1836 |
options=dict( |
| 1837 |
id=dict(type='str'), |
| 1838 |
name=dict(type='str'), |
| 1839 |
virtual_network_name=dict(type='str') |
| 1840 |
) |
| 1841 |
) |
| 1842 |
) |
| 1843 |
), |
| 1844 |
authentication_certificates=dict( |
| 1845 |
type='list', |
| 1846 |
elements='dict', |
| 1847 |
options=dict( |
| 1848 |
name=dict(type='str'), |
| 1849 |
data=dict(type='str') |
| 1850 |
), |
| 1851 |
), |
| 1852 |
ssl_certificates=dict( |
| 1853 |
type='list', |
| 1854 |
elements='dict', |
| 1855 |
options=ssl_certificates_spec |
| 1856 |
), |
| 1857 |
trusted_root_certificates=dict( |
| 1858 |
type='list', |
| 1859 |
elements='dict', |
| 1860 |
options=trusted_root_certificates_spec |
| 1861 |
), |
| 1862 |
redirect_configurations=dict( |
| 1863 |
type='list', |
| 1864 |
elements='dict', |
| 1865 |
options=redirect_configuration_spec |
| 1866 |
), |
| 1867 |
rewrite_rule_sets=dict( |
| 1868 |
type='list', |
| 1869 |
elements='dict', |
| 1870 |
options=rewrite_rule_set_spec |
| 1871 |
), |
| 1872 |
frontend_ip_configurations=dict( |
| 1873 |
type='list', |
| 1874 |
elements='dict', |
| 1875 |
options=dict( |
| 1876 |
private_ip_address=dict(type='str'), |
| 1877 |
private_ip_allocation_method=dict(type='str', choices=['static', 'dynamic']), |
| 1878 |
public_ip_address=dict(type='raw'), |
| 1879 |
name=dict(type='str'), |
| 1880 |
subnet=dict( |
| 1881 |
type='dict', |
| 1882 |
options=dict( |
| 1883 |
id=dict(type='str'), |
| 1884 |
name=dict(type='str'), |
| 1885 |
virtual_network_name=dict(type='str') |
| 1886 |
) |
| 1887 |
) |
| 1888 |
) |
| 1889 |
), |
| 1890 |
frontend_ports=dict( |
| 1891 |
type='list', |
| 1892 |
elements='dict', |
| 1893 |
options=dict( |
| 1894 |
port=dict(type='str'), |
| 1895 |
name=dict(type='str') |
| 1896 |
) |
| 1897 |
), |
| 1898 |
backend_address_pools=dict( |
| 1899 |
type='list', |
| 1900 |
elements='dict', |
| 1901 |
options=dict( |
| 1902 |
name=dict(type='str'), |
| 1903 |
backend_addresses=dict( |
| 1904 |
type='list', |
| 1905 |
elements='dict', |
| 1906 |
options=dict( |
| 1907 |
fqdn=dict(type='str'), |
| 1908 |
ip_address=dict(type='str') |
| 1909 |
) |
| 1910 |
) |
| 1911 |
) |
| 1912 |
), |
| 1913 |
backend_http_settings_collection=dict( |
| 1914 |
type='list', |
| 1915 |
elements='dict', |
| 1916 |
options=dict( |
| 1917 |
probe=dict(type='raw'), |
| 1918 |
port=dict(type='int'), |
| 1919 |
protocol=dict(type='str', choices=['http', 'https']), |
| 1920 |
cookie_based_affinity=dict(type='str', choices=['enabled', 'disabled']), |
| 1921 |
connection_draining=dict( |
| 1922 |
type='dict', |
| 1923 |
options=dict( |
| 1924 |
drain_timeout_in_sec=dict(type='int'), |
| 1925 |
enabled=dict(type='bool') |
| 1926 |
) |
| 1927 |
), |
| 1928 |
request_timeout=dict(type='int'), |
| 1929 |
authentication_certificates=dict( |
| 1930 |
type='list', |
| 1931 |
elements='dict', |
| 1932 |
options=dict( |
| 1933 |
id=dict(type='str') |
| 1934 |
) |
| 1935 |
), |
| 1936 |
trusted_root_certificates=dict(type='list', elements='raw'), |
| 1937 |
host_name=dict(type='str'), |
| 1938 |
pick_host_name_from_backend_address=dict(type='bool'), |
| 1939 |
affinity_cookie_name=dict(type='str'), |
| 1940 |
path=dict(type='str'), |
| 1941 |
name=dict(type='str') |
| 1942 |
) |
| 1943 |
), |
| 1944 |
probes=dict( |
| 1945 |
type='list', |
| 1946 |
elements='dict', |
| 1947 |
options=probe_spec |
| 1948 |
), |
| 1949 |
http_listeners=dict( |
| 1950 |
type='list', |
| 1951 |
elements='dict', |
| 1952 |
options=dict( |
| 1953 |
frontend_ip_configuration=dict(type='raw'), |
| 1954 |
frontend_port=dict(type='raw'), |
| 1955 |
protocol=dict(type='str', choices=['http', 'https']), |
| 1956 |
host_name=dict(type='str'), |
| 1957 |
ssl_certificate=dict(type='raw'), |
| 1958 |
require_server_name_indication=dict(type='bool'), |
| 1959 |
name=dict(type='str'), |
| 1960 |
) |
| 1961 |
), |
| 1962 |
url_path_maps=dict( |
| 1963 |
type='list', |
| 1964 |
elements='dict', |
| 1965 |
options=url_path_maps_spec, |
| 1966 |
mutually_exclusive=[('default_backend_address_pool', 'default_redirect_configuration')], |
| 1967 |
required_one_of=[('default_backend_address_pool', 'default_redirect_configuration')], |
| 1968 |
required_together=[('default_backend_address_pool', 'default_backend_http_settings')], |
| 1969 |
), |
| 1970 |
request_routing_rules=dict( |
| 1971 |
type='list', |
| 1972 |
elements='dict', |
| 1973 |
options=dict( |
| 1974 |
rule_type=dict(type='str', choices=['basic', 'path_based_routing']), |
| 1975 |
priority=dict(type='int', required=True), |
| 1976 |
backend_address_pool=dict(type='raw'), |
| 1977 |
backend_http_settings=dict(type='raw'), |
| 1978 |
http_listener=dict(type='raw'), |
| 1979 |
name=dict(type='str'), |
| 1980 |
redirect_configuration=dict(type='raw'), |
| 1981 |
rewrite_rule_set=dict(type='raw'), |
| 1982 |
url_path_map=dict(type='raw'), |
| 1983 |
) |
| 1984 |
), |
| 1985 |
autoscale_configuration=dict( |
| 1986 |
type='dict', |
| 1987 |
options=autoscale_configuration_spec, |
| 1988 |
), |
| 1989 |
web_application_firewall_configuration=dict( |
| 1990 |
type='dict', |
| 1991 |
options=web_application_firewall_configuration_spec |
| 1992 |
), |
| 1993 |
enable_http2=dict( |
| 1994 |
type='bool', |
| 1995 |
default=False |
| 1996 |
), |
| 1997 |
identity=dict( |
| 1998 |
type='dict', |
| 1999 |
options=self.managed_identity_multiple_spec |
| 2000 |
), |
| 2001 |
gateway_state=dict( |
| 2002 |
type='str', |
| 2003 |
choices=['started', 'stopped'], |
| 2004 |
), |
| 2005 |
state=dict( |
| 2006 |
type='str', |
| 2007 |
default='present', |
| 2008 |
choices=['present', 'absent'] |
| 2009 |
) |
| 2010 |
) |
| 2011 |
|
| 2012 |
self.resource_group = None |
| 2013 |
self.name = None |
| 2014 |
self.parameters = dict() |
| 2015 |
|
| 2016 |
self.results = dict(changed=False) |
| 2017 |
self.state = None |
| 2018 |
self.gateway_state = None |
| 2019 |
self.to_do = Actions.NoAction |
| 2020 |
self.identity = None |
| 2021 |
self._managed_identity = None |
| 2022 |
|
| 2023 |
super(AzureRMApplicationGateways, self).__init__(derived_arg_spec=self.module_arg_spec, |
| 2024 |
supports_check_mode=True, |
| 2025 |
supports_tags=True) |
| 2026 |
|
| 2027 |
@property |
| 2028 |
def managed_identity(self): |
| 2029 |
if not self._managed_identity: |
| 2030 |
self._managed_identity = {"identity": ManagedServiceIdentity, |
| 2031 |
"user_assigned": dict |
| 2032 |
} |
| 2033 |
return self._managed_identity |
| 2034 |
|
| 2035 |
def exec_module(self, **kwargs): |
| 2036 |
"""Main module execution method""" |
| 2037 |
for key in list(self.module_arg_spec.keys()) + ['tags']: |
| 2038 |
if hasattr(self, key): |
| 2039 |
setattr(self, key, kwargs[key]) |
| 2040 |
elif kwargs[key] is not None: |
| 2041 |
if key == "id": |
| 2042 |
self.parameters["id"] = kwargs[key] |
| 2043 |
elif key == "location": |
| 2044 |
self.parameters["location"] = kwargs[key] |
| 2045 |
elif key == "sku": |
| 2046 |
ev = kwargs[key] |
| 2047 |
if 'name' in ev: |
| 2048 |
if ev['name'] == 'standard_small': |
| 2049 |
ev['name'] = 'Standard_Small' |
| 2050 |
elif ev['name'] == 'standard_medium': |
| 2051 |
ev['name'] = 'Standard_Medium' |
| 2052 |
elif ev['name'] == 'standard_large': |
| 2053 |
ev['name'] = 'Standard_Large' |
| 2054 |
elif ev['name'] == 'standard_v2': |
| 2055 |
ev['name'] = 'Standard_v2' |
| 2056 |
elif ev['name'] == 'waf_medium': |
| 2057 |
ev['name'] = 'WAF_Medium' |
| 2058 |
elif ev['name'] == 'waf_large': |
| 2059 |
ev['name'] = 'WAF_Large' |
| 2060 |
elif ev['name'] == 'waf_v2': |
| 2061 |
ev['name'] = 'WAF_v2' |
| 2062 |
if 'tier' in ev: |
| 2063 |
if ev['tier'] == 'standard': |
| 2064 |
ev['tier'] = 'Standard' |
| 2065 |
if ev['tier'] == 'standard_v2': |
| 2066 |
ev['tier'] = 'Standard_v2' |
| 2067 |
elif ev['tier'] == 'waf': |
| 2068 |
ev['tier'] = 'WAF' |
| 2069 |
elif ev['tier'] == 'waf_v2': |
| 2070 |
ev['tier'] = 'WAF_v2' |
| 2071 |
self.parameters["sku"] = ev |
| 2072 |
elif key == "ssl_policy": |
| 2073 |
ev = kwargs[key] |
| 2074 |
if 'policy_type' in ev: |
| 2075 |
ev['policy_type'] = _snake_to_camel(ev['policy_type'], True) |
| 2076 |
if 'policy_name' in ev: |
| 2077 |
if ev['policy_name'] == 'ssl_policy20150501': |
| 2078 |
ev['policy_name'] = 'AppGwSslPolicy20150501' |
| 2079 |
elif ev['policy_name'] == 'ssl_policy20170401': |
| 2080 |
ev['policy_name'] = 'AppGwSslPolicy20170401' |
| 2081 |
elif ev['policy_name'] == 'ssl_policy20170401_s': |
| 2082 |
ev['policy_name'] = 'AppGwSslPolicy20170401S' |
| 2083 |
if 'min_protocol_version' in ev: |
| 2084 |
if ev['min_protocol_version'] == 'tls_v1_0': |
| 2085 |
ev['min_protocol_version'] = 'TLSv1_0' |
| 2086 |
elif ev['min_protocol_version'] == 'tls_v1_1': |
| 2087 |
ev['min_protocol_version'] = 'TLSv1_1' |
| 2088 |
elif ev['min_protocol_version'] == 'tls_v1_2': |
| 2089 |
ev['min_protocol_version'] = 'TLSv1_2' |
| 2090 |
if 'disabled_ssl_protocols' in ev: |
| 2091 |
protocols = ev['disabled_ssl_protocols'] |
| 2092 |
if protocols is not None: |
| 2093 |
for i in range(len(protocols)): |
| 2094 |
if protocols[i] == 'tls_v1_0': |
| 2095 |
protocols[i] = 'TLSv1_0' |
| 2096 |
elif protocols[i] == 'tls_v1_1': |
| 2097 |
protocols[i] = 'TLSv1_1' |
| 2098 |
elif protocols[i] == 'tls_v1_2': |
| 2099 |
protocols[i] = 'TLSv1_2' |
| 2100 |
if 'cipher_suites' in ev: |
| 2101 |
suites = ev['cipher_suites'] |
| 2102 |
if suites is not None: |
| 2103 |
for i in range(len(suites)): |
| 2104 |
suites[i] = suites[i].upper() |
| 2105 |
for prop_name in ['policy_name', 'min_protocol_version', 'disabled_ssl_protocols', 'cipher_suites']: |
| 2106 |
if prop_name in ev and ev[prop_name] is None: |
| 2107 |
|
| 2108 |
del ev[prop_name] |
| 2109 |
self.parameters["ssl_policy"] = ev |
| 2110 |
elif key == "gateway_ip_configurations": |
| 2111 |
ev = kwargs[key] |
| 2112 |
for i in range(len(ev)): |
| 2113 |
item = ev[i] |
| 2114 |
if 'subnet' in item and item['subnet'] is not None and 'name' in item['subnet'] and item['subnet']['name'] is not None and \ |
| 2115 |
'virtual_network_name' in item['subnet'] and item['subnet']['virtual_network_name'] is not None: |
| 2116 |
id = subnet_id(self.subscription_id, |
| 2117 |
kwargs['resource_group'], |
| 2118 |
item['subnet']['virtual_network_name'], |
| 2119 |
item['subnet']['name']) |
| 2120 |
item['subnet'] = {'id': id} |
| 2121 |
self.parameters["gateway_ip_configurations"] = kwargs[key] |
| 2122 |
elif key == "authentication_certificates": |
| 2123 |
self.parameters["authentication_certificates"] = kwargs[key] |
| 2124 |
elif key == "ssl_certificates": |
| 2125 |
self.parameters["ssl_certificates"] = kwargs[key] |
| 2126 |
elif key == "trusted_root_certificates": |
| 2127 |
self.parameters["trusted_root_certificates"] = kwargs[key] |
| 2128 |
elif key == "redirect_configurations": |
| 2129 |
ev = kwargs[key] |
| 2130 |
for i in range(len(ev)): |
| 2131 |
item = ev[i] |
| 2132 |
if 'redirect_type' in item: |
| 2133 |
item['redirect_type'] = _snake_to_camel(item['redirect_type'], True) |
| 2134 |
if 'target_listener' in item: |
| 2135 |
id = http_listener_id(self.subscription_id, |
| 2136 |
kwargs['resource_group'], |
| 2137 |
kwargs['name'], |
| 2138 |
item['target_listener']) |
| 2139 |
item['target_listener'] = {'id': id} |
| 2140 |
if item['request_routing_rules']: |
| 2141 |
for j in range(len(item['request_routing_rules'])): |
| 2142 |
rule_name = item['request_routing_rules'][j] |
| 2143 |
id = request_routing_rule_id(self.subscription_id, |
| 2144 |
kwargs['resource_group'], |
| 2145 |
kwargs['name'], |
| 2146 |
rule_name) |
| 2147 |
item['request_routing_rules'][j] = {'id': id} |
| 2148 |
else: |
| 2149 |
del item['request_routing_rules'] |
| 2150 |
if item['url_path_maps']: |
| 2151 |
for j in range(len(item['url_path_maps'])): |
| 2152 |
pathmap_name = item['url_path_maps'][j] |
| 2153 |
id = url_path_map_id(self.subscription_id, |
| 2154 |
kwargs['resource_group'], |
| 2155 |
kwargs['name'], |
| 2156 |
pathmap_name) |
| 2157 |
item['url_path_maps'][j] = {'id': id} |
| 2158 |
else: |
| 2159 |
del item['url_path_maps'] |
| 2160 |
if item['path_rules']: |
| 2161 |
for j in range(len(item['path_rules'])): |
| 2162 |
pathrule = item['path_rules'][j] |
| 2163 |
if 'name' in pathrule and 'path_map_name' in pathrule: |
| 2164 |
id = url_path_rule_id(self.subscription_id, |
| 2165 |
kwargs['resource_group'], |
| 2166 |
kwargs['name'], |
| 2167 |
pathrule['path_map_name'], |
| 2168 |
pathrule['name']) |
| 2169 |
item['path_rules'][j] = {'id': id} |
| 2170 |
else: |
| 2171 |
del item['path_rules'] |
| 2172 |
self.parameters["redirect_configurations"] = ev |
| 2173 |
elif key == "rewrite_rule_sets": |
| 2174 |
ev = kwargs[key] |
| 2175 |
for i in range(len(ev)): |
| 2176 |
ev2 = ev[i]['rewrite_rules'] |
| 2177 |
for j in range(len(ev2)): |
| 2178 |
item2 = ev2[j] |
| 2179 |
if item2['action_set'].get('url_configuration'): |
| 2180 |
if not item2['action_set']['url_configuration'].get('modified_path'): |
| 2181 |
del item2['action_set']['url_configuration']['modified_path'] |
| 2182 |
if not item2['action_set']['url_configuration'].get('modified_query_string'): |
| 2183 |
del item2['action_set']['url_configuration']['modified_query_string'] |
| 2184 |
else: |
| 2185 |
del item2['action_set']['url_configuration'] |
| 2186 |
self.parameters["rewrite_rule_sets"] = ev |
| 2187 |
elif key == "frontend_ip_configurations": |
| 2188 |
ev = kwargs[key] |
| 2189 |
for i in range(len(ev)): |
| 2190 |
item = ev[i] |
| 2191 |
if 'private_ip_allocation_method' in item and item['private_ip_allocation_method'] is not None: |
| 2192 |
item['private_ip_allocation_method'] = _snake_to_camel(item['private_ip_allocation_method'], True) |
| 2193 |
if 'public_ip_address' in item and item['public_ip_address'] is not None: |
| 2194 |
pip = item['public_ip_address'] |
| 2195 |
pip_id = (pip if is_valid_resource_id(pip) else public_ip_id( |
| 2196 |
self.subscription_id, |
| 2197 |
kwargs['resource_group'], |
| 2198 |
pip |
| 2199 |
)) |
| 2200 |
item['public_ip_address'] = {'id': pip_id} |
| 2201 |
if 'subnet' in item and item['subnet'] is not None and 'name' in item['subnet'] and item['subnet']['name'] is not None and \ |
| 2202 |
'virtual_network_name' in item['subnet'] and item['subnet']['virtual_network_name'] is not None: |
| 2203 |
id = subnet_id(self.subscription_id, |
| 2204 |
kwargs['resource_group'], |
| 2205 |
item['subnet']['virtual_network_name'], |
| 2206 |
item['subnet']['name']) |
| 2207 |
item['subnet'] = {'id': id} |
| 2208 |
self.parameters["frontend_ip_configurations"] = ev |
| 2209 |
elif key == "frontend_ports": |
| 2210 |
self.parameters["frontend_ports"] = kwargs[key] |
| 2211 |
elif key == "backend_address_pools": |
| 2212 |
self.parameters["backend_address_pools"] = kwargs[key] |
| 2213 |
elif key == "probes": |
| 2214 |
ev = kwargs[key] |
| 2215 |
for i in range(len(ev)): |
| 2216 |
item = ev[i] |
| 2217 |
if 'protocol' in item and item['protocol'] is not None: |
| 2218 |
item['protocol'] = _snake_to_camel(item['protocol'], True) |
| 2219 |
if 'pick_host_name_from_backend_http_settings' in item and item['pick_host_name_from_backend_http_settings'] and 'host' in item: |
| 2220 |
del item['host'] |
| 2221 |
self.parameters["probes"] = ev |
| 2222 |
elif key == "backend_http_settings_collection": |
| 2223 |
ev = kwargs[key] |
| 2224 |
for i in range(len(ev)): |
| 2225 |
item = ev[i] |
| 2226 |
if 'protocol' in item and item['protocol'] is not None: |
| 2227 |
item['protocol'] = _snake_to_camel(item['protocol'], True) |
| 2228 |
if 'cookie_based_affinity' in item and item['cookie_based_affinity'] is not None: |
| 2229 |
item['cookie_based_affinity'] = _snake_to_camel(item['cookie_based_affinity'], True) |
| 2230 |
if 'probe' in item and item['probe'] is not None: |
| 2231 |
id = probe_id(self.subscription_id, |
| 2232 |
kwargs['resource_group'], |
| 2233 |
kwargs['name'], |
| 2234 |
item['probe']) |
| 2235 |
item['probe'] = {'id': id} |
| 2236 |
if 'trusted_root_certificates' in item and item['trusted_root_certificates'] is not None: |
| 2237 |
for j in range(len(item['trusted_root_certificates'])): |
| 2238 |
id = item['trusted_root_certificates'][j] |
| 2239 |
id = id if is_valid_resource_id(id) else trusted_root_certificate_id(self.subscription_id, |
| 2240 |
kwargs['resource_group'], |
| 2241 |
kwargs['name'], |
| 2242 |
id) |
| 2243 |
item['trusted_root_certificates'][j] = {'id': id} |
| 2244 |
self.parameters["backend_http_settings_collection"] = ev |
| 2245 |
elif key == "http_listeners": |
| 2246 |
ev = kwargs[key] |
| 2247 |
for i in range(len(ev)): |
| 2248 |
item = ev[i] |
| 2249 |
if 'frontend_ip_configuration' in item and item['frontend_ip_configuration'] is not None: |
| 2250 |
id = frontend_ip_configuration_id(self.subscription_id, |
| 2251 |
kwargs['resource_group'], |
| 2252 |
kwargs['name'], |
| 2253 |
item['frontend_ip_configuration']) |
| 2254 |
item['frontend_ip_configuration'] = {'id': id} |
| 2255 |
|
| 2256 |
if 'frontend_port' in item and item['frontend_port'] is not None: |
| 2257 |
id = frontend_port_id(self.subscription_id, |
| 2258 |
kwargs['resource_group'], |
| 2259 |
kwargs['name'], |
| 2260 |
item['frontend_port']) |
| 2261 |
item['frontend_port'] = {'id': id} |
| 2262 |
if 'ssl_certificate' in item and item['ssl_certificate'] is not None: |
| 2263 |
id = ssl_certificate_id(self.subscription_id, |
| 2264 |
kwargs['resource_group'], |
| 2265 |
kwargs['name'], |
| 2266 |
item['ssl_certificate']) |
| 2267 |
item['ssl_certificate'] = {'id': id} |
| 2268 |
if 'protocol' in item and item['protocol'] is not None: |
| 2269 |
item['protocol'] = _snake_to_camel(item['protocol'], True) |
| 2270 |
ev[i] = item |
| 2271 |
self.parameters["http_listeners"] = ev |
| 2272 |
elif key == "url_path_maps": |
| 2273 |
ev = kwargs[key] |
| 2274 |
for i in range(len(ev)): |
| 2275 |
item = ev[i] |
| 2276 |
if item['default_backend_address_pool'] and item['default_backend_address_pool'] is not None: |
| 2277 |
id = backend_address_pool_id(self.subscription_id, |
| 2278 |
kwargs['resource_group'], |
| 2279 |
kwargs['name'], |
| 2280 |
item['default_backend_address_pool']) |
| 2281 |
item['default_backend_address_pool'] = {'id': id} |
| 2282 |
else: |
| 2283 |
del item['default_backend_address_pool'] |
| 2284 |
if item['default_backend_http_settings'] and item['default_backend_http_settings'] is not None: |
| 2285 |
id = backend_http_settings_id(self.subscription_id, |
| 2286 |
kwargs['resource_group'], |
| 2287 |
kwargs['name'], |
| 2288 |
item['default_backend_http_settings']) |
| 2289 |
item['default_backend_http_settings'] = {'id': id} |
| 2290 |
else: |
| 2291 |
del item['default_backend_http_settings'] |
| 2292 |
if 'path_rules' in item: |
| 2293 |
ev2 = item['path_rules'] |
| 2294 |
for j in range(len(ev2)): |
| 2295 |
item2 = ev2[j] |
| 2296 |
if item2['backend_address_pool'] and item2['backend_address_pool'] is not None: |
| 2297 |
id = backend_address_pool_id(self.subscription_id, |
| 2298 |
kwargs['resource_group'], |
| 2299 |
kwargs['name'], |
| 2300 |
item2['backend_address_pool']) |
| 2301 |
item2['backend_address_pool'] = {'id': id} |
| 2302 |
else: |
| 2303 |
del item2['backend_address_pool'] |
| 2304 |
if item2['backend_http_settings'] and item2['backend_http_settings'] is not None: |
| 2305 |
id = backend_http_settings_id(self.subscription_id, |
| 2306 |
kwargs['resource_group'], |
| 2307 |
kwargs['name'], |
| 2308 |
item2['backend_http_settings']) |
| 2309 |
item2['backend_http_settings'] = {'id': id} |
| 2310 |
else: |
| 2311 |
del item2['backend_http_settings'] |
| 2312 |
if item2['redirect_configuration'] and item2['redirect_configuration'] is not None: |
| 2313 |
id = redirect_configuration_id(self.subscription_id, |
| 2314 |
kwargs['resource_group'], |
| 2315 |
kwargs['name'], |
| 2316 |
item2['redirect_configuration']) |
| 2317 |
item2['redirect_configuration'] = {'id': id} |
| 2318 |
else: |
| 2319 |
del item2['redirect_configuration'] |
| 2320 |
if item2['rewrite_rule_set']: |
| 2321 |
id = item2['rewrite_rule_set'] |
| 2322 |
id = id if is_valid_resource_id(id) else rewrite_rule_set_id(self.subscription_id, |
| 2323 |
kwargs['resource_group'], |
| 2324 |
kwargs['name'], |
| 2325 |
id) |
| 2326 |
item2['rewrite_rule_set'] = {'id': id} |
| 2327 |
else: |
| 2328 |
del item2['rewrite_rule_set'] |
| 2329 |
ev2[j] = item2 |
| 2330 |
if item['default_redirect_configuration']: |
| 2331 |
id = redirect_configuration_id(self.subscription_id, |
| 2332 |
kwargs['resource_group'], |
| 2333 |
kwargs['name'], |
| 2334 |
item['default_redirect_configuration']) |
| 2335 |
item['default_redirect_configuration'] = {'id': id} |
| 2336 |
else: |
| 2337 |
del item['default_redirect_configuration'] |
| 2338 |
if item['default_rewrite_rule_set']: |
| 2339 |
id = item['default_rewrite_rule_set'] |
| 2340 |
id = id if is_valid_resource_id(id) else rewrite_rule_set_id(self.subscription_id, |
| 2341 |
kwargs['resource_group'], |
| 2342 |
kwargs['name'], |
| 2343 |
id) |
| 2344 |
item['default_rewrite_rule_set'] = {'id': id} |
| 2345 |
else: |
| 2346 |
del item['default_rewrite_rule_set'] |
| 2347 |
ev[i] = item |
| 2348 |
self.parameters["url_path_maps"] = ev |
| 2349 |
elif key == "request_routing_rules": |
| 2350 |
ev = kwargs[key] |
| 2351 |
for i in range(len(ev)): |
| 2352 |
item = ev[i] |
| 2353 |
if 'rule_type' in item and item['rule_type'] is not None and item['rule_type'] == 'path_based_routing' and \ |
| 2354 |
'backend_address_pool' in item and item['backend_address_pool'] is not None: |
| 2355 |
del item['backend_address_pool'] |
| 2356 |
if 'backend_address_pool' in item and item['backend_address_pool'] is not None: |
| 2357 |
id = backend_address_pool_id(self.subscription_id, |
| 2358 |
kwargs['resource_group'], |
| 2359 |
kwargs['name'], |
| 2360 |
item['backend_address_pool']) |
| 2361 |
item['backend_address_pool'] = {'id': id} |
| 2362 |
if 'backend_http_settings' in item and item['backend_http_settings'] is not None: |
| 2363 |
id = backend_http_settings_id(self.subscription_id, |
| 2364 |
kwargs['resource_group'], |
| 2365 |
kwargs['name'], |
| 2366 |
item['backend_http_settings']) |
| 2367 |
item['backend_http_settings'] = {'id': id} |
| 2368 |
if 'http_listener' in item and item['http_listener'] is not None: |
| 2369 |
id = http_listener_id(self.subscription_id, |
| 2370 |
kwargs['resource_group'], |
| 2371 |
kwargs['name'], |
| 2372 |
item['http_listener']) |
| 2373 |
item['http_listener'] = {'id': id} |
| 2374 |
if 'protocol' in item and item['protocol'] is not None: |
| 2375 |
item['protocol'] = _snake_to_camel(item['protocol'], True) |
| 2376 |
if 'rule_type' in item and item['rule_type'] is not None: |
| 2377 |
item['rule_type'] = _snake_to_camel(item['rule_type'], True) |
| 2378 |
if 'redirect_configuration' in item and item['redirect_configuration'] is not None: |
| 2379 |
id = redirect_configuration_id(self.subscription_id, |
| 2380 |
kwargs['resource_group'], |
| 2381 |
kwargs['name'], |
| 2382 |
item['redirect_configuration']) |
| 2383 |
item['redirect_configuration'] = {'id': id} |
| 2384 |
if 'url_path_map' in item and item['url_path_map'] is not None: |
| 2385 |
id = url_path_map_id(self.subscription_id, |
| 2386 |
kwargs['resource_group'], |
| 2387 |
kwargs['name'], |
| 2388 |
item['url_path_map']) |
| 2389 |
item['url_path_map'] = {'id': id} |
| 2390 |
if item.get('rewrite_rule_set'): |
| 2391 |
id = item.get('rewrite_rule_set') |
| 2392 |
id = id if is_valid_resource_id(id) else rewrite_rule_set_id(self.subscription_id, |
| 2393 |
kwargs['resource_group'], |
| 2394 |
kwargs['name'], |
| 2395 |
id) |
| 2396 |
item['rewrite_rule_set'] = {'id': id} |
| 2397 |
ev[i] = item |
| 2398 |
self.parameters["request_routing_rules"] = ev |
| 2399 |
elif key == "etag": |
| 2400 |
self.parameters["etag"] = kwargs[key] |
| 2401 |
elif key == "autoscale_configuration": |
| 2402 |
self.parameters["autoscale_configuration"] = kwargs[key] |
| 2403 |
elif key == "web_application_firewall_configuration": |
| 2404 |
self.set_web_application_firewall_configuration(kwargs) |
| 2405 |
elif key == "enable_http2": |
| 2406 |
self.parameters["enable_http2"] = kwargs[key] |
| 2407 |
elif key == "tags": |
| 2408 |
self.parameters["tags"] = kwargs[key] |
| 2409 |
|
| 2410 |
response = None |
| 2411 |
|
| 2412 |
self.mgmt_client = self.get_mgmt_svc_client(GenericRestClient, |
| 2413 |
base_url=self._cloud_environment.endpoints.resource_manager) |
| 2414 |
|
| 2415 |
resource_group = self.get_resource_group(self.resource_group) |
| 2416 |
|
| 2417 |
if "location" not in self.parameters: |
| 2418 |
self.parameters["location"] = resource_group.location |
| 2419 |
|
| 2420 |
old_response = self.get_applicationgateway() |
| 2421 |
|
| 2422 |
properties = self.get_resource() |
| 2423 |
old_ssl_certs = [] |
| 2424 |
if properties: |
| 2425 |
for old_cert in properties.get('properties', {}).get('sslCertificates', []): |
| 2426 |
old_public_cert = old_cert.get('properties', {}).get('publicCertData') |
| 2427 |
old_ssl_certs.append(old_public_cert) |
| 2428 |
|
| 2429 |
if not old_response: |
| 2430 |
self.log("Application Gateway instance doesn't exist") |
| 2431 |
if self.state == 'absent': |
| 2432 |
self.log("Old instance didn't exist") |
| 2433 |
else: |
| 2434 |
self.to_do = Actions.Create |
| 2435 |
else: |
| 2436 |
self.log("Application Gateway instance already exists") |
| 2437 |
if self.state == 'absent': |
| 2438 |
self.to_do = Actions.Delete |
| 2439 |
elif self.state == 'present': |
| 2440 |
self.log("Need to check if Application Gateway instance has to be deleted or may be updated") |
| 2441 |
self.to_do = Actions.Update |
| 2442 |
|
| 2443 |
self.results['compare'] = [] |
| 2444 |
if self.identity: |
| 2445 |
update_identity, identity = self.update_managed_identity(new_identity=self.identity, curr_identity=old_response.get('identity', {})) |
| 2446 |
else: |
| 2447 |
update_identity = False |
| 2448 |
identity = None |
| 2449 |
|
| 2450 |
if (self.to_do == Actions.Update): |
| 2451 |
if (old_response['operational_state'] == 'Stopped' and self.gateway_state == 'started'): |
| 2452 |
self.to_do = Actions.Start |
| 2453 |
elif (old_response['operational_state'] == 'Running' and self.gateway_state == 'stopped'): |
| 2454 |
self.to_do = Actions.Stop |
| 2455 |
elif ((old_response['operational_state'] == 'Stopped' and self.gateway_state == 'stopped') or |
| 2456 |
(old_response['operational_state'] == 'Running' and self.gateway_state == 'started')): |
| 2457 |
self.to_do = Actions.NoAction |
| 2458 |
elif (not self.idempotency_check(old_response, self.parameters) or |
| 2459 |
update_identity is True): |
| 2460 |
self.to_do = Actions.Update |
| 2461 |
else: |
| 2462 |
self.to_do = Actions.NoAction |
| 2463 |
|
| 2464 |
update_tags, new_tags = self.update_tags(old_response.get('tags')) |
| 2465 |
if update_tags: |
| 2466 |
self.to_do = Actions.Update |
| 2467 |
self.parameters["tags"] = new_tags |
| 2468 |
|
| 2469 |
self.parameters.update({"identity": identity}) |
| 2470 |
|
| 2471 |
if (self.to_do == Actions.Create) or (self.to_do == Actions.Update): |
| 2472 |
self.log("Need to Create / Update the Application Gateway instance") |
| 2473 |
|
| 2474 |
if self.check_mode: |
| 2475 |
self.results['changed'] = True |
| 2476 |
self.results["parameters"] = self.parameters |
| 2477 |
return self.results |
| 2478 |
|
| 2479 |
response = self.create_update_applicationgateway() |
| 2480 |
|
| 2481 |
properties = self.get_resource() or {} |
| 2482 |
new_ssl_certs = [] |
| 2483 |
if properties: |
| 2484 |
for new_cert in properties.get('properties', {}).get('sslCertificates', []): |
| 2485 |
new_public_cert = new_cert.get('properties', {}).get('publicCertData') |
| 2486 |
new_ssl_certs.append(new_public_cert) |
| 2487 |
|
| 2488 |
if not old_response: |
| 2489 |
self.results['changed'] = True |
| 2490 |
else: |
| 2491 |
self.results['changed'] = not compare_dicts(old_response, response) or \ |
| 2492 |
old_ssl_certs.__ne__(new_ssl_certs) |
| 2493 |
self.log("Creation / Update done") |
| 2494 |
elif (self.to_do == Actions.Start) or (self.to_do == Actions.Stop): |
| 2495 |
self.log("Need to Start / Stop the Application Gateway instance") |
| 2496 |
self.results['changed'] = True |
| 2497 |
response = old_response |
| 2498 |
|
| 2499 |
if self.check_mode: |
| 2500 |
return self.results |
| 2501 |
elif self.to_do == Actions.Start: |
| 2502 |
self.start_applicationgateway() |
| 2503 |
response["operational_state"] = "Running" |
| 2504 |
else: |
| 2505 |
self.stop_applicationgateway() |
| 2506 |
response["operational_state"] = "Stopped" |
| 2507 |
|
| 2508 |
elif self.to_do == Actions.Delete: |
| 2509 |
self.log("Application Gateway instance deleted") |
| 2510 |
self.results['changed'] = True |
| 2511 |
|
| 2512 |
if self.check_mode: |
| 2513 |
return self.results |
| 2514 |
|
| 2515 |
self.delete_applicationgateway() |
| 2516 |
|
| 2517 |
|
| 2518 |
while self.get_applicationgateway(): |
| 2519 |
time.sleep(20) |
| 2520 |
else: |
| 2521 |
self.log("Application Gateway instance unchanged") |
| 2522 |
self.results['changed'] = False |
| 2523 |
response = old_response |
| 2524 |
|
| 2525 |
if response: |
| 2526 |
self.results.update(self.format_response(response)) |
| 2527 |
|
| 2528 |
return self.results |
| 2529 |
|
| 2530 |
def create_update_applicationgateway(self): |
| 2531 |
''' |
| 2532 |
Creates or updates Application Gateway with the specified configuration. |
| 2533 |
|
| 2534 |
:return: deserialized Application Gateway instance state dictionary |
| 2535 |
''' |
| 2536 |
self.log("Creating / Updating the Application Gateway instance {0}".format(self.name)) |
| 2537 |
|
| 2538 |
try: |
| 2539 |
response = self.network_client.application_gateways.begin_create_or_update(resource_group_name=self.resource_group, |
| 2540 |
application_gateway_name=self.name, |
| 2541 |
parameters=self.parameters) |
| 2542 |
if isinstance(response, LROPoller): |
| 2543 |
response = self.get_poller_result(response) |
| 2544 |
|
| 2545 |
except Exception as exc: |
| 2546 |
self.log('Error attempting to create the Application Gateway instance.') |
| 2547 |
self.fail("Error creating the Application Gateway instance: {0}".format(str(exc))) |
| 2548 |
return response.as_dict() |
| 2549 |
|
| 2550 |
def delete_applicationgateway(self): |
| 2551 |
''' |
| 2552 |
Deletes specified Application Gateway instance in the specified subscription and resource group. |
| 2553 |
|
| 2554 |
:return: True |
| 2555 |
''' |
| 2556 |
self.log("Deleting the Application Gateway instance {0}".format(self.name)) |
| 2557 |
try: |
| 2558 |
response = self.network_client.application_gateways.begin_delete(resource_group_name=self.resource_group, |
| 2559 |
application_gateway_name=self.name) |
| 2560 |
except Exception as e: |
| 2561 |
self.log('Error attempting to delete the Application Gateway instance.') |
| 2562 |
self.fail("Error deleting the Application Gateway instance: {0}".format(str(e))) |
| 2563 |
|
| 2564 |
return True |
| 2565 |
|
| 2566 |
def get_applicationgateway(self): |
| 2567 |
''' |
| 2568 |
Gets the properties of the specified Application Gateway. |
| 2569 |
|
| 2570 |
:return: deserialized Application Gateway instance state dictionary |
| 2571 |
''' |
| 2572 |
self.log("Checking if the Application Gateway instance {0} is present".format(self.name)) |
| 2573 |
found = False |
| 2574 |
try: |
| 2575 |
response = self.network_client.application_gateways.get(resource_group_name=self.resource_group, |
| 2576 |
application_gateway_name=self.name) |
| 2577 |
found = True |
| 2578 |
self.log("Response : {0}".format(response)) |
| 2579 |
self.log("Application Gateway instance : {0} found".format(response.name)) |
| 2580 |
except ResourceNotFoundError as e: |
| 2581 |
self.log('Did not find the Application Gateway instance.') |
| 2582 |
if found is True: |
| 2583 |
return response.as_dict() |
| 2584 |
|
| 2585 |
return False |
| 2586 |
|
| 2587 |
def start_applicationgateway(self): |
| 2588 |
self.log("Starting the Application Gateway instance {0}".format(self.name)) |
| 2589 |
try: |
| 2590 |
response = self.network_client.application_gateways.begin_start(resource_group_name=self.resource_group, |
| 2591 |
application_gateway_name=self.name) |
| 2592 |
if isinstance(response, LROPoller): |
| 2593 |
self.get_poller_result(response) |
| 2594 |
except Exception as e: |
| 2595 |
self.log('Error attempting to start the Application Gateway instance.') |
| 2596 |
self.fail("Error starting the Application Gateway instance: {0}".format(str(e))) |
| 2597 |
|
| 2598 |
def stop_applicationgateway(self): |
| 2599 |
self.log("Stopping the Application Gateway instance {0}".format(self.name)) |
| 2600 |
try: |
| 2601 |
response = self.network_client.application_gateways.begin_stop(resource_group_name=self.resource_group, |
| 2602 |
application_gateway_name=self.name) |
| 2603 |
if isinstance(response, LROPoller): |
| 2604 |
self.get_poller_result(response) |
| 2605 |
except Exception as e: |
| 2606 |
self.log('Error attempting to stop the Application Gateway instance.') |
| 2607 |
self.fail("Error stopping the Application Gateway instance: {0}".format(str(e))) |
| 2608 |
|
| 2609 |
def format_response(self, appgw_dict): |
| 2610 |
id = appgw_dict.get("id") |
| 2611 |
id_dict = parse_resource_id(id) |
| 2612 |
d = { |
| 2613 |
"id": id, |
| 2614 |
"name": appgw_dict.get("name"), |
| 2615 |
"resource_group": id_dict.get('resource_group', self.resource_group), |
| 2616 |
"location": appgw_dict.get("location"), |
| 2617 |
"operational_state": appgw_dict.get("operational_state"), |
| 2618 |
"provisioning_state": appgw_dict.get("provisioning_state"), |
| 2619 |
} |
| 2620 |
return d |
| 2621 |
|
| 2622 |
def get_resource(self): |
| 2623 |
|
| 2624 |
url = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/' \ |
| 2625 |
'applicationGateways/{2}'.format(self.subscription_id, self.resource_group, self.name) |
| 2626 |
|
| 2627 |
query_parameters = {} |
| 2628 |
query_parameters['api-version'] = '2022-05-01' |
| 2629 |
header_parameters = {} |
| 2630 |
header_parameters['Content-Type'] = 'application/json; charset=utf-8' |
| 2631 |
status_code = [200, 201, 202] |
| 2632 |
|
| 2633 |
found = False |
| 2634 |
try: |
| 2635 |
response = self.mgmt_client.query(url, |
| 2636 |
'GET', |
| 2637 |
query_parameters, |
| 2638 |
header_parameters, |
| 2639 |
None, |
| 2640 |
status_code, |
| 2641 |
600, |
| 2642 |
30) |
| 2643 |
response = json.loads(response.body()) |
| 2644 |
found = True |
| 2645 |
self.log("Response : {0}".format(response)) |
| 2646 |
except Exception as e: |
| 2647 |
self.log('Did not find the AppGateway instance.') |
| 2648 |
if found is True: |
| 2649 |
return response |
| 2650 |
|
| 2651 |
return False |
| 2652 |
|
| 2653 |
def set_web_application_firewall_configuration(self, kwargs): |
| 2654 |
waf_config = dict(kwargs['web_application_firewall_configuration']) |
| 2655 |
if waf_config is None: |
| 2656 |
return |
| 2657 |
|
| 2658 |
if 'firewall_policy' in waf_config and waf_config['firewall_policy'] is not None: |
| 2659 |
if 'name' in waf_config['firewall_policy'] and waf_config['firewall_policy']['name'] is not None: |
| 2660 |
waf_config['firewall_policy']['id'] = waf_policy_id(self.subscription_id, |
| 2661 |
kwargs['resource_group'], |
| 2662 |
waf_config['firewall_policy']['name']) |
| 2663 |
del waf_config['firewall_policy']['name'] |
| 2664 |
|
| 2665 |
self.parameters['force_firewall_policy_association'] = waf_config['firewall_policy']['force_association'] |
| 2666 |
del waf_config['firewall_policy']['force_association'] |
| 2667 |
self.parameters['firewall_policy'] = waf_config['firewall_policy'] |
| 2668 |
else: |
| 2669 |
self.module.deprecate("The WAF configuration can no longer be added to an application gateway." + |
| 2670 |
"Please use a WAF policy via 'firewall_policy' instead.", |
| 2671 |
version='4.0.0', |
| 2672 |
collection_name='azure.azcollection') |
| 2673 |
|
| 2674 |
|
| 2675 |
def public_ip_id(subscription_id, resource_group_name, name): |
| 2676 |
"""Generate the id for a frontend ip configuration""" |
| 2677 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/publicIPAddresses/{2}'.format( |
| 2678 |
subscription_id, |
| 2679 |
resource_group_name, |
| 2680 |
name |
| 2681 |
) |
| 2682 |
|
| 2683 |
|
| 2684 |
def frontend_ip_configuration_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2685 |
"""Generate the id for a frontend ip configuration""" |
| 2686 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/frontendIPConfigurations/{3}'.format( |
| 2687 |
subscription_id, |
| 2688 |
resource_group_name, |
| 2689 |
appgateway_name, |
| 2690 |
name |
| 2691 |
) |
| 2692 |
|
| 2693 |
|
| 2694 |
def frontend_port_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2695 |
"""Generate the id for a frontend port""" |
| 2696 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/frontendPorts/{3}'.format( |
| 2697 |
subscription_id, |
| 2698 |
resource_group_name, |
| 2699 |
appgateway_name, |
| 2700 |
name |
| 2701 |
) |
| 2702 |
|
| 2703 |
|
| 2704 |
def redirect_configuration_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2705 |
"""Generate the id for a redirect configuration""" |
| 2706 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/redirectConfigurations/{3}'.format( |
| 2707 |
subscription_id, |
| 2708 |
resource_group_name, |
| 2709 |
appgateway_name, |
| 2710 |
name |
| 2711 |
) |
| 2712 |
|
| 2713 |
|
| 2714 |
def ssl_certificate_id(subscription_id, resource_group_name, ssl_certificate_name, name): |
| 2715 |
"""Generate the id for a frontend port""" |
| 2716 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/sslCertificates/{3}'.format( |
| 2717 |
subscription_id, |
| 2718 |
resource_group_name, |
| 2719 |
ssl_certificate_name, |
| 2720 |
name |
| 2721 |
) |
| 2722 |
|
| 2723 |
|
| 2724 |
def backend_address_pool_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2725 |
"""Generate the id for an address pool""" |
| 2726 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/backendAddressPools/{3}'.format( |
| 2727 |
subscription_id, |
| 2728 |
resource_group_name, |
| 2729 |
appgateway_name, |
| 2730 |
name |
| 2731 |
) |
| 2732 |
|
| 2733 |
|
| 2734 |
def probe_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2735 |
"""Generate the id for a probe""" |
| 2736 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/probes/{3}'.format( |
| 2737 |
subscription_id, |
| 2738 |
resource_group_name, |
| 2739 |
appgateway_name, |
| 2740 |
name |
| 2741 |
) |
| 2742 |
|
| 2743 |
|
| 2744 |
def backend_http_settings_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2745 |
"""Generate the id for a http settings""" |
| 2746 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/backendHttpSettingsCollection/{3}'.format( |
| 2747 |
subscription_id, |
| 2748 |
resource_group_name, |
| 2749 |
appgateway_name, |
| 2750 |
name |
| 2751 |
) |
| 2752 |
|
| 2753 |
|
| 2754 |
def http_listener_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2755 |
"""Generate the id for a http listener""" |
| 2756 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/httpListeners/{3}'.format( |
| 2757 |
subscription_id, |
| 2758 |
resource_group_name, |
| 2759 |
appgateway_name, |
| 2760 |
name |
| 2761 |
) |
| 2762 |
|
| 2763 |
|
| 2764 |
def url_path_map_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2765 |
"""Generate the id for a url path map""" |
| 2766 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/urlPathMaps/{3}'.format( |
| 2767 |
subscription_id, |
| 2768 |
resource_group_name, |
| 2769 |
appgateway_name, |
| 2770 |
name |
| 2771 |
) |
| 2772 |
|
| 2773 |
|
| 2774 |
def url_path_rule_id(subscription_id, resource_group_name, appgateway_name, url_path_map_name, name): |
| 2775 |
"""Generate the id for a url path map""" |
| 2776 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/urlPathMaps/{3}/pathRules/{4}'.format( |
| 2777 |
subscription_id, |
| 2778 |
resource_group_name, |
| 2779 |
appgateway_name, |
| 2780 |
url_path_map_name, |
| 2781 |
name |
| 2782 |
) |
| 2783 |
|
| 2784 |
|
| 2785 |
def subnet_id(subscription_id, resource_group_name, virtual_network_name, name): |
| 2786 |
"""Generate the id for a subnet in a virtual network""" |
| 2787 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/virtualNetworks/{2}/subnets/{3}'.format( |
| 2788 |
subscription_id, |
| 2789 |
resource_group_name, |
| 2790 |
virtual_network_name, |
| 2791 |
name |
| 2792 |
) |
| 2793 |
|
| 2794 |
|
| 2795 |
def ip_configuration_id(subscription_id, resource_group_name, network_interface_name, name): |
| 2796 |
"""Generate the id for a request routing rule in an application gateway""" |
| 2797 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/networkInterfaces/{2}/ipConfigurations/{3}'.format( |
| 2798 |
subscription_id, |
| 2799 |
resource_group_name, |
| 2800 |
network_interface_name, |
| 2801 |
name |
| 2802 |
) |
| 2803 |
|
| 2804 |
|
| 2805 |
def request_routing_rule_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2806 |
"""Generate the id for a request routing rule in an application gateway""" |
| 2807 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/requestRoutingRules/{3}'.format( |
| 2808 |
subscription_id, |
| 2809 |
resource_group_name, |
| 2810 |
appgateway_name, |
| 2811 |
name |
| 2812 |
) |
| 2813 |
|
| 2814 |
|
| 2815 |
def rewrite_rule_set_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2816 |
"""Generate the id for a rewrite rule set in an application gateway""" |
| 2817 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/rewriteRuleSets/{3}'.format( |
| 2818 |
subscription_id, |
| 2819 |
resource_group_name, |
| 2820 |
appgateway_name, |
| 2821 |
name |
| 2822 |
) |
| 2823 |
|
| 2824 |
|
| 2825 |
def trusted_root_certificate_id(subscription_id, resource_group_name, appgateway_name, name): |
| 2826 |
"""Generate the id for a trusted root certificate in an application gateway""" |
| 2827 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/trustedRootCertificates/{3}'.format( |
| 2828 |
subscription_id, |
| 2829 |
resource_group_name, |
| 2830 |
appgateway_name, |
| 2831 |
name |
| 2832 |
) |
| 2833 |
|
| 2834 |
|
| 2835 |
def waf_policy_id(subscription_id, resource_group_name, policy_name): |
| 2836 |
"""Generate the id for a web application firewall policy""" |
| 2837 |
return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/{2}'.format( |
| 2838 |
subscription_id, |
| 2839 |
resource_group_name, |
| 2840 |
policy_name, |
| 2841 |
) |
| 2842 |
|
| 2843 |
|
| 2844 |
def compare_dicts(old_response, new_response): |
| 2845 |
"""Compare two dictionaries using recursive_diff method and assuming that null values coming from yaml input |
| 2846 |
are acting like absent values""" |
| 2847 |
|
| 2848 |
oldd = array_to_dict([old_response]) |
| 2849 |
newd = array_to_dict([new_response]) |
| 2850 |
diffs = recursive_diff(oldd, newd, skip_keys=['etag']) |
| 2851 |
if diffs is None: |
| 2852 |
return True |
| 2853 |
else: |
| 2854 |
actual_diffs = diffs[1] |
| 2855 |
return all(value is None or not value for value in actual_diffs.values()) |
| 2856 |
|
| 2857 |
|
| 2858 |
def array_to_dict(array): |
| 2859 |
'''Converts list object to dictionary object, including any nested properties on elements.''' |
| 2860 |
new = {} |
| 2861 |
for index, item in enumerate(array): |
| 2862 |
new[index] = deepcopy(item) |
| 2863 |
if isinstance(item, dict): |
| 2864 |
for nested in item: |
| 2865 |
if isinstance(item[nested], list): |
| 2866 |
new[index][nested] = array_to_dict(item[nested]) |
| 2867 |
return new |
| 2868 |
|
| 2869 |
|
| 2870 |
def recursive_diff(dict1, dict2, skip_keys=None): |
| 2871 |
"""Recursively diff two dictionaries |
| 2872 |
|
| 2873 |
Raises ``TypeError`` for incorrect argument type. |
| 2874 |
|
| 2875 |
:arg dict1: Dictionary to compare against. |
| 2876 |
:arg dict2: Dictionary to compare with ``dict1``. |
| 2877 |
:arg skip_keys: Array of keys to ignore in compare. |
| 2878 |
:return: Tuple of dictionaries of differences or ``None`` if there are no differences. |
| 2879 |
""" |
| 2880 |
|
| 2881 |
skip_keys = skip_keys or [] |
| 2882 |
|
| 2883 |
if not all((isinstance(item, MutableMapping) for item in (dict1, dict2))): |
| 2884 |
raise TypeError("Unable to diff 'dict1' %s and 'dict2' %s. " |
| 2885 |
"Both must be a dictionary." % (type(dict1), type(dict2))) |
| 2886 |
|
| 2887 |
left = dict((k, v) for (k, v) in dict1.items() if k not in dict2 and k not in skip_keys) |
| 2888 |
right = dict((k, v) for (k, v) in dict2.items() if k not in dict1 and k not in skip_keys) |
| 2889 |
for k in (set(dict1.keys()) & set(dict2.keys())): |
| 2890 |
if k in skip_keys: |
| 2891 |
continue |
| 2892 |
if isinstance(dict1[k], dict) and isinstance(dict2[k], dict): |
| 2893 |
result = recursive_diff(dict1[k], dict2[k], skip_keys=skip_keys) |
| 2894 |
if result: |
| 2895 |
left[k] = result[0] |
| 2896 |
right[k] = result[1] |
| 2897 |
elif dict1[k] != dict2[k]: |
| 2898 |
left[k] = dict1[k] |
| 2899 |
right[k] = dict2[k] |
| 2900 |
if left or right: |
| 2901 |
return left, right |
| 2902 |
return None |
| 2903 |
|
| 2904 |
|
| 2905 |
def main(): |
| 2906 |
"""Main execution""" |
| 2907 |
AzureRMApplicationGateways() |
| 2908 |
|
| 2909 |
|
| 2910 |
if __name__ == '__main__': |
| 2911 |
main() |