# Ansible delegate to another host

**URL:** <https://forum.ansible.com/t/ansible-delegate-to-another-host/32296>\
**Category:** Ansible Project\
**Created:** [February 21, 2020, 6:33pm UTC](https://forum.ansible.com/t/ansible-delegate-to-another-host/32296 "2020-02-21T18:33:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Juneja](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Amit\_Juneja](https://forum.ansible.com/u/Amit_Juneja)\
**Post date:** [February 21, 2020, 6:33pm UTC](https://forum.ansible.com/t/ansible-delegate-to-another-host/32296/1 "2020-02-21T18:33:18Z")

</div>

Hi everyone,

I would appreciate if you could please look at my issue below and provide your suggestions -

GOAL - Identify if the data in lower environment is scrambled.

Steps -

1. Identify all lower environment and form sql query of random records to run in PROD
2. Dynamically identify the prod server IP address
3. Run the sql query from lower environment task on PROD server

Steps 1 and 2 are working fine, but in the playbook if I use “delegate\_to” with prod server ip (identified as part of step 2), it fails.

Query : In my scenario, If I use delegate\_to option, does that mean its the UAT server ( and not the Ansible server) trying to connect to PROD?

Please suggest an alternative approach. Let me know if you need more details.

Thanks  
Amit

---

<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:** [February 21, 2020, 6:38pm UTC](https://forum.ansible.com/t/ansible-delegate-to-another-host/32296/2 "2020-02-21T18:38:07Z")

</div>

> Hi everyone,
> 
> I would appreciate if you could please look at my issue below and provide your suggestions -
> 
> GOAL - Identify if the data in lower environment is scrambled.
> 
> Steps -  
> 1. Identify all lower environment and form sql query of random records to run in PROD  
> 2. Dynamically identify the prod server IP address  
> 3. Run the sql query from lower environment task on PROD server
> 
> Steps 1 and 2 are working fine, but in the playbook if I use "delegate\_to" with prod server ip (identified as part of  
> step 2), it fails.
> 
> Query : In my scenario, If I use delegate\_to option, does that mean its the UAT server ( and not the Ansible server)  
> trying to connect to PROD?

The Ansible controller connects to the host in delegate\_to:.

> Please suggest an alternative approach. Let me know if you need more details.

Well obviously the task you are running and the error message.

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

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [February 21, 2020, 9:52pm UTC](https://forum.ansible.com/t/ansible-delegate-to-another-host/32296/3 "2020-02-21T21:52:54Z")

</div>

Make sure the host is in your inventory, or try add\_host to get it there.

V/r,  
James Cassell
