I have an Ansible playbook that uses two var files; one for general properties and others for me specific properties. However, there are some properties from both files that share the same root YAML structure (aws.ec2) but when I run my playbook, it seems like the properties do not merge into one tree, but the last listed file overwrites the previous for any props using aws.ec2.
Playbook
- name: Play 1. Create AWS Environment
hosts: localhost
vars_files:
- var_files/aws_management_vars.yml
- var_files/aws_general_vars.yml
aws_management_vars.yml
aws:
ec2:
node:
name: "Management Node"
instance_type: "t2.micro"
...
aws_general_vars.yml
aws:
region: us-west-1
ec2:
env: mih-env
vpc_id: vpc-abc12345
...
When I run my playbook, if I have the vars file in the order here, it complains that it cannot find aws.ec2.node.
"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'node'
If I swap the order, it complains that it cannot find aws.region.
"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'region'
Is this a limitation of vars_files and is there something else I can use that will parse the yml files and merge properties that have the same structure? I know I could just rename the structure in the files, but I would like it keep it this way if possible.
Ansible v2.7.8