Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

How to set target VM for an Azure loadbalancer inbound NAT rule with Ansible-azure?

I need to create an inbound nat rule on my loadbalancer to redirect a certain port to a virtual machine. I've created my loadbalancer like so. I'm on Ansible 2.9.6.

- name: Create loadbalancers
  azure_rm_loadbalancer:
    resource_group: "{{ item.lb_resource_group }}"
    name: "{{ item.lb_name }}"
    frontend_ip_configurations: "{{ item.lb_frontend_ip_configurations }}"
    backend_address_pools: "{{ item.lb_backend_address_pools }}"
    probes: "{{ item.lb_probes }}"
    load_balancing_rules: "{{ item.lb_load_balancing_rules }}"
    inbound_nat_rules: "{{ item.lb_inbound_nat_rules }}"
  with_items:
    - "{{ lbs }}"
    tags:
      - lb

The inbound nat-rule looks like this.

- name: "nat-rule-in"
  backend_port: 821
  protocol: Tcp
  frontend_port: 380
  frontend_ip_configuration: "lb-frontend"

I've looked in this documentation and can not find anything that says something about this. Is it not possible to set a target VM for an inbound nat-rule using Ansible or do I need to do it somewhere else?

I've also searched the VM documentation for Ansible-azure but can't find anything related to NAT rules there either.

question from:https://stackoverflow.com/questions/65599253/how-to-set-target-vm-for-an-azure-loadbalancer-inbound-nat-rule-with-ansible-azu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What you need to find is not the azure_rm_virtualmachine module in Ansible, it should be the azure_rm_networkinterface module. You can configure the ip_configurations property of the azure_rm_networkinterface to set the load_balancer_backend_address_pools, this property can associate the VM to the Load Balancer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...