azure.azcollection.azure_rm_appgateway 模块 – 管理应用程序网关实例

注意

此模块是 azure.azcollection 集合 (版本 3.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install azure.azcollection。您需要其他要求才能使用此模块,请参阅 需求 以了解详情。

要在 playbook 中使用它,请指定: azure.azcollection.azure_rm_appgateway

azure.azcollection 0.1.2 中的新增功能

概要

  • 创建、更新和删除应用程序网关实例。

需求

执行此模块的主机需要以下需求。

  • python >= 2.7

  • 执行此模块的主机必须通过 galaxy 安装 azure.azcollection 集合

  • 集合的 requirements.txt 中列出的所有 python 包必须通过 pip 安装在执行 azure.azcollection 集合中模块的主机上

  • 完整的安装说明可在 https://galaxy.ansible.com/azure/azcollection 找到

参数

参数

注释

ad_user

字符串

Active Directory 用户名。在使用 Active Directory 用户而不是服务主体进行身份验证时使用。

adfs_authority_url

字符串

azure.azcollection 0.0.1 中新增

Azure AD 授权 URL。在使用用户名/密码进行身份验证并且拥有自己的 ADFS 授权时使用。

api_profile

字符串

azure.azcollection 0.0.1 中新增

选择在与 Azure 服务通信时要使用的 API 配置文件。对于公有云,latest 的默认值是合适的;未来的值将允许与 Azure Stack 一起使用。

默认值: "latest"

append_tags

布尔值

用于控制标签字段是规范的还是只是附加到现有标签。

如果规范,则 tags 参数中找不到的任何标签都将从对象的元数据中删除。

选项

  • false

  • true ← (默认)

auth_source

字符串

azure.azcollection 0.0.1 中新增

控制用于身份验证的凭据来源。

也可以通过 ANSIBLE_AZURE_AUTH_SOURCE 环境变量设置。

设置为 auto(默认值)时,优先级为模块参数 -> env -> credential_file -> cli

设置为 env 时,凭据将从环境变量中读取。

设置为 credential_file 时,它将从 ~/.azure/credentials 读取配置文件。

设置为 cli 时,凭据将从 Azure CLI 配置文件获取。如果存在多个,则可以使用 subscription_id 或环境变量 AZURE_SUBSCRIPTION_ID 来标识订阅 ID,否则使用默认的 az cli 订阅。

设置为 msi 时,主机必须是启用了 MSI 扩展的 Azure 资源。subscription_id 或环境变量 AZURE_SUBSCRIPTION_ID 可用于标识订阅 ID(如果资源被授予对多个订阅的访问权限),否则选择第一个订阅。

Ansible 2.6 中新增了 msi

选项

  • "auto" ← (默认)

  • "cli"

  • "credential_file"

  • "env"

  • "msi"

authentication_certificates

列表 / 元素=字典

应用程序网关资源的身份验证证书。

data

字符串

证书公钥数据 - base64 编码的 pfx。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

autoscale_configuration

字典

azure.azcollection 1.15.0 中新增

应用程序网关资源的自动缩放配置。

max_capacity

整数

应用程序网关容量的上限。

min_capacity

整数

应用程序网关容量的下限。

backend_address_pools

列表 / 元素=字典

应用程序网关资源的后端地址池列表。

backend_addresses

列表 / 元素=字典

后端地址列表。

fqdn

字符串

完全限定域名 (FQDN)。

ip_address

字符串

IP 地址。

name

字符串

在资源组内唯一的资源。此名称可用于访问资源。

backend_http_settings_collection

列表 / 元素=字典

应用程序网关资源的后端 HTTP 设置。

字符串

用于关联 cookie 的 cookie 名称。

authentication_certificates

列表 / 元素=字典

对应用程序网关身份验证证书的引用列表。

仅当启用 cookie_based_affinity 时适用,否则静默忽略。

id

字符串

资源 ID。

connection_draining

字典

azure.azcollection 1.15.0 中新增

后端 HTTP 设置资源的连接清空。

drain_timeout_in_sec

整数

连接清空激活的秒数。可接受的值为 1 秒到 3600 秒。

enabled

布尔值

是否启用连接清空。

选项

  • false

  • true

字符串

基于 Cookie 的亲缘性。

选项

  • "enabled"

  • "disabled"

host_name

字符串

要发送到后端服务器的主机标头。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

path

字符串

用作所有http请求前缀的路径。

空值表示不会添加路径前缀。默认值为 null。

pick_host_name_from_backend_address

布尔值

是否应从后端服务器的主机名中选择主机标头。默认值为 false。

选项

  • false

  • true

port

整数

后端的目标端口。

probe

any

应用程序网关的探测资源。

protocol

字符串

用于与后端通信的协议。

选项

  • "http"

  • "https"

request_timeout

整数

请求超时(秒)。

如果在 RequestTimeout 内未收到响应,应用程序网关将使请求失败。

可接受的值为 1 秒到 86400 秒。

trusted_root_certificates

列表 / 元素=任意

azure.azcollection 1.15.0 中新增

对应用程序网关受信任的根证书的引用的数组。

可以是受信任的根证书的名称或完整的资源 ID。

cert_validation_mode

字符串

azure.azcollection 0.0.1 中新增

控制 Azure 端点的证书验证行为。默认情况下,所有模块都将验证服务器证书,但在使用 HTTPS 代理或针对 Azure Stack 时,可能需要通过传递ignore来禁用此行为。也可以通过凭据文件配置文件或AZURE_CERT_VALIDATION环境变量进行设置。

选项

  • "ignore"

  • "validate"

client_id

字符串

Azure 客户端 ID。在使用服务主体或托管标识 (msi) 进行身份验证时使用。

也可以通过AZURE_CLIENT_ID环境变量进行设置。

cloud_environment

字符串

azure.azcollection 0.0.1 中新增

对于除美国公共云以外的云环境,环境名称(由 Azure Python SDK 定义,例如AzureChinaCloudAzureUSGovernment)或元数据发现端点 URL(Azure Stack 必须使用)。也可以通过凭据文件配置文件或AZURE_CLOUD_ENVIRONMENT环境变量进行设置。

默认值:"AzureCloud"

disable_instance_discovery

布尔值

azure.azcollection 2.3.0 中添加

确定在尝试进行身份验证时是否执行实例发现。将其设置为 true 将完全禁用实例发现和权限验证。此功能旨在用于无法访问元数据端点的场景,例如私有云或 Azure Stack。实例发现过程需要从https://login.microsoft.com/检索权限元数据以验证权限。将其设置为**True**,将禁用权限的验证。因此,务必确保已配置的权限主机有效且值得信赖。

通过凭据文件配置文件或AZURE_DISABLE_INSTANCE_DISCOVERY环境变量进行设置。

选项

  • false ← (默认)

  • true

enable_http2

布尔值

azure.azcollection 1.15.0 中新增

应用程序网关资源上是否启用 HTTP2。

选项

  • false ← (默认)

  • true

frontend_ip_configurations

列表 / 元素=字典

应用程序网关资源的前端 IP 地址。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

private_ip_address

字符串

网络接口 IP 配置的 PrivateIPAddress。

private_ip_allocation_method

字符串

PrivateIP 分配方法。

选项

  • "static"

  • "dynamic"

public_ip_address

any

PublicIP 资源的引用。

subnet

字典

子网资源的引用。

id

字符串

子网资源的完整 ID。如果未提供namevirtual_network_name,则需要此项。

name

字符串

子网名称。仅当也提供virtual_network_name时才使用。

virtual_network_name

字符串

虚拟网络名称。仅当也提供name时才使用。

frontend_ports

列表 / 元素=字典

应用程序网关资源的前端端口列表。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

port

字符串

前端端口。

gateway_ip_configurations

列表 / 元素=字典

应用程序网关使用的子网列表。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

subnet

字典

子网资源的引用。应用程序网关从中获取其私有地址的子网。

id

字符串

子网资源的完整 ID。如果未提供namevirtual_network_name,则需要此项。

name

字符串

子网名称。仅当也提供virtual_network_name时才使用。

virtual_network_name

字符串

虚拟网络名称。仅当也提供name时才使用。

gateway_state

字符串

启动或停止应用程序网关。指定此项后,网关将不会进行任何更新。

选项

  • "started"

  • "stopped"

http_listeners

列表 / 元素=字典

应用程序网关资源的 HTTP 侦听器列表。

frontend_ip_configuration

any

应用程序网关的前端 IP 配置资源。

frontend_port

any

应用程序网关的前端端口资源。

host_name

字符串

HTTP 侦听器的主机名。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

protocol

字符串

HTTP 侦听器的协议。

选项

  • "http"

  • "https"

require_server_name_indication

布尔值

仅当protocolhttps时才适用。为多主机启用 SNI。

选项

  • false

  • true

ssl_certificate

any

应用程序网关的 SSL 证书资源。

identity

字典

对象的标识。

type

字符串

托管标识的类型。

选项

  • "SystemAssigned"

  • "UserAssigned"

  • "SystemAssigned, UserAssigned"

  • "None" ← (默认)

user_assigned_identities

字典

用户分配的托管标识及其选项。

默认值:{}

append

布尔值

标识列表是否要追加到当前标识(true)还是替换当前标识(false)。

选项

  • false

  • true ← (默认)

id

列表 / 元素=字符串

与对象关联的用户分配的标识 ID 列表。

默认值:[]

location

字符串

资源位置。如果未设置,则将使用资源组中的位置作为默认值。

log_mode

字符串

父参数。

log_path

字符串

父参数。

name

字符串 / 必填

应用程序网关的名称。

password

字符串

Active Directory 用户密码。在使用 Active Directory 用户而不是服务主体进行身份验证时使用。

probes

列表 / 元素=字典

应用程序网关资源可用的探测。

host

字符串

要向其发送probe的主机名。

interval

整数

探测间隔(秒)。

这是两次连续探测之间的时间间隔。

可接受的值为 1 秒到 86400 秒。

match

字典

对健康探测响应进行分类的标准。

status_codes

列表 / 元素=字符串

允许的健康状态代码范围。

健康状态代码的默认范围是 200-399。

name

字符串

在应用程序网关内唯一的probe名称。

path

字符串

probe的相对路径。

有效的路径从“/”开始。

探测发送到<Protocol>://<host>:<port><path>。

pick_host_name_from_backend_http_settings

布尔值

是否应从后端 HTTP 设置的主机名中选择主机标头。默认值为 false。

选项

  • false ← (默认)

  • true

port

整数

将用于探测后端服务器的自定义端口。

有效值范围为 1 到 65535。

如果未设置,将使用 http 设置中的端口。

此属性仅对Standard_v2WAF_v2有效。

protocol

字符串

用于probe的协议。

选项

  • "http"

  • "https"

timeout

整数

探测超时(秒)。

如果在此超时期间未收到有效响应,则探测标记为失败。

可接受的值为 1 秒到 86400 秒。

unhealthy_threshold

整数

probe重试次数。

连续探测失败次数达到 UnhealthyThreshold 后,后端服务器将被标记为关闭。

可接受的值为 1 秒到 20。

profile

字符串

在 ~/.azure/credentials 文件中找到的安全配置文件。

redirect_configurations

列表 / 元素=字典

应用程序网关资源的重定向配置。

include_path

布尔值

在重定向的 url 中包含路径。

选项

  • false

  • true

include_query_string

布尔值

在重定向的 url 中包含查询字符串。

选项

  • false

  • true

name

字符串

在资源组内唯一的资源名称。

path_rules

列表 / 元素=字典

azure.azcollection 1.10.0 中添加

重定向绑定的 c(path_based_routing) 规则内的 URL 路径规则列表。

name

字符串

URL 规则的名称。

path_map_name

字符串

URL 路径映射的名称。

redirect_type

字符串

重定向类型。

选项

  • "permanent"

  • "found"

  • "see_other"

  • "temporary"

request_routing_rules

列表 / 元素=字符串

azure.azcollection 1.10.0 中添加

重定向绑定的应用程序网关内的 c(basic) 请求路由规则名称列表。

target_listener

字符串

对要将请求重定向到的侦听器的引用。

url_path_maps

列表 / 元素=字符串

azure.azcollection 1.10.0 中添加

重定向绑定的应用程序网关内的 URL 路径映射名称 (c(path_based_routing) 规则) 列表。

request_routing_rules

列表 / 元素=字典

应用程序网关资源的请求路由规则列表。

backend_address_pool

any

应用程序网关的后端地址池资源。如果rule_typepath_based_routing,则不使用。

backend_http_settings

any

应用程序网关的后端http设置资源。

http_listener

any

应用程序网关的 Http 侦听器资源。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

priority

整数 / 必填

请求路由规则的优先级。

redirect_configuration

any

应用程序网关的重定向配置资源。

rewrite_rule_set

any

azure.azcollection 1.11.0 中添加

路径映射的重写规则集。

可以是重写规则集的名称或完整的资源 ID。

rule_type

字符串

规则类型。

选项

  • "basic"

  • "path_based_routing"

url_path_map

any

应用程序网关的 URL 路径映射资源。如果rule_typepath_based_routing,则需要此项。

resource_group

字符串 / 必填

资源组的名称。

rewrite_rule_sets

列表 / 元素=字典

azure.azcollection 1.11.0 中添加

应用程序网关资源的重写配置列表。

name

字符串 / 必填

重写规则集的名称。

rewrite_rules

列表 / 元素=字典 / 必填

重写规则列表。

action_set

字典 / 必填

作为重写规则一部分要执行的操作集。

request_header_configurations

列表 / 元素=字典

要对请求标头执行的操作列表。

默认值:[]

header_name

字符串 / 必填

标头的名称。

header_value

字符串

标头的值。

保留参数未设置以删除标头。

默认值:""

response_header_configurations

列表 / 元素=字典

响应头操作列表。

默认值:[]

header_name

字符串 / 必填

标头的名称。

header_value

字符串

标头的值。

保留参数未设置以删除标头。

默认值:""

url_configuration

字典

对URL的操作。

modified_path

字符串

URL路径将被重写到的值。

保留参数未设置以保留原始URL路径。

modified_query_string

字符串

URL查询字符串将被重写到的值。

保留参数未设置以保留原始URL查询字符串。

reroute

布尔值

如果设置为true,将使用修改后的路径重新评估基于路径的请求路由规则中提供的路径映射。

选项

  • false ← (默认)

  • true

conditions

列表 / 元素=字典

基于这些条件评估操作集的执行。

默认值:[]

ignore_case

布尔值

将此值设置为true将强制模式进行不区分大小写的比较。

选项

  • false

  • true ← (默认)

negate

布尔值

将此值设置为true将强制检查用户给定条件的反义。

选项

  • false ← (默认)

  • true

pattern

字符串 / 必填

模式,可以是固定字符串或正则表达式,用于评估条件的真假。

variable

字符串 / 必填

条件的参数。

name

字符串 / 必填

重写规则的名称。

rule_sequence

整数 / 必填

规则的顺序,决定了在集合中执行的顺序。

secret

字符串

Azure客户端密钥。使用服务主体进行身份验证时使用。

sku

字典

应用网关资源的SKU。

capacity

整数

应用网关的容量(实例数量)。

name

字符串

应用网关SKU的名称。

选项

  • "standard_small"

  • "standard_medium"

  • "standard_large"

  • "standard_v2"

  • "waf_medium"

  • "waf_large"

  • "waf_v2"

tier

字符串

应用网关的层级。

选项

  • "standard"

  • "standard_v2"

  • "waf"

  • "waf_v2"

ssl_certificates

列表 / 元素=字典

应用网关资源的SSL证书。

data

字符串

Base-64编码的pfx证书。

仅适用于PUT请求。

name

字符串

在资源组内唯一的资源名称。此名称可用于访问资源。

password

字符串

data中指定的pfx文件的密码。

仅适用于PUT请求。

ssl_policy

字典

应用网关资源的SSL策略。

cipher_suites

列表 / 元素=字符串

要在指定顺序中启用到应用网关的SSL密码套件列表。

选项

  • "tls_ecdhe_rsa_with_aes_256_gcm_sha384"

  • "tls_ecdhe_rsa_with_aes_128_gcm_sha256"

  • "tls_ecdhe_rsa_with_aes_256_cbc_sha384"

  • "tls_ecdhe_rsa_with_aes_128_cbc_sha256"

  • "tls_ecdhe_rsa_with_aes_256_cbc_sha"

  • "tls_ecdhe_rsa_with_aes_128_cbc_sha"

  • "tls_dhe_rsa_with_aes_256_gcm_sha384"

  • "tls_dhe_rsa_with_aes_128_gcm_sha256"

  • "tls_dhe_rsa_with_aes_256_cbc_sha"

  • "tls_dhe_rsa_with_aes_128_cbc_sha"

  • "tls_rsa_with_aes_256_gcm_sha384"

  • "tls_rsa_with_aes_128_gcm_sha256"

  • "tls_rsa_with_aes_256_cbc_sha256"

  • "tls_rsa_with_aes_128_cbc_sha256"

  • "tls_rsa_with_aes_256_cbc_sha"

  • "tls_rsa_with_aes_128_cbc_sha"

  • "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384"

  • "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256"

  • "tls_ecdhe_ecdsa_with_aes_256_cbc_sha384"

  • "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256"

  • "tls_ecdhe_ecdsa_with_aes_256_cbc_sha"

  • "tls_ecdhe_ecdsa_with_aes_128_cbc_sha"

  • "tls_dhe_dss_with_aes_256_cbc_sha256"

  • "tls_dhe_dss_with_aes_128_cbc_sha256"

  • "tls_dhe_dss_with_aes_256_cbc_sha"

  • "tls_dhe_dss_with_aes_128_cbc_sha"

  • "tls_rsa_with_3des_ede_cbc_sha"

  • "tls_dhe_dss_with_3des_ede_cbc_sha"

disabled_ssl_protocols

列表 / 元素=字符串

要在应用网关上禁用的SSL协议列表。

选项

  • "tls_v1_0"

  • "tls_v1_1"

  • "tls_v1_2"

min_protocol_version

字符串

应用网关要支持的SSL协议的最低版本。

选项

  • "tls_v1_0"

  • "tls_v1_1"

  • "tls_v1_2"

policy_name

字符串

Ssl 预定义策略的名称。

选项

  • "ssl_policy20150501"

  • "ssl_policy20170401"

  • "ssl_policy20170401_s"

policy_type

字符串

SSL策略的类型。

选项

  • "predefined"

  • "custom"

state

字符串

声明应用网关的状态。使用present创建或更新,使用absent删除。

选项

  • "absent"

  • "present" ← (默认)

subscription_id

字符串

您的Azure订阅ID。

tags

字典

字符串:字符串对的字典,作为元数据分配给对象。

对象上的元数据标签将使用任何提供的数值进行更新。

要删除标签,请将append_tags选项设置为false。

目前,Azure DNS区域和流量管理器服务也不允许在标签中使用空格。

Azure前端门户不支持使用

Azure自动化和Azure CDN仅支持资源上的15个标签。

tenant

字符串

Azure租户ID。使用服务主体进行身份验证时使用。

thumbprint

字符串

在azure.azcollection 1.14.0中添加

x509_certificate_path中指定的私钥的指纹。

使用服务主体进行身份验证时使用。

如果定义了x509_certificate_path,则需要此项。

trusted_root_certificates

列表 / 元素=字典

azure.azcollection 1.15.0 中新增

应用网关资源的受信任根证书。

data

字符串

证书公共数据。

key_vault_secret_id

字符串

存储在KeyVault中的(base-64编码的未加密pfx)“Secret”或“Certificate”对象的密钥ID。

默认值:""

name

字符串

应用网关内唯一的受信任根证书的名称。

url_path_maps

列表 / 元素=字典

应用网关资源的URL路径映射列表。

default_backend_address_pool

字符串

应用网关的后端地址池资源,如果没有任何路径匹配则使用。

default_redirect_configuration互斥。

default_backend_http_settings

字符串

应用网关的后端HTTP设置资源;与default_backend_address_pool一起使用。

default_redirect_configuration

字符串

azure.azcollection 1.10.0 中添加

应用网关的重定向配置资源的名称,如果没有任何路径匹配则使用。

default_backend_address_pool互斥。

default_rewrite_rule_set

字符串

azure.azcollection 1.11.0 中添加

路径映射的默认重写规则集。

可以是重写规则集的名称或完整的资源 ID。

name

字符串

在应用网关内唯一的资源名称。此名称可用于访问资源。

path_rules

列表 / 元素=字典

URL路径规则列表。

backend_address_pool

字符串

如果路径匹配,则使用应用网关的后端地址池资源。

redirect_configuration互斥。

backend_http_settings

字符串

应用网关的后端HTTP设置资源;用于路径的backend_address_pool

name

字符串

在路径映射内唯一的资源名称。

paths

列表 / 元素=字符串

路径列表。

redirect_configuration

字符串

azure.azcollection 1.10.0 中添加

应用网关的重定向配置资源的名称,如果路径匹配则使用。

backend_address_pool互斥。

rewrite_rule_set

字符串

azure.azcollection 1.11.0 中添加

路径映射的重写规则集。

可以是重写规则集的名称或完整的资源 ID。

web_application_firewall_configuration

字典

azure.azcollection 1.15.0 中新增

应用网关资源的Web应用程序防火墙配置。

disabled_rule_groups

列表 / 元素=字典

禁用的规则组。

默认值:[]

rule_group_name

字符串

将被禁用的规则组的名称。

rules

列表 / 元素=整数

将被禁用的规则列表。如果为null,则将禁用规则组的所有规则。

默认值:[]

enabled

布尔值

Web应用程序防火墙是否启用。

选项

  • false

  • true

exclusions

列表 / 元素=字典

排除列表。

默认值:[]

match_variable

字符串

要排除的变量。

selector

字符串

当match_variable是集合时,用于指定此排除应用于集合中哪些元素的操作符。

selector_match_operator

字符串

当match_variable是集合时,对选择器进行操作以指定此排除应用于集合中哪些元素。

file_upload_limit_in_mb

整数

WAF的最大文件上传大小(MB)。

firewall_mode

字符串

Web应用程序防火墙模式。

选项

  • "Detection"

  • "Prevention"

max_request_body_size

整数

WAF的最大请求正文大小。

max_request_body_size_in_kb

整数

WAF的最大请求正文大小(KB)。

request_body_check

布尔值

是否允许WAF检查请求正文。

选项

  • false

  • true

rule_set_type

字符串

Web应用程序防火墙规则集的类型。

可能的值为“OWASP”。

选项

  • "OWASP"

rule_set_version

字符串

规则集类型的版本。

x509_certificate_path

path

在azure.azcollection 1.14.0中添加

用于创建PEM格式的服务主体的X509证书的路径。

证书必须附加到私钥。

使用服务主体进行身份验证时使用。

注释

注意

  • 对于使用Azure进行身份验证,您可以传递参数,设置环境变量,使用存储在~/.azure/credentials中的配置文件,或者在运行任务或剧本之前使用az login登录。

  • 也可以使用服务主体或Active Directory用户进行身份验证。

  • 要通过服务主体进行身份验证,请传递subscription_id、client_id、secret和tenant,或设置环境变量AZURE_SUBSCRIPTION_ID、AZURE_CLIENT_ID、AZURE_SECRET和AZURE_TENANT。

  • 要通过Active Directory用户进行身份验证,请传递ad_user和password,或在环境中设置AZURE_AD_USER和AZURE_PASSWORD。

  • 或者,凭据可以存储在~/.azure/credentials中。这是一个包含[default]部分和以下键的ini文件:subscription_id、client_id、secret和tenant或subscription_id、ad_user和password。也可以添加其他配置文件。通过传递profile或在环境中设置AZURE_PROFILE来指定配置文件。

另请参阅

另请参阅

使用Azure CLI登录

如何使用az login命令进行身份验证。

示例

- name: Create instance of Application Gateway
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    sku:
      name: standard_small
      tier: standard
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: sample_gateway_frontend_ip_config
    frontend_ports:
      - port: 90
        name: ag_frontend_port
    backend_address_pools:
      - backend_addresses:
          - ip_address: 10.0.0.4
        name: test_backend_address_pool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        connection_draining:
          drain_timeout_in_sec: 60
          enabled: true
        name: sample_appgateway_http_settings
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: ag_frontend_port
        name: sample_http_listener
    request_routing_rules:
      - rule_type: basic
        backend_address_pool: test_backend_address_pool
        backend_http_settings: sample_appgateway_http_settings
        http_listener: sample_http_listener
        name: rule1
        priority: 100

- name: Create instance of Application Gateway with custom trusted root certificate
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    sku:
      name: standard_small
      tier: standard
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: sample_gateway_frontend_ip_config
    frontend_ports:
      - port: 90
        name: ag_frontend_port
    trusted_root_certificates:
      - name: "root_cert"
        key_vault_secret_id: "https://kv/secret"
    backend_address_pools:
      - backend_addresses:
          - ip_address: 10.0.0.4
        name: test_backend_address_pool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        connection_draining:
          drain_timeout_in_sec: 60
          enabled: true
        name: sample_appgateway_http_settings
        trusted_root_certificates:
          - "root_cert"
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: ag_frontend_port
        name: sample_http_listener
    request_routing_rules:
      - rule_type: basic
        priority: 100
        backend_address_pool: test_backend_address_pool
        backend_http_settings: sample_appgateway_http_settings
        http_listener: sample_http_listener
        name: rule1

- name: Create instance of Application Gateway by looking up virtual network and subnet
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    sku:
      name: standard_small
      tier: standard
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          name: default
          virtual_network_name: my-vnet
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          name: default
          virtual_network_name: my-vnet
        name: sample_gateway_frontend_ip_config
    frontend_ports:
      - port: 90
        name: ag_frontend_port
    backend_address_pools:
      - backend_addresses:
          - ip_address: 10.0.0.4
        name: test_backend_address_pool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        name: sample_appgateway_http_settings
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: ag_frontend_port
        name: sample_http_listener
    request_routing_rules:
      - rule_type: basic
        priority: 100
        backend_address_pool: test_backend_address_pool
        backend_http_settings: sample_appgateway_http_settings
        http_listener: sample_http_listener
        name: rule1

- name: Create instance of Application Gateway with path based rules
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    sku:
      name: standard_small
      tier: standard
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: sample_gateway_frontend_ip_config
    frontend_ports:
      - port: 90
        name: ag_frontend_port
    backend_address_pools:
      - backend_addresses:
          - ip_address: 10.0.0.4
        name: test_backend_address_pool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        name: sample_appgateway_http_settings
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: ag_frontend_port
        name: sample_http_listener
    request_routing_rules:
      - rule_type: path_based_routing
        priority: 100
        http_listener: sample_http_listener
        name: rule1
        url_path_map: path_mappings
    url_path_maps:
      - name: path_mappings
        default_backend_address_pool: test_backend_address_pool
        default_backend_http_settings: sample_appgateway_http_settings
        path_rules:
          - name: path_rules
            backend_address_pool: test_backend_address_pool
            backend_http_settings: sample_appgateway_http_settings
            paths:
              - "/abc"
              - "/123/*"

- name: Create instance of Application Gateway with complex routing and redirect rules
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myComplexAppGateway
    sku:
      name: standard_small
      tier: standard
      capacity: 2
    ssl_policy:
      policy_type: "predefined"
      policy_name: "ssl_policy20170401_s"
    ssl_certificates:
      - name: ssl_cert
        password: "{{ password }}"
        data: "{{ lookup('file', 'certfile') }}"
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_output.state.id }}"
          name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          id: "{{ subnet_output.state.id }}"
          name: sample_gateway_frontend_ip_config
    frontend_ports:
      - name: "inbound-http"
        port: 80
      - name: "inbound-https"
        port: 443
    backend_address_pools:
      - name: test_backend_address_pool1
        backend_addresses:
          - ip_address: 10.0.0.1
      - name: test_backend_address_pool2
        backend_addresses:
          - ip_address: 10.0.0.2
    backend_http_settings_collection:
      - name: "http-profile1"
        port: 443
        protocol: https
        pick_host_name_from_backend_address: true
        probe: "http-probe1"
        cookie_based_affinity: "Disabled"
      - name: "http-profile2"
        port: 8080
        protocol: http
        pick_host_name_from_backend_address: true
        probe: "http-probe2"
        cookie_based_affinity: "Disabled"
    http_listeners:
      - name: "inbound-http"
        protocol: "http"
        frontend_ip_configuration: "sample_gateway_frontend_ip_config"
        frontend_port: "inbound-http"
      - name: "inbound-traffic1"
        protocol: "https"
        frontend_ip_configuration: "sample_gateway_frontend_ip_config"
        frontend_port: "inbound-https"
        host_name: "traffic1.example.com"
        require_server_name_indication: true
        ssl_certificate: "ssl_cert"
      - name: "inbound-traffic2"
        protocol: "https"
        frontend_ip_configuration: "sample_gateway_frontend_ip_config"
        frontend_port: "inbound-https"
        host_name: "traffic2.example.com"
        require_server_name_indication: true
        ssl_certificate: "ssl_cert"
    url_path_maps:
      - name: "path_mappings"
        default_redirect_configuration: "redirect-traffic1"
        path_rules:
          - name: "path_rules"
            backend_address_pool: "test_backend_address_pool1"
            backend_http_settings: "http-profile1"
            paths:
              - "/abc"
              - "/123/*"
    request_routing_rules:
      - name: "app-routing1"
        rule_type: "basic"
        priority: 100
        http_listener: "inbound-traffic1"
        backend_address_pool: "test_backend_address_pool2"
        backend_http_settings: "http-profile1"
      - name: "app-routing2"
        rule_type: "path_based_routing"
        priority: 101
        http_listener: "inbound-traffic2"
        url_path_map: "path_mappings"
      - name: "redirect-routing"
        rule_type: "basic"
        priority: 102
        http_listener: "inbound-http"
        redirect_configuration: "redirect-http"
    probes:
      - name: "http-probe1"
        interval: 30
        path: "/abc"
        protocol: "https"
        pick_host_name_from_backend_http_settings: true
        timeout: 30
        unhealthy_threshold: 2
      - name: "http-probe2"
        interval: 30
        path: "/xyz"
        protocol: "http"
        pick_host_name_from_backend_http_settings: true
        timeout: 30
        unhealthy_threshold: 2
    redirect_configurations:
      - name: "redirect-http"
        redirect_type: "permanent"
        target_listener: "inbound-traffic1"
        include_path: true
        include_query_string: true
        request_routing_rules:
          - "redirect-routing"
      - name: "redirect-traffic1"
        redirect_type: "found"
        target_listener: "inbound-traffic1"
        include_path: true
        include_query_string: true
        url_path_maps:
          - "path_mappings"

