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.

1
  • 1
    If the example below does not work for you post the error. – Vladimir Botka Apr 26 '19 at 9:24
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"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.