我试图通过参考以下文档来提供Azure应用程序网关。https://learn.microsoft.com/en-us/azure/developer/ansible/application-gateway-configure?tabs=ansible但我使用了一个虚拟机作为后端池,而不是容器。
- name: Get info of backend server 1
azure_rm_resource_info:
api_version: '2018-04-01'
resource_group: "{{ resource_group }}"
provider: compute
resource_type: virtualmachines
resource_name: "{{ vm_1_name }}"
register: vm_1_output
- name: Create instance of Application Gateway
azure_rm_appgateway:
resource_group: "{{ resource_group }}"
name: "{{ appgw_name }}"
frontend_ip_configurations:
- public_ip_address: "publicip-{{env}}-{{appgw_name}}"
name: appGatewayFrontendIP
frontend_ports:
- port: 80
name: appGatewayFrontendPort
backend_address_pools:
- backend_addresses:
- ip_address: "{{ vm_1_output.response[0].properties.ipAddress.ip }}"
name: appGatewayBackendPool
但是我得到了以下错误。
"The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ipAddress'nnThe error appears to be in
我尝试过更改值IpAddress.ip、IpAddress.ip和private_ip_address.id,但仍然失败。任何帮助都将不胜感激。
感谢
查看Ansible中azure_rm_resource_info
模块的返回值,响应中似乎没有返回ipaddress
属性。
使用azure_rm_networkinterface_info模块获取连接到VM的网络接口的事实,以检索IP地址。然后,您应该能够使用类似于networkinterface_output.networkinterfaces[0].ip_configurations[0].private_ip_address
的表达式来访问IP
查看这篇讨论类似问题的SO帖子。