# best practice to assign conditional variables, depending on --extra-vars values

**URL:** <https://forum.ansible.com/t/best-practice-to-assign-conditional-variables-depending-on-extra-vars-values/17674>\
**Category:** Ansible Project\
**Created:** [March 5, 2015, 10:30am UTC](https://forum.ansible.com/t/best-practice-to-assign-conditional-variables-depending-on-extra-vars-values/17674 "2015-03-05T10:30:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten\_Reinhard](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@Torsten\_Reinhard](https://forum.ansible.com/u/Torsten_Reinhard)\
**Post date:** [March 5, 2015, 10:30am UTC](https://forum.ansible.com/t/best-practice-to-assign-conditional-variables-depending-on-extra-vars-values/17674/1 "2015-03-05T10:30:53Z")

</div>

Hi,

I´ve a “best practice” question of how to define conditional variables, depending on other variables:  
The requirement is:

- –extra-vars “extint\_filter=regEx” should filter instances

- –extra-vars “internalOnly=true” should filter instances by a ‘build-in’ filter,read from {{stage}} file

- if both are passed, the ‘built-in’ filter wins

- if nothing is passed, the filter defaults to “.\*”, so all instances are selected

Actually I solved it like this:

`
