# Can i provide options for a module via a dict variable ?

**URL:** <https://forum.ansible.com/t/can-i-provide-options-for-a-module-via-a-dict-variable/23965>\
**Category:** Ansible Project\
**Created:** [March 14, 2017, 1:55pm UTC](https://forum.ansible.com/t/can-i-provide-options-for-a-module-via-a-dict-variable/23965 "2017-03-14T13:55:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [March 14, 2017, 1:55pm UTC](https://forum.ansible.com/t/can-i-provide-options-for-a-module-via-a-dict-variable/23965/1 "2017-03-14T13:55:51Z")

</div>

Suppose i want to start a docker container and its parameters would differ based on a condition. Something like this:

docker\_container:  
name: typeA  
image: typeA  
volumes:

- a1:a1
- a2:a2  
when: type == A

docker\_container:  
name: typeB  
image: typeB  
volumes:

- b1:b1
- b2:b2  
privileged: yes  
when: type == B

I want to avoid writing and maintaining two similar tasks when i know always only one of them will execute. So is there a more elegant way to do this ? Like i define the differences in a dict var and only specify one docker\_container.

I tried this but this didn’t work. I was hoping that there is something similar possible

Avars:

name: typeA  
image: typeA  
volumes:

- a1:a1

Bvars:

name: typeB  
image: typeB  
volumes:

- b1:b1
- b2:b2  
privileged: yes

docker\_container: “{{ (type == A) | ternary ( Avars, Bvars) }}”
