I am struggling with what I believe is the simplest of tasks. I want to take a variable v and turn that into a dictionary where
v: ValueofV
The end goal is to write that dictionary to a JSON file that contains a list of variables, with key: value where key name is always a variable name, so for variables a, b, c, ... I should end up with:
{
"a": "a_val",
"b": "v_val",
"c": "c_val"
}
I've tried building lists with_items, e.g.
- name: Var3
set_fact:
node_state4: "{{ node_state4 | default({}) | combine({ item : item })}}"
with_items:
- requested_node_count
- added_node_count
But, that makes the value the string name. If I make the second item {{ item }} it fails.