azure_rm_appgateway
Manage Application Gateway instance
Collection: azure.azcollection
Full Name: azure.azcollection.azure_rm_appgateway
Synopsis
Manage Application Gateway instance
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| ad_user | string | Active Directory username. Use when authenticating with an Active Directory user rather than service principal. | ||
| adfs_authority_url | string | Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. | ||
| api_profile | string | latest | Selects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; future values will allow use with Azure Stack. | |
| append_tags | bool | true | Use to control if tags field is canonical or just appends to existing tags. | |
| When canonical, any tags not found in the tags parameter will be removed from the object’s metadata. | ||||
| auth_source | string | auto | Controls the source of the credentials to use for authentication. | |
| Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable. | ||||
| When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli). | ||||
| When set to C(env), the credentials will be read from the environment variables. | ||||
| When set to C(credential_file), it will read the profile from C(~/.azure/credentials). | ||||
| When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default az cli subscription is used. | ||||
| When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen. | ||||
| The C(msi) was added in Ansible 2.6. | ||||
| authentication_certificates | list | Authentication certificates of the application gateway resource. | ||
| autoscale_configuration | dict | Autoscale configuration of the application gateway resource. | ||
| backend_address_pools | list | List of backend address pool of the application gateway resource. | ||
| backend_http_settings_collection | list | Backend http settings of the application gateway resource. | ||
| cert_validation_mode | string | Controls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable. | ||
| client_id | string | Azure client ID. Use when authenticating with a Service Principal or Managed Identity (msi). | ||
| Can also be set via the C(AZURE_CLIENT_ID) environment variable. | ||||
| cloud_environment | string | AzureCloud | For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable. | |
| disable_instance_discovery | bool | false | Determines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to True, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy. | |
| Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable. | ||||
| enable_http2 | bool | false | Whether HTTP2 is enabled on the application gateway resource. | |
| frontend_ip_configurations | list | Frontend IP addresses of the application gateway resource. | ||
| frontend_ports | list | List of frontend ports of the application gateway resource. | ||
| gateway_ip_configurations | list | List of subnets used by the application gateway. | ||
| gateway_state | string | Start or Stop the application gateway. When specified, no updates will occur to the gateway. | ||
| http_listeners | list | List of HTTP listeners of the application gateway resource. | ||
| identity | dict | Identity for the Object | ||
| location | string | Resource location. If not set, location from the resource group will be used as default. | ||
| log_mode | string | Parent argument. | ||
| log_path | string | Parent argument. | ||
| name | string | yes | The name of the application gateway. | |
| oidc_token | string | Direct OpenID Connect (OIDC) token (JWT) used for workload identity authentication. | ||
| This token is exchanged with Azure AD using OIDC federated identity. | ||||
| Useful in CI systems (for example GitHub Actions, Azure DevOps) where an OIDC token is provided directly by the platform. | ||||
| Can also be set via the C(AZURE_FEDERATED_TOKEN) environment variable. | ||||
| oidc_token_file_path | string | Path to a file containing an OpenID Connect (OIDC) token (JWT) used for workload identity authentication. | ||
| The file must contain only raw token. | ||||
| This method is commonly used in platforms that materialize OIDC tokens as files | ||||
| Can also be set via the C(AZURE_FEDERATED_TOKEN_FILE) environment variable. | ||||
| password | string | Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. | ||
| probes | list | Probes available to the application gateway resource. | ||
| profile | string | Security profile found in ~/.azure/credentials file. | ||
| redirect_configurations | list | Redirect configurations of the application gateway resource. | ||
| request_routing_rules | list | List of request routing rules of the application gateway resource. | ||
| resource_group | string | yes | The name of the resource group. | |
| rewrite_rule_sets | list | List of rewrite configurations for the application gateway resource. | ||
| secret | string | Azure client secret. Use when authenticating with a Service Principal. | ||
| sku | dict | SKU of the application gateway resource. | ||
| ssl_certificates | list | SSL certificates of the application gateway resource. | ||
| ssl_policy | dict | SSL policy of the application gateway resource. | ||
| state | string | present | Assert the state of the application gateway. Use C(present) to create or update and C(absent) to delete. | |
| subscription_id | string | Your Azure subscription Id. | ||
| tags | dict | Dictionary of string:string pairs to assign as metadata to the object. | ||
| Metadata tags on the object will be updated with any provided values. | ||||
| To remove tags set append_tags option to false. | ||||
| Currently, Azure DNS zones and Traffic Manager services also don’t allow the use of spaces in the tag. | ||||
| Azure Front Door doesn’t support the use of | ||||
| Azure Automation and Azure CDN only support 15 tags on resources. | ||||
| tenant | string | Azure tenant ID. Use when authenticating with a Service Principal. | ||
| thumbprint | string | The thumbprint of the private key specified in I(x509_certificate_path). | ||
| Use when authenticating with a Service Principal. | ||||
| Required if I(x509_certificate_path) is defined. | ||||
| trusted_root_certificates | list | Trusted Root certificates of the application gateway resource. | ||
| url_path_maps | list | List of URL path maps of the application gateway resource. | ||
| web_application_firewall_configuration | dict | Web application firewall configuration of the application gateway resource. | ||
| Note that as of version 2.8.0, I(firewall_policy) is required instead of deprecated options. See https://github.com/ansible-collections/azure/pull/1697. | ||||
| x509_certificate_path | string | Path to the X509 certificate used to create the service principal in PEM format. | ||
| The certificate must be appended to the private key. | ||||
| Use when authenticating with a Service Principal. |
Example
yaml
- name: Create instance of Application Gateway
azure.azcollection.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.azcollection.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"
ssl_certificates:
- name: "ssl_cert"
key_vault_secret_id: "https://kv/secrets/ssl-cert"
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.azcollection.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.azcollection.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.azcollection.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.azcollection.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.azcollection.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.azcollection.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.azcollection.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.azcollection.azure_rm_appgateway:
resource_group: myResourceGroup
name: myAppGateway
gateway_state: stopped
- name: Start an Application Gateway instance
azure.azcollection.azure_rm_appgateway:
resource_group: myResourceGroup
name: myAppGateway
gateway_state: started