# Run a task only on remote host if this hosts a specific database

**URL:** <https://forum.ansible.com/t/run-a-task-only-on-remote-host-if-this-hosts-a-specific-database/29229>\
**Category:** Ansible Project\
**Created:** [December 9, 2018, 4:06pm UTC](https://forum.ansible.com/t/run-a-task-only-on-remote-host-if-this-hosts-a-specific-database/29229 "2018-12-09T16:06:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Marquardt](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Christian\_Marquardt](https://forum.ansible.com/u/Christian_Marquardt)\
**Post date:** [December 9, 2018, 4:06pm UTC](https://forum.ansible.com/t/run-a-task-only-on-remote-host-if-this-hosts-a-specific-database/29229/1 "2018-12-09T16:06:28Z")

</div>

Hello,

I’m looking for ideas on how I can realize the following:

I wan’t to change some database parameters on a specific database. I’ve several ideas but I’m not sure how to realize this.  
For example:

- Having local facts defined on remote machine containing a list of databases running on this host
- Having local list of host-database-relationship on the ansible host itself

Does anyone of you have an better idea?

thanks  
Christian

---

<div class="post-metadata">

**Author:** ![Andy\_Smith](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andy\_Smith](https://forum.ansible.com/u/Andy_Smith)\
**Post date:** [December 9, 2018, 5:15pm UTC](https://forum.ansible.com/t/run-a-task-only-on-remote-host-if-this-hosts-a-specific-database/29229/2 "2018-12-09T17:15:06Z")

</div>

Hi Christian,

> - Having local facts defined on remote machine containing a list of  
> databases running on this host  
> - Having local list of host-database-relationship on the ansible host itself
> 
> Does anyone of you have an better idea?

If I was going to have multiple tasks interacting with the list of  
databases I think I would go the fact route.

Otherwise I would probably run a command that listed the databases,  
register it in a variable and then do things in later tasks based on  
that variable.

Cheers,  
Andy
