I want to make a variable named as value of _id. And it seems to be working fine (tested on _id value i know), except I have no clue how to deal with it via _id field.
- name: Set fact
set_fact:
"{{_id}}": "{{ _name }}"
I want to make a variable named as value of _id. And it seems to be working fine (tested on _id value i know), except I have no clue how to deal with it via _id field.
- name: Set fact
set_fact:
"{{_id}}": "{{ _name }}"
You can do this with the set_fact
module, you just have to change your syntax up a bit to reference the metadata in a dictionary for the variable.
- set_fact: {"{{ item.key }}":"{{ item.val }}"}
loop: "{{ item }}"
loop_control:
loop_var: item
Let me know if you have any questions or need any additional help. Happy to assist if I can. Ansible is fun. :)