# How to efficiently 'delegate\_to'?

**URL:** <https://forum.ansible.com/t/how-to-efficiently-delegate-to/33064>\
**Category:** Ansible Project\
**Created:** [June 1, 2020, 3:49pm UTC](https://forum.ansible.com/t/how-to-efficiently-delegate-to/33064 "2020-06-01T15:49:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toni\_Mueller](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Toni\_Mueller](https://forum.ansible.com/u/Toni_Mueller)\
**Post date:** [June 1, 2020, 3:49pm UTC](https://forum.ansible.com/t/how-to-efficiently-delegate-to/33064/1 "2020-06-01T15:49:52Z")

</div>

Hi,

in a project to provision stuff, I would like to set a lot of variables  
on a host, which I want to use in a playbook, but take the values for  
that variable from the host I am delegating to. Ie, in my inventory, I  
have

host2 delegate\_to=host1  
host3 delegate\_to=host1  
host4 delegate\_to=host1  
host5 delegate\_to=host1

and in host1, I have a lot of things to do, and also a lot of variables  
to use. Now, I would like to avoid configuring these variables in the  
host\_vars for hosts2..host5, but just in the host\_vars for host1.  
Opening a group is not really feasible, as the association between host1  
and the other hosts on top of it, can vary quickly, and there are no  
fixed groups.

How would I best address this problem?

Cheers,  
Ton1

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [June 1, 2020, 3:59pm UTC](https://forum.ansible.com/t/how-to-efficiently-delegate-to/33064/2 "2020-06-01T15:59:22Z")

</div>

> Hi,
> 
> in a project to provision stuff, I would like to set a lot of variables  
> on a host, which I want to use in a playbook, but take the values for  
> that variable from the host I am delegating to. Ie, in my inventory, I  
> have
> 
> host2 delegate\_to=host1  
> host3 delegate\_to=host1  
> host4 delegate\_to=host1  
> host5 delegate\_to=host1
> 
> and in host1, I have a lot of things to do, and also a lot of variables  
> to use. Now, I would like to avoid configuring these variables in the  
> host\_vars for hosts2..host5, but just in the host\_vars for host1.  
> Opening a group is not really feasible, as the association between host1  
> and the other hosts on top of it, can vary quickly, and there are no  
> fixed groups.
> 
> How would I best address this problem?

The description of your problem is quite generic, but nothing stops you  
from defining variables outside of host or group vars to consume in your tasks.  
A common pattern is to read variables via include\_vars from a number of files.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
