Building up a dictionary/hash with listsfilter a list of objects with ipaddr in AnsibleUnable to do a nested loop with AnsibleNested loop with a list and a dictionaryJoining two lists of dicts based on unique key in Jinja2/Ansible using map() functionAnsible regex_findall multiple setsBuilding a list with ansibleiterate over list of dictionaries within with_nested listAnsible looping Ansible_net_interfaces isn't seeing item.key as definedIterate through a dictionary with a listLoop for ansible arraysAnsible build list dictionary with from list of strings

Do we see some Unsullied doing this in S08E05?

Usage of the relative pronoun "dont"

Search string in file, replace it, and write back to file

Cannot remove door knob -- totally inaccessible!

Why did the soldiers of the North disobey Jon?

What kind of environment would favor hermaphroditism in a sentient species over regular, old sexes?

Pedaling at different gear ratios on flat terrain: what's the point?

Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?

Why do galaxies collide?

Is it possible to pass a pointer to an operator as an argument like a pointer to a function?

Would a "ring language" be possible?

Why is so much ransomware breakable?

Why aren't satellites disintegrated even though they orbit earth within their Roche Limits?

What do astronauts do with their trash on the ISS?

Does a non-singular matrix have a large minor with disjoint rows and columns and full rank?

Can EU citizens work on Iceland?

How can I make dummy text (like lipsum) grey?

What is the conversion rate for Sorcery points to Spell Points?

When did Britain learn about American independence?

What would a Dragon have to exhale to cause rain?

Can I pay my credit card?

Why is the A380’s with-reversers stopping distance the same as its no-reversers stopping distance?

Assign the same string to multiple variables

Cycling to work - 30mile return



Building up a dictionary/hash with lists


filter a list of objects with ipaddr in AnsibleUnable to do a nested loop with AnsibleNested loop with a list and a dictionaryJoining two lists of dicts based on unique key in Jinja2/Ansible using map() functionAnsible regex_findall multiple setsBuilding a list with ansibleiterate over list of dictionaries within with_nested listAnsible looping Ansible_net_interfaces isn't seeing item.key as definedIterate through a dictionary with a listLoop for ansible arraysAnsible build list dictionary with from list of strings






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








1















I am attempting to build a dictionary but cannot grasp how jinja2 interpolates variables.



I want to set a specific item in the array (for example item[0]) to a specific key-value dictionary item.



- set_fact: 
nodes:
- node1
- node2

- set_fact:
list_one:
- f-one
- f-two

- set_fact:
list_two:
- n-one
- n-two


what I want:



- set_fact: 
**node_dict:
node1:
labels:
f-one: n-one
node2:
labels:
f-two: n-two**


When I run :



- name: check loop1
debug:
msg: 'item[0] - item[1] - item[2] '
with_nested:
- ' nodes '
- ' list_one '
- ' list_two '


item variable is availble. But doing this:



- set_fact: 
final:
'item[0]':
labels:
"item[1] " : "item[2]"
with_nested:
- ' nodes '
- ' list_one '
- ' list_two '


results in an error.



Can someone explain why? How do I end up with my desired result?










share|improve this question













migrated from serverfault.com May 5 at 7:34


