# lookup syntax (or client/server install)

**URL:** <https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374>\
**Category:** Ansible Project\
**Created:** [May 30, 2014, 9:56am UTC](https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374 "2014-05-30T09:56:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Makimoto\_Marakatti](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@Makimoto\_Marakatti](https://forum.ansible.com/u/Makimoto_Marakatti)\
**Post date:** [May 30, 2014, 9:56am UTC](https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374/1 "2014-05-30T09:56:20Z")

</div>

Hi all

Let’s say I’ve got a service that I need to install on a machine that we’ll call ‘client’ and for that to work it has to get some parameter from a box called ‘master’.

For this to work under ansible it would need to:

- install on ‘client’
- contact ‘master’ to relay the hostname of ‘client’ and get an install string
- go back to ‘client’ and perform a sync with this string.

So I thought the best way to approach this would be lookups. But can’t figure out the syntax for this, or even if this would be the right approach?

(I can actually make this work with a shell script easily, but thought that ansible would be the right tool to get things standardized)

Any insights greatly appreciated…

---

<div class="post-metadata">

**Author:** ![Nathan\_Howell](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@Nathan\_Howell](https://forum.ansible.com/u/Nathan_Howell)\
**Post date:** [May 30, 2014, 5:46pm UTC](https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374/2 "2014-05-30T17:46:01Z")

</div>

My thought would be to use delegate\_to to call a script on master that returns the string that the client needs.

Nathan

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 31, 2014, 4:25pm UTC](https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374/3 "2014-05-31T16:25:57Z")

</div>

“Let’s say I’ve got a service that I need to install on a machine that we’ll call ‘client’ and for that to work it has to get some parameter from a box called ‘master’.”

Just gather this parameter via a fact or run a seperate play first to save that result for that particular host.

delegate\_to from 500 machines to a common machine can result in a bit of DDOS, and is usually not the answer.

---

<div class="post-metadata">

**Author:** ![Makimoto\_Marakatti](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@Makimoto\_Marakatti](https://forum.ansible.com/u/Makimoto_Marakatti)\
**Post date:** [June 3, 2014, 10:10am UTC](https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374/4 "2014-06-03T10:10:46Z")

</div>

Hi

Thanks for the comments. It would help tho, if I had explained the issue in a coherent way. ☹

Let me rephrase:

I still got a service to install.  
But it’s in a bunch of boxes that we’ll call ‘client-group’ (client1, client2…).  
I still got a ‘master’ box that needs to be contacted for each ‘client#’ box.

So ansible should loop over the client-group and do:

- install on client#
- contact ‘master’ to relay the hostname of ‘client#’ and get an install string
- go back to ‘client#’ and perform a sync with this string.

The problem comes when I declare in a play:

`  
hosts: client-group

`

From then on, it seems to me impossible to contact any other machine than what is declared on the ‘hosts’ line.

So that’s why I did ask for help with lookups, but not sure at all, how that would work.

I ended up doing this with a loop in a shell script. Ugly but works…

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [June 6, 2014, 12:18pm UTC](https://forum.ansible.com/t/lookup-syntax-or-client-server-install/15374/5 "2014-06-06T12:18:48Z")

</div>

“From then on, it seems to me impossible to contact any other machine than what is declared on the ‘hosts’ line.”

You can start another play in the same playbook that talks to a different host group.
