How to read ansible debug output as a variable in Json file .. example belowansible print debug msg variableI am trying to use vars_prompt but when i run the playbook it directly gives me prompt and ask for the value, it doesn't checks in inventory fileAnsible JSON OutputPrint Ansible debug output without quotes/escapesAnsible parsing a JSON outputHow to filter the content of Powershell script output?How to set tasks by variable in AnsibleAnsible how to get output as variable without brackets and uHow can I replace a template file in an Ansible role?How to debug below o/p in ansible

I drew a randomly colored grid of points with tikz, how do I force it to remember the first grid from then on?

What is the name of this hexagon/pentagon polyhedron?

Missing Piece of Pie - Can you find it?

I'm in your subnets, golfing your code

What to use instead of cling film to wrap pastry

What is the most remote airport from the center of the city it supposedly serves?

How wide is a neg symbol, how to get the width for alignment?

Would Hubble Space Telescope improve black hole image observed by EHT if it joined array of telesopes?

What matters more when it comes to book covers? Is it ‘professional quality’ or relevancy?

Why wasn't the Night King naked in S08E03?

What is the difference between 'unconcealed' and 'revealed'?

Does a card have a keyword if it has the same effect as said keyword?

Is this homebrew life-stealing melee cantrip unbalanced?

Shantae Dance Matching

How to convert a MULTIPOLYGON field stored as text to geometry data type in postGIS so that it can be plotted in QGIS

Is latino sine flexione dead?

How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?

A mathematically illogical argument in the derivation of Hamilton's equation in Goldstein

Upside-Down Pyramid Addition...REVERSED!

How can I close a gap between my fence and my neighbor's that's on his side of the property line?

Randomness of Python's random

How long would it take for people to notice a mass disappearance?

Why are prions in animal diets not destroyed by the digestive system?

Which module had more 'comfort' in terms of living space, the Lunar Module or the Command module?



How to read ansible debug output as a variable in Json file .. example below


ansible print debug msg variableI am trying to use vars_prompt but when i run the playbook it directly gives me prompt and ask for the value, it doesn't checks in inventory fileAnsible JSON OutputPrint Ansible debug output without quotes/escapesAnsible parsing a JSON outputHow to filter the content of Powershell script output?How to set tasks by variable in AnsibleAnsible how to get output as variable without brackets and uHow can I replace a template file in an Ansible role?How to debug below o/p in ansible






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








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.










share|improve this question



















  • 1





    If the example below does not work for you post the error.

    – Vladimir Botka
    Apr 26 at 9:24

















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.










share|improve this question



















  • 1





    If the example below does not work for you post the error.

    – Vladimir Botka
    Apr 26 at 9:24













0












0








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.










share|improve this question
















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.







ansible ansible-playbook ansible-galaxy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 25 at 4:03









Eduardo Baitello

17910




17910










asked Apr 24 at 4:10









Sandeep C HSandeep C H

61




61







  • 1





    If the example below does not work for you post the error.

    – Vladimir Botka
    Apr 26 at 9:24












  • 1





    If the example below does not work for you post the error.

    – Vladimir Botka
    Apr 26 at 9:24







1




1





If the example below does not work for you post the error.

– Vladimir Botka
Apr 26 at 9:24





If the example below does not work for you post the error.

– Vladimir Botka
Apr 26 at 9:24










1 Answer
1






active

oldest

votes


















0














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"






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964338%2fhow-to-read-ansible-debug-output-as-a-variable-in-json-file-example-below%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    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"






    share|improve this answer



























      0














      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"






      share|improve this answer

























        0












        0








        0







        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"






        share|improve this answer













        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"







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 26 at 9:23









        Vladimir BotkaVladimir Botka

        700212




        700212



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964338%2fhow-to-read-ansible-debug-output-as-a-variable-in-json-file-example-below%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

            What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

            Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?