0

This is my debug output ..

register: create
    - debug: 
        msg: "{{ create.json.info.0.value }}"
ok: [localhost] => {
    "msg": "8308a020-5c9d-4936-8f1a-40f408d3a085"
}

Now I need to add the output as an input to JSON template. Below is my template...

{
"networkDomainId": "{{create.json.info.0.value}}"
"name": "Sandy_Smoke_VLAN",
"description": "For hosting our Smokeping_test Cloud Servers"
"privateIpv4NetworkAddress": "10.10.0.0"
"privateIpv4PrefixSize": 24
"attachedVlan": { "gatewayAddressing": "HIGH" }
}

But the above template is not working.

Eduardo Baitello
  • 267
  • 1
  • 14
Sandeep C H
  • 11
  • 1
  • 2

1 Answers1

1

An example is below. The play

- hosts: localhost                                                                           
  vars:                                                                                      
    create:                                                                                  
      json:                                                                                  
        info:                                                                                
          - {key: 'key_1', value: '8308a020-5c9d-4936-8f1a-40f408d3a085'}                    
  tasks:                                                                                     
    - debug:                                                                                 
        msg: "{{ create.json.info.0.value }}"                                                
    - template:                                                                              
        src: test.j2                                                                         
        dest: /scratch/tmp/test

with the template test.j2

> cat test.j2 
{
"networkDomainId": "{{create.json.info.0.value}}"
}

gives

PLAY [localhost] 
TASK [debug] 
ok: [localhost] => {
"msg": "8308a020-5c9d-4936-8f1a-40f408d3a085"
}
TASK [template]
changed: [localhost]
PLAY RECAP 
localhost                  : ok=2    changed=1    unreachable=0    failed=0

> cat /scratch/tmp/test 
{
"networkDomainId": "8308a020-5c9d-4936-8f1a-40f408d3a085"
}
Vladimir Botka
  • 3,791
  • 6
  • 17