I'm not sure that this is possible.
I want to define a var at run-time and use it to access another var(defined in file,playbook..).
defined at run-time :
typeConfig (possible values: "in_config" or "out_config")
defined in playbook:
in_config: url_config: http://localhost/configuration out_config: url_config: http://config.pi.dyn-dns.org/configuration
I need to resolve something similar to this:
{{ {{ typeConfig }}.url_config }}
I try with:
- name: Mytest
hosts: all
gather_facts: false
sudo: yes
vars:
- in_config:
url_config: http://localhost/configuration
- out_config:
url_config: http://config.pi.dyn-dns.org/configuration
tasks:
- set_fact:
typeConfig: in_config
- name: Value in_config.url_config
debug: msg=" {{in_config.url_config}}"
- name: Value out_config.url_config
debug: msg=" {{out_config.url_config}}"
- name: Value typeConfig
debug: var=typeConfig
- debug: msg="{{ {{ typeConfig }}.url_config }} "
ACTUAL RESULTS
task path: /home/nor/gitrepos/iiot-iac/ansible/myUnitTest.yml:19 fatal: [node1]: FAILED! => { "failed": true, "msg": "template error while templating string: expected token ':', got '}'. String: {{ {{ typeConfig }}.url_config }} " } " }