- name: Create v2 instance of Application Gateway with rewrite rules
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myV2AppGateway
    sku:
      name: standard_v2
      tier: standard_v2
      capacity: 2
    ssl_policy:
      policy_type: predefined
      policy_name: ssl_policy20170401_s
    ssl_certificates:
      - name: ssl_cert
        password: "{{ password }}"
        data: "{{ lookup('file', ssl_cert) }}"
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_output.state.id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - name: "public-inbound-ip"
        public_ip_address: my-appgw-pip
    frontend_ports:
      - name: "inbound-http"
        port: 80
      - name: "inbound-https"
        port: 443
    backend_address_pools:
      - name: test_backend_address_pool1
        backend_addresses:
          - ip_address: 10.0.0.1
      - name: test_backend_address_pool2
        backend_addresses:
          - ip_address: 10.0.0.2
    backend_http_settings_collection:
      - name: "http-profile1"
        port: 443
        protocol: https
        pick_host_name_from_backend_address: true
        probe: "http-probe1"
        cookie_based_affinity: "Disabled"
      - name: "http-profile2"
        port: 8080
        protocol: http
        pick_host_name_from_backend_address: true
        probe: "http-probe2"
        cookie_based_affinity: "Disabled"
    http_listeners:
      - name: "inbound-http"
        protocol: "http"
        frontend_ip_configuration: "public-inbound-ip"
        frontend_port: "inbound-http"
      - name: "inbound-traffic1"
        protocol: "https"
        frontend_ip_configuration: "public-inbound-ip"
        frontend_port: "inbound-https"
        host_name: "traffic1.example.com"
        require_server_name_indication: true
        ssl_certificate: "ssl_cert"
      - name: "inbound-traffic2"
        protocol: "https"
        frontend_ip_configuration: "public-inbound-ip"
        frontend_port: "inbound-https"
        host_name: "traffic2.example.com"
        require_server_name_indication: true
        ssl_certificate: "ssl_cert"
    url_path_maps:
      - name: "path_mappings"
        default_redirect_configuration: "redirect-traffic1"
        default_rewrite_rule_set: "configure-headers"
        path_rules:
          - name: "path_rules"
            backend_address_pool: "test_backend_address_pool1"
            backend_http_settings: "http-profile1"
            paths:
              - "/abc"
              - "/123/*"
    request_routing_rules:
      - name: "app-routing1"
        rule_type: "basic"
        priority: 100
        http_listener: "inbound-traffic1"
        backend_address_pool: "test_backend_address_pool2"
        backend_http_settings: "http-profile1"
        rewrite_rule_set: "configure-headers"
      - name: "app-routing2"
        rule_type: "path_based_routing"
        priority: 101
        http_listener: "inbound-traffic2"
        url_path_map: "path_mappings"
      - name: "redirect-routing"
        rule_type: "basic"
        priority: 102
        http_listener: "inbound-http"
        redirect_configuration: "redirect-http"
    rewrite_rule_sets:
      - name: "configure-headers"
        rewrite_rules:
          - name: "add-security-response-header"
            rule_sequence: 1
            action_set:
              response_header_configurations:
                - header_name: "Strict-Transport-Security"
                  header_value: "max-age=31536000"
          - name: "remove-backend-response-headers"
            rule_sequence: 2
            action_set:
              response_header_configurations:
                - header_name: "Server"
                - header_name: "X-Powered-By"
          - name: "set-custom-header-condition"
            rule_sequence: 3
            conditions:
              - variable: "var_client_ip"
                pattern: "1.1.1.1"
              - variable: "http_req_Authorization"
                pattern: "12345"
                ignore_case: false
            action_set:
              request_header_configurations:
                - header_name: "Foo"
                  header_value: "Bar"
    probes:
      - name: "http-probe1"
        interval: 30
        path: "/abc"
        protocol: "https"
        pick_host_name_from_backend_http_settings: true
        timeout: 30
        unhealthy_threshold: 2
      - name: "http-probe2"
        interval: 30
        path: "/xyz"
        protocol: "http"
        pick_host_name_from_backend_http_settings: true
        timeout: 30
        unhealthy_threshold: 2
    redirect_configurations:
      - name: "redirect-http"
        redirect_type: "permanent"
        target_listener: "inbound-traffic1"
        include_path: true
        include_query_string: true
        request_routing_rules:
          - "redirect-routing"
      - name: "redirect-traffic1"
        redirect_type: "found"
        target_listener: "inbound-traffic1"
        include_path: true
        include_query_string: true
        url_path_maps:
          - "path_mappings"

