"{{10.0.0.1:8080,10.0.0.2:8080}}"
tasks: - name: Connect command: az account set -s {{ subscription_id }} - name: Get private IPs command: az vmss nic list --resource-group {{ customer_group }} --vmss-name {{ customer }}-vmss register: result - name: Filter result set_fact: ip_list: "{{ result.stdout | from_json | json_query('[*].ipConfigurations[*].privateIpAddress') }}"
- set_fact: foo: "{{ item }}:8080" with_items: "{{ ip_list }}" - debug: var=foo
PLAY [localhost] ********************************************************************************************************************
TASK [set_fact] *********************************************************************************************************************ok: [localhost]
TASK [Connect] **********************************************************************************************************************changed: [localhost]
TASK [Get private IPs] **************************************************************************************************************changed: [localhost]
TASK [Filter result] ****************************************************************************************************************ok: [localhost]
TASK [set_fact] *********************************************************************************************************************ok: [localhost] => (item=10.1.1.7)ok: [localhost] => (item=10.1.1.4)ok: [localhost] => (item=10.1.1.5)
TASK [debug] ************************************************************************************************************************ok: [localhost] => { "foo": "10.1.1.5:8080"}
- set_fact: foo: "{{ item }}:8080" with_items: "{{ ip_list }}"
TASK [debug] ************************************************************************************************************************ok: [localhost] => {
"foo": "[u'10.1.1.7']:8080,[u'10.1.1.4']:8080,[u'10.1.1.5']:8080"}
TASK [debug] ********************************************************************************************************************************************************ok: [localhost] => { "ip_list": [ [ "10.1.1.7" ], [ "10.1.1.4" ], [ "10.1.1.5" ] ]}