Skip to content
Advertisement

Ansible: Add values in nested dictionary among them selves and insert into another dictionary

I am iterating over the following dictionary of dictionaries and want to add the values of nested dictionary and insert them into another dictionary.

master_nodes

JavaScript

I am trying something like this and struggling to devise a solution.

JavaScript

What I am trying achieve in total_master

JavaScript

Advertisement

Answer

This could be one option:

JavaScript

gives

JavaScript

Another flavour,

JavaScript

gives

JavaScript
Advertisement