#Hey folks I m looking into adding a load
1 messages · Page 1 of 1 (latest)
Hi Yann,
azure_rm_loadbalancer_info can only return a dictionary, you can then extract only the data you need from it, like so for example:
---
- name: Extract id value from azure_rm_loadbalancer_info
hosts: localhost
tasks:
- name: Get load balancer information
azure_rm_loadbalancer_info:
resource_group: "{{ resource_group }}"
name: "{{ load_balancer_name }}"
register: lb_info
- name: Extract id value
set_fact:
lb_id: "{{ lb_info.id }}"
- name: Print id value
debug:
var: lb_id
Thanks. So if I want to add a frontend IP, I need to make sure I parse every single parameter and put it back as is ?
mmmh I've never done that but I'm guessing yes, you can also skip putting the value in another variable and just parse the values you need from dictionary in the next task, like "{{ lb_info.id }}", "{{ lb_info.xyz }}"
got it thanks
Seems like a lot of work, especially while dealing with structures like loadbalancer.loadbalancers[0].properties.frontendIPConfigurations.properties.subnet.id
to actually build loadbalancer.frontendIPConfigurations[].subnet
agreed... but if the azure_rm_loadbalancer_info module provides more data than what azure_rm_loadbalancer expects I cant' think of another way around it
I'm a big fan (and hater) of json_query. There is a nice tutorial at https://jmespath.org/tutorial.html