When I read the Ansible source code, the values โโof the variables in the inventory files are evaluated using the "ast.literal_eval ()" Python. That way you can describe dict variables in inventory files with single-line Python literals.
Your example might look like this:
[all:vars] region_subnet_matrix={'site1': {'subnet': 'subnet-xxxxxxx', 'region': '{{ aws_region }}', 'zone': '{{aws_region}}a'}, 'site2': {'subnet': 'subnet-xxxxxxx', 'region': '{{ aws_region }}', 'zone': '{{aws_region}}b'}}
Make sure that this example does not evaluate variables.
NB: I do not know that such an inventory variable definition is officially permitted.
source share