- name: Create instance of Application Gateway with autoscale configuration
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    sku:
      name: standard_small
      tier: standard
    autoscale_configuration:
      max_capacity: 2
      min_capacity: 1
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: sample_gateway_frontend_ip_config
    frontend_ports:
      - port: 90
        name: ag_frontend_port
    backend_address_pools:
      - backend_addresses:
          - ip_address: 10.0.0.4
        name: test_backend_address_pool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        name: sample_appgateway_http_settings
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: ag_frontend_port
        name: sample_http_listener
    request_routing_rules:
      - rule_type: basic
        priority: 100
        backend_address_pool: test_backend_address_pool
        backend_http_settings: sample_appgateway_http_settings
        http_listener: sample_http_listener
        name: rule1

- name: Create instance of Application Gateway waf_v2 with waf configuration
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    sku:
      name: waf_v2
      tier: waf_v2
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: sample_gateway_frontend_ip_config
    frontend_ports:
      - port: 90
        name: ag_frontend_port
    backend_address_pools:
      - backend_addresses:
          - ip_address: 10.0.0.4
        name: test_backend_address_pool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        name: sample_appgateway_http_settings
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: ag_frontend_port
        name: sample_http_listener
    request_routing_rules:
      - rule_type: basic
        priority: 100
        backend_address_pool: test_backend_address_pool
        backend_http_settings: sample_appgateway_http_settings
        http_listener: sample_http_listener
        name: rule1
    web_application_firewall_configuration:
      - enabled: true
        firewall_mode: Detection
        rule_set_type: OWASP
        rule_set_version: 3.0
        request_body_check: true
        max_request_body_size_in_kb: 128
        file_upload_limit_in_mb: 100

