So, I disqualified it because in Ansible 2.12, there is an ability to define defaults for module collections, more on that
here.
In ansible-core 2.12, collections can define their own groups in the meta/runtime.yml file. module_defaults does not take the collections keyword into account, so the fully qualified group name must be used for new groups in module_defaults.
This means my playbook requires a value to begin with.
module_defaults:
group/ns.col.session:
session_id: <VALUE>
Now, if I'm going to use set_fact, this is what my playbook looks like.
---
- hosts:
- localhost
vars:
session_fact:
module_defaults:
group/ns.col.session:
session_id: "{{ session_fact }}"
tasks:
- name: "SETTING VALUE FOR FACT session_fact"
set_fact:
session_fact: "MYSESSIONVALUE"
delegate_to: localhost
register: RESULT
- name: "MY MODULE 1"
ns.col.mymodule1 :
param1: "val1"
As you can see, I have to create a variable called session_fact , assign it to the module default, at this point, its value is Null, then in the first set_fact task, I assign it a proper value.
Now, it does work but I'm not sure if this is the cleanest approach, naming a variable a fact.
Thanks
Dhiwakar