This question came from our site for system and network administrators.
























    1















    I am attempting to build a dictionary but cannot grasp how jinja2 interpolates variables.



    I want to set a specific item in the array (for example item[0]) to a specific key-value dictionary item.



    - set_fact: 
    nodes:
    - node1
    - node2

    - set_fact:
    list_one:
    - f-one
    - f-two

    - set_fact:
    list_two:
    - n-one
    - n-two


    what I want:



    - set_fact: 
    **node_dict:
    node1:
    labels:
    f-one: n-one
    node2:
    labels:
    f-two: n-two**


    When I run :



    - name: check loop1
    debug:
    msg: 'item[0] - item[1] - item[2] '
    with_nested:
    - ' nodes '
    - ' list_one '
    - ' list_two '


    item variable is availble. But doing this:



    - set_fact: 
    final:
    'item[0]':
    labels:
    "item[1] " : "item[2]"
    with_nested:
    - ' nodes '
    - ' list_one '
    - ' list_two '


    results in an error.



    Can someone explain why? How do I end up with my desired result?










    share|improve this question













    migrated from serverfault.com May 5 at 7:34


    This question came from our site for system and network administrators.




















      1












      1








      1








      I am attempting to build a dictionary but cannot grasp how jinja2 interpolates variables.



      I want to set a specific item in the array (for example item[0]) to a specific key-value dictionary item.



      - set_fact: 
      nodes:
      - node1
      - node2

      - set_fact:
      list_one:
      - f-one
      - f-two

      - set_fact:
      list_two:
      - n-one
      - n-two


      what I want:



      - set_fact: 
      **node_dict:
      node1:
      labels:
      f-one: n-one
      node2:
      labels:
      f-two: n-two**


      When I run :



      - name: check loop1
      debug:
      msg: 'item[0] - item[1] - item[2] '
      with_nested:
      - ' nodes '
      - ' list_one '
      - ' list_two '


      item variable is availble. But doing this:



      - set_fact: 
      final:
      'item[0]':
      labels:
      "item[1] " : "item[2]"
      with_nested:
      - ' nodes '
      - ' list_one '
      - ' list_two '


      results in an error.



      Can someone explain why? How do I end up with my desired result?










      share|improve this question














      I am attempting to build a dictionary but cannot grasp how jinja2 interpolates variables.



      I want to set a specific item in the array (for example item[0]) to a specific key-value dictionary item.



      - set_fact: 
      nodes:
      - node1
      - node2

      - set_fact:
      list_one:
      - f-one
      - f-two

      - set_fact:
      list_two:
      - n-one
      - n-two


      what I want:



      - set_fact: 
      **node_dict:
      node1:
      labels:
      f-one: n-one
      node2:
      labels:
      f-two: n-two**


      When I run :



      - name: check loop1
      debug:
      msg: 'item[0] - item[1] - item[2] '
      with_nested:
      - ' nodes '
      - ' list_one '
      - ' list_two '


      item variable is availble. But doing this:



      - set_fact: 
      final:
      'item[0]':
      labels:
      "item[1] " : "item[2]"
      with_nested:
      - ' nodes '
      - ' list_one '
      - ' list_two '


      results in an error.



      Can someone explain why? How do I end up with my desired result?







      ansible






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 5 at 3:08









      P NotesP Notes

      133




      133




      migrated from serverfault.com May 5 at 7:34


      This question came from our site for system and network administrators.









      migrated from serverfault.com May 5 at 7:34


      This question came from our site for system and network administrators.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          1. Although your last piece of code above does not meet your requirement, It's perfectly valid: I'm not getting any error when running it.

          2. As your are using it right now, set_fact is overwriting your final variable on each loop. To append element to a dict like your are trying to do, you need to initialize the var to an empty dict and combine it with the values you are calculating for each iteration. Since your calculated values are a dict themselves, you will need to use recursive=True if you have to write expressions deep inside the dict.

          3. If I take into account your original data and your expected result, you want to relate the Nth element of each lists together. This is not what nested does (loop over nodes with a sub-loop on list_one sub-sub-loop on list_two....). In your case, you simply need to loop over an index of the length of your lists and combine the elements of same index together. My take below.

          ---
          - name: test for SO
          hosts: localhost

          vars:
          nodes:
          - node1
          - node2
          list_one:
          - f-one
          - f-two
          list_two:
          - n-one
          - n-two

          tasks:
          - name: Make my config
          set_fact:
          final: >-

          final

          loop: " length) "

          - name: debug
          debug:
          var: final


          which gives the following result



          $ ansible-playbook test.yml 

          PLAY [test for SO] ******************************************************************

          TASK [Gathering Facts] **************************************************************
          ok: [localhost]

          TASK [Make my config] ***************************************************************
          ok: [localhost] => (item=0)
          ok: [localhost] => (item=1)

          TASK [debug] ************************************************************************
          ok: [localhost] =>
          "final":
          "node1":
          "labels":
          "f-one": "n-one"

          ,
          "node2":
          "labels":
          "f-two": "n-two"





          PLAY RECAP **************************************************************************
          localhost : ok=3 changed=0 unreachable=0 failed=0


          Edit: The same result can be acheived using the zip filter (which I (re)discovered today reading an other contribution).



           - name: Make my config
          set_fact:
          final: >-
          default()

          loop: " list "





          share|improve this answer

























          • Thank you SO MUCH for providing an explanation to the solution.

            – P Notes
            May 5 at 18:12











          • Glad I could help.

            – Zeitounator
            May 5 at 18:40











          • How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

            – P Notes
            May 5 at 19:10



















          0














          An option would be to create the list of labels and then combine the dictionary. The play below



          - hosts: localhost
          vars:
          nodes:
          - node1
          - node2
          list_one:
          - f-one
          - f-two
          list_two:
          - n-one
          - n-two
          node_dict:
          my_labels: []
          tasks:
          - set_fact:
          my_labels: " my_labels + [ list_one[my_idx]:list_two[my_idx] ] "
          loop: " nodes "
          loop_control:
          index_var: my_idx
          - set_fact:
          node_dict: " combine(item:'labels':my_labels[my_idx]) "
          loop: " nodes "
          loop_control:
          index_var: my_idx
          - debug:
          var: node_dict


          gives:



          "node_dict": 
          "node1":
          "labels":
          "f-one": "n-one"

          ,
          "node2":
          "labels":
          "f-two": "n-two"








          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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%2fstackoverflow.com%2fquestions%2f55989796%2fbuilding-up-a-dictionary-hash-with-lists%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            1. Although your last piece of code above does not meet your requirement, It's perfectly valid: I'm not getting any error when running it.

            2. As your are using it right now, set_fact is overwriting your final variable on each loop. To append element to a dict like your are trying to do, you need to initialize the var to an empty dict and combine it with the values you are calculating for each iteration. Since your calculated values are a dict themselves, you will need to use recursive=True if you have to write expressions deep inside the dict.

            3. If I take into account your original data and your expected result, you want to relate the Nth element of each lists together. This is not what nested does (loop over nodes with a sub-loop on list_one sub-sub-loop on list_two....). In your case, you simply need to loop over an index of the length of your lists and combine the elements of same index together. My take below.

            ---
            - name: test for SO
            hosts: localhost

            vars:
            nodes:
            - node1
            - node2
            list_one:
            - f-one
            - f-two
            list_two:
            - n-one
            - n-two

            tasks:
            - name: Make my config
            set_fact:
            final: >-

            final

            loop: " length) "

            - name: debug
            debug:
            var: final


            which gives the following result



            $ ansible-playbook test.yml 

            PLAY [test for SO] ******************************************************************

            TASK [Gathering Facts] **************************************************************
            ok: [localhost]

            TASK [Make my config] ***************************************************************
            ok: [localhost] => (item=0)
            ok: [localhost] => (item=1)

            TASK [debug] ************************************************************************
            ok: [localhost] =>
            "final":
            "node1":
            "labels":
            "f-one": "n-one"

            ,
            "node2":
            "labels":
            "f-two": "n-two"





            PLAY RECAP **************************************************************************
            localhost : ok=3 changed=0 unreachable=0 failed=0


            Edit: The same result can be acheived using the zip filter (which I (re)discovered today reading an other contribution).



             - name: Make my config
            set_fact:
            final: >-
            default()

            loop: " list "





            share|improve this answer

























            • Thank you SO MUCH for providing an explanation to the solution.

              – P Notes
              May 5 at 18:12











            • Glad I could help.

              – Zeitounator
              May 5 at 18:40











            • How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

              – P Notes
              May 5 at 19:10
















            0














            1. Although your last piece of code above does not meet your requirement, It's perfectly valid: I'm not getting any error when running it.

            2. As your are using it right now, set_fact is overwriting your final variable on each loop. To append element to a dict like your are trying to do, you need to initialize the var to an empty dict and combine it with the values you are calculating for each iteration. Since your calculated values are a dict themselves, you will need to use recursive=True if you have to write expressions deep inside the dict.

            3. If I take into account your original data and your expected result, you want to relate the Nth element of each lists together. This is not what nested does (loop over nodes with a sub-loop on list_one sub-sub-loop on list_two....). In your case, you simply need to loop over an index of the length of your lists and combine the elements of same index together. My take below.

            ---
            - name: test for SO
            hosts: localhost

            vars:
            nodes:
            - node1
            - node2
            list_one:
            - f-one
            - f-two
            list_two:
            - n-one
            - n-two

            tasks:
            - name: Make my config
            set_fact:
            final: >-

            final

            loop: " length) "

            - name: debug
            debug:
            var: final


            which gives the following result



            $ ansible-playbook test.yml 

            PLAY [test for SO] ******************************************************************

            TASK [Gathering Facts] **************************************************************
            ok: [localhost]

            TASK [Make my config] ***************************************************************
            ok: [localhost] => (item=0)
            ok: [localhost] => (item=1)

            TASK [debug] ************************************************************************
            ok: [localhost] =>
            "final":
            "node1":
            "labels":
            "f-one": "n-one"

            ,
            "node2":
            "labels":
            "f-two": "n-two"





            PLAY RECAP **************************************************************************
            localhost : ok=3 changed=0 unreachable=0 failed=0


            Edit: The same result can be acheived using the zip filter (which I (re)discovered today reading an other contribution).



             - name: Make my config
            set_fact:
            final: >-
            default()

            loop: " list "





            share|improve this answer

























            • Thank you SO MUCH for providing an explanation to the solution.

              – P Notes
              May 5 at 18:12











            • Glad I could help.

              – Zeitounator
              May 5 at 18:40











            • How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

              – P Notes
              May 5 at 19:10














            0












            0








            0







            1. Although your last piece of code above does not meet your requirement, It's perfectly valid: I'm not getting any error when running it.

            2. As your are using it right now, set_fact is overwriting your final variable on each loop. To append element to a dict like your are trying to do, you need to initialize the var to an empty dict and combine it with the values you are calculating for each iteration. Since your calculated values are a dict themselves, you will need to use recursive=True if you have to write expressions deep inside the dict.

            3. If I take into account your original data and your expected result, you want to relate the Nth element of each lists together. This is not what nested does (loop over nodes with a sub-loop on list_one sub-sub-loop on list_two....). In your case, you simply need to loop over an index of the length of your lists and combine the elements of same index together. My take below.

            ---
            - name: test for SO
            hosts: localhost

            vars:
            nodes:
            - node1
            - node2
            list_one:
            - f-one
            - f-two
            list_two:
            - n-one
            - n-two

            tasks:
            - name: Make my config
            set_fact:
            final: >-

            final

            loop: " length) "

            - name: debug
            debug:
            var: final


            which gives the following result



            $ ansible-playbook test.yml 

            PLAY [test for SO] ******************************************************************

            TASK [Gathering Facts] **************************************************************
            ok: [localhost]

            TASK [Make my config] ***************************************************************
            ok: [localhost] => (item=0)
            ok: [localhost] => (item=1)

            TASK [debug] ************************************************************************
            ok: [localhost] =>
            "final":
            "node1":
            "labels":
            "f-one": "n-one"

            ,
            "node2":
            "labels":
            "f-two": "n-two"





            PLAY RECAP **************************************************************************
            localhost : ok=3 changed=0 unreachable=0 failed=0


            Edit: The same result can be acheived using the zip filter (which I (re)discovered today reading an other contribution).



             - name: Make my config
            set_fact:
            final: >-
            default()

            loop: " list "





            share|improve this answer















            1. Although your last piece of code above does not meet your requirement, It's perfectly valid: I'm not getting any error when running it.

            2. As your are using it right now, set_fact is overwriting your final variable on each loop. To append element to a dict like your are trying to do, you need to initialize the var to an empty dict and combine it with the values you are calculating for each iteration. Since your calculated values are a dict themselves, you will need to use recursive=True if you have to write expressions deep inside the dict.

            3. If I take into account your original data and your expected result, you want to relate the Nth element of each lists together. This is not what nested does (loop over nodes with a sub-loop on list_one sub-sub-loop on list_two....). In your case, you simply need to loop over an index of the length of your lists and combine the elements of same index together. My take below.

            ---
            - name: test for SO
            hosts: localhost

            vars:
            nodes:
            - node1
            - node2
            list_one:
            - f-one
            - f-two
            list_two:
            - n-one
            - n-two

            tasks:
            - name: Make my config
            set_fact:
            final: >-

            final

            loop: " length) "

            - name: debug
            debug:
            var: final


            which gives the following result



            $ ansible-playbook test.yml 

            PLAY [test for SO] ******************************************************************

            TASK [Gathering Facts] **************************************************************
            ok: [localhost]

            TASK [Make my config] ***************************************************************
            ok: [localhost] => (item=0)
            ok: [localhost] => (item=1)

            TASK [debug] ************************************************************************
            ok: [localhost] =>
            "final":
            "node1":
            "labels":
            "f-one": "n-one"

            ,
            "node2":
            "labels":
            "f-two": "n-two"





            PLAY RECAP **************************************************************************
            localhost : ok=3 changed=0 unreachable=0 failed=0


            Edit: The same result can be acheived using the zip filter (which I (re)discovered today reading an other contribution).



             - name: Make my config
            set_fact:
            final: >-
            default()

            loop: " list "






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 7 at 14:09

























            answered May 5 at 11:48









            ZeitounatorZeitounator

            1,1651313




            1,1651313












            • Thank you SO MUCH for providing an explanation to the solution.

              – P Notes
              May 5 at 18:12











            • Glad I could help.

              – Zeitounator
              May 5 at 18:40











            • How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

              – P Notes
              May 5 at 19:10


















            • Thank you SO MUCH for providing an explanation to the solution.

              – P Notes
              May 5 at 18:12











            • Glad I could help.

              – Zeitounator
              May 5 at 18:40











            • How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

              – P Notes
              May 5 at 19:10

















            Thank you SO MUCH for providing an explanation to the solution.

            – P Notes
            May 5 at 18:12





            Thank you SO MUCH for providing an explanation to the solution.

            – P Notes
            May 5 at 18:12













            Glad I could help.

            – Zeitounator
            May 5 at 18:40





            Glad I could help.

            – Zeitounator
            May 5 at 18:40













            How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

            – P Notes
            May 5 at 19:10






            How do I ensure that this runs only once for every nodes in a group? I am running into a situation whereby it runs twice for each node in the group thus overwriting the labels variable. ** Just thought to use run_once: true. Will test**

            – P Notes
            May 5 at 19:10














            0














            An option would be to create the list of labels and then combine the dictionary. The play below



            - hosts: localhost
            vars:
            nodes:
            - node1
            - node2
            list_one:
            - f-one
            - f-two
            list_two:
            - n-one
            - n-two
            node_dict:
            my_labels: []
            tasks:
            - set_fact:
            my_labels: " my_labels + [ list_one[my_idx]:list_two[my_idx] ] "
            loop: " nodes "
            loop_control:
            index_var: my_idx
            - set_fact:
            node_dict: " combine(item:'labels':my_labels[my_idx]) "
            loop: " nodes "
            loop_control:
            index_var: my_idx
            - debug:
            var: node_dict


            gives:



            "node_dict": 
            "node1":
            "labels":
            "f-one": "n-one"

            ,
            "node2":
            "labels":
            "f-two": "n-two"








            share|improve this answer





























              0














              An option would be to create the list of labels and then combine the dictionary. The play below



              - hosts: localhost
              vars:
              nodes:
              - node1
              - node2
              list_one:
              - f-one
              - f-two
              list_two:
              - n-one
              - n-two
              node_dict:
              my_labels: []
              tasks:
              - set_fact:
              my_labels: " my_labels + [ list_one[my_idx]:list_two[my_idx] ] "
              loop: " nodes "
              loop_control:
              index_var: my_idx
              - set_fact:
              node_dict: " combine(item:'labels':my_labels[my_idx]) "
              loop: " nodes "
              loop_control:
              index_var: my_idx
              - debug:
              var: node_dict


              gives:



              "node_dict": 
              "node1":
              "labels":
              "f-one": "n-one"

              ,
              "node2":
              "labels":
              "f-two": "n-two"








              share|improve this answer



























                0












                0








                0







                An option would be to create the list of labels and then combine the dictionary. The play below



                - hosts: localhost
                vars:
                nodes:
                - node1
                - node2
                list_one:
                - f-one
                - f-two
                list_two:
                - n-one
                - n-two
                node_dict:
                my_labels: []
                tasks:
                - set_fact:
                my_labels: " my_labels + [ list_one[my_idx]:list_two[my_idx] ] "
                loop: " nodes "
                loop_control:
                index_var: my_idx
                - set_fact:
                node_dict: " combine(item:'labels':my_labels[my_idx]) "
                loop: " nodes "
                loop_control:
                index_var: my_idx
                - debug:
                var: node_dict


                gives:



                "node_dict": 
                "node1":
                "labels":
                "f-one": "n-one"

                ,
                "node2":
                "labels":
                "f-two": "n-two"








                share|improve this answer















                An option would be to create the list of labels and then combine the dictionary. The play below



                - hosts: localhost
                vars:
                nodes:
                - node1
                - node2
                list_one:
                - f-one
                - f-two
                list_two:
                - n-one
                - n-two
                node_dict:
                my_labels: []
                tasks:
                - set_fact:
                my_labels: " my_labels + [ list_one[my_idx]:list_two[my_idx] ] "
                loop: " nodes "
                loop_control:
                index_var: my_idx
                - set_fact:
                node_dict: " combine(item:'labels':my_labels[my_idx]) "
                loop: " nodes "
                loop_control:
                index_var: my_idx
                - debug:
                var: node_dict


                gives:



                "node_dict": 
                "node1":
                "labels":
                "f-one": "n-one"

                ,
                "node2":
                "labels":
                "f-two": "n-two"









                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 5 at 9:40

























                answered May 5 at 9:30









                Vladimir BotkaVladimir Botka

                3,1782518




                3,1782518



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f55989796%2fbuilding-up-a-dictionary-hash-with-lists%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?

                    Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos