# How to create a complex variable from an existing variable (not a clone)

**URL:** <https://forum.ansible.com/t/how-to-create-a-complex-variable-from-an-existing-variable-not-a-clone/17122>\
**Category:** Ansible Project\
**Created:** [December 20, 2014, 10:59pm UTC](https://forum.ansible.com/t/how-to-create-a-complex-variable-from-an-existing-variable-not-a-clone/17122 "2014-12-20T22:59:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyril\_Scetbon](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@Cyril\_Scetbon](https://forum.ansible.com/u/Cyril_Scetbon)\
**Post date:** [December 20, 2014, 10:59pm UTC](https://forum.ansible.com/t/how-to-create-a-complex-variable-from-an-existing-variable-not-a-clone/17122/1 "2014-12-20T22:59:49Z")

</div>

Hi,

I’m using a lot of parameters when I instantiate an ec2 instance. I’d like to reuse the same configuration for all my instances and extend them depending on instances.  
For example, my global variable is

ec2\_parameters:

key\_name: mykey  
instance\_type: mytype  
image: ami-60a10117  
region: myregion

and in my playbook, I’d like to use the same ec2\_parameters and to add some configuration depending on the instance I configure :

host: instance\_type\_1

vars:  
ec2:

“{{ ec2\_parameters + dict(foo=‘bar’) }}”

host: instance\_type\_2

vars:  
ec2:

“{{ ec2\_parameters + dict(foo=‘toto’) }}”

Is there a way to do that easily ?

Thanks