- name: Create application gateway with multi parameters
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myappgateway
    sku:
      name: standard_v2
      tier: standard_v2
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet_id }}"
        name: app_gateway_ip_config
    frontend_ip_configurations:
      - name: sample_gateway_frontend_ip_config
        public_ip_address: "pip{{ rpfx }}"
    frontend_ports:
      - port: 80
        name: http_frontend_port
    backend_address_pools:
      - name: test_backend_address_pool  # empty pool which will receive attachment to NIC.
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        name: sample_appgateway_http_settings
    http_listeners:
      - frontend_ip_configuration: sample_gateway_frontend_ip_config
        frontend_port: http_frontend_port
        protocol: http
        name: http_listener
    probes:
      - name: testprobes01
        protocol: http
        path: '/'
        timeout: 30
        host: testazure
        interval: 90
        port: 80
        match:
          status_codes:
            - 200
    request_routing_rules:
      - rule_type: basic
        priority: 100
        backend_address_pool: test_backend_address_pool
        backend_http_settings: sample_appgateway_http_settings
        http_listener: http_listener
        name: rule1

- name: Stop an Application Gateway instance
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    gateway_state: stopped

- name: Start an Application Gateway instance
  azure_rm_appgateway:
    resource_group: myResourceGroup
    name: myAppGateway
    gateway_state: started

返回值

常用的返回值已在此处记录,以下是此模块特有的字段

描述

id

字符串

应用网关资源ID。

返回:始终

示例:"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/myAppGw"

location

字符串

应用网关的位置。

返回:始终

示例:"centralus"

name

字符串

应用网关的名称。

返回:始终

示例:"myAppGw"

operational_state

字符串

应用网关的运行状态。

返回:始终

示例:"Running"

provisioning_state

字符串

应用网关的预配状态。

返回:始终

示例:"Succeeded"

resource_group

字符串

资源组的名称。

返回:始终

示例:"myResourceGroup"

作者

  • Zim Kalinowski (@zikalino)