Here is my problem I need to use one variable \'target_host\' and then append \'_host\' to it\'s value to get another variable name whose value I need. If you look at my pl
You have two ways to choose:
1. General using.
vars:
- target_host: smtp
- smtp: smtp.max.com
tasks:
- name: testing
debug: msg={{ target_host }}
- name: testing
debug: msg={{ smtp }}
- name: testing
debug: msg={{ vars[target_host] }}
2. Using fact
tasks:
- set_fact: target_host=smtp
- set_fact: smtp=smtp.max.com
- name: testing
debug: msg={{ target_host }}
- name: testing
debug: msg={{ smtp }}
- name: testing
debug: msg={{hostvars[inventory_hostname][target_host]}}