Join two variables

I have two variable definition files as follows

*vars.yml*
aws_common_tags:
Project: "{{ project_name }}"
Application: "{{ application_name }}"
Region: "{{ aws_region }}"
Ansible: "Yes"

*instance.yml*
ec2_instance_tags:
    environment_name: dev

Now in task.yml I am tryin to create aws ec2 instance with all tags but its
not working.

ec2:
    key_name: "{{ keypair_name }}"
    instance_type: "{{ ec2_instance_type }}"
    instance_tags: "{{ aws_common_tags + ec2_instance_tags }}"

We are getting the following error:

"tags": {
        "Ansible": "Yes",
        "Application": "webserver",
        "Project": "document_upload",
        "Region": "us-west-2"
    },

fatal: [localhost]: FAILED! => {
    "msg": "Unexpected templating type error occurred on ({{
aws_common_tags + ec2_instance_tags }}): unsupported operand type(s) for +:
'dict' and 'dict'"
}
Thanks
Geo

The error is correct. You can’t add one dict to another using the + operand.

Use combine instead:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#combining-hashes-dictionaries

Thanks… Working fine now.