如何使用Ansible更新Azure Application Gateway实例

问题描述

我正在尝试使用Ansible自动管理应用程序网关的某些方面。一些示例将新主机添加到后端池,增加实例数等。我在此处找到了azure_rm_appgateway_module的示例:https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_appgateway_module.html

但是,它仅具有创建应用程序网关实例的示例。有人可以指出一些如何使用Ansible更新现有应用程序网关的示例。

解决方法

以下是使用Ansible剧本管理Azure Application Gateway的快速参考示例,

- name: Create instance of Application Gateway
  azure_rm_appgateway:
    resource_group: "{{ resource_group }}"
    name: "{{ appgw_name }}"
    sku:
      name: standard_small
      tier: standard
      capacity: 2
    gateway_ip_configurations:
      - subnet:
          id: "{{ subnet.response[0].id }}"
        name: appGatewayIP
    frontend_ip_configurations:
      - public_ip_address: "{{ publicip_name }}"
        name: appGatewayFrontendIP
    frontend_ports:
      - port: 80
        name: appGatewayFrontendPort
    backend_address_pools:
      - backend_addresses:
          - ip_address: "{{ aci_1_output.response[0].properties.ipAddress.ip }}"
          - ip_address: "{{ aci_2_output.response[0].properties.ipAddress.ip }}"
        name: appGatewayBackendPool
    backend_http_settings_collection:
      - port: 80
        protocol: http
        cookie_based_affinity: enabled
        name: appGatewayBackendHttpSettings
    http_listeners:
      - frontend_ip_configuration: appGatewayFrontendIP
        frontend_port: appGatewayFrontendPort
        name: appGatewayHttpListener
    request_routing_rules:
      - rule_type: Basic
        backend_address_pool: appGatewayBackendPool
        backend_http_settings: appGatewayBackendHttpSettings
        http_listener: appGatewayHttpListener
        name: rule1

参考:Doc