# using custom vars in group\_by

**URL:** <https://forum.ansible.com/t/using-custom-vars-in-group-by/16473>\
**Category:** Ansible Project\
**Created:** [October 8, 2014, 7:26pm UTC](https://forum.ansible.com/t/using-custom-vars-in-group-by/16473 "2014-10-08T19:26:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![O\_T\_Suarez](https://avatars.discourse-cdn.com/v4/letter/o/c89c15/32.png) [@O\_T\_Suarez](https://forum.ansible.com/u/O_T_Suarez)\
**Post date:** [October 8, 2014, 7:26pm UTC](https://forum.ansible.com/t/using-custom-vars-in-group-by/16473/1 "2014-10-08T19:26:07Z")

</div>

Hi,  
I want to be able to execute tasks on a subgroup of servers. It can be done via groups ([dbservers\_cannary]) in the inventory file, but after checking out group\_by funcionality, I thought of just adding a variable to the host in order to identify its pertenence to the subgroup.  
This is for the cannary release before full deploy.  
The code below doesn’t work as originally intented. Any idea what I am missing?  
Regards,  
Osvaldo

$ cat inventory  
[dbservers]  
db1 ansible\_connection=local deploy=release  
db2 ansible\_connection=local deploy=cannary  
db3 ansible\_connection=local deploy=release  
[wwwservers]  
web1 ansible\_connection=local deploy=cannary  
web2 ansible\_connection=local deploy=release  
web3 ansible\_connection=local deploy=release  
$ cat vars.yml
