Hi there,

I simply cannot figure out how to create a string from a list.

What output I want in a variable: 

"{{10.0.0.1:8080,10.0.0.2:8080}}"

I am retrieving a dynamic list of private IPs from Azure Scaleset.

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

Output so far:
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"
}

I need to create a loop that puts the list into a string.
  - set_fact: 
      foo: "{{ item }}:8080"
    with_items: "{{ ip_list }}"

Does anybody know how to do this? 


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0ee4aeb0-e36c-4a4a-8c25-91a6092e237f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to