# Stopping and starting of services on RHES servers

**URL:** <https://forum.ansible.com/t/stopping-and-starting-of-services-on-rhes-servers/37519>\
**Category:** Ansible Project\
**Created:** [January 4, 2023, 5:56pm UTC](https://forum.ansible.com/t/stopping-and-starting-of-services-on-rhes-servers/37519 "2023-01-04T17:56:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Robert](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@Andrew\_Robert](https://forum.ansible.com/u/Andrew_Robert)\
**Post date:** [January 4, 2023, 5:56pm UTC](https://forum.ansible.com/t/stopping-and-starting-of-services-on-rhes-servers/37519/1 "2023-01-04T17:56:42Z")

</div>

Good afternoon,

I am able to stop/start services on a server with ansible using ssh keys if I specify the services as items.

Is there a way to modify the hosts file to supply the service names by server and pick up as variables?

Better yet, is there a way to auto detect the service names and plug them in when found?

All of the services start with mq@ so there is a pattern to work off of.

Any help you can provide would be fantastic.

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [January 4, 2023, 6:16pm UTC](https://forum.ansible.com/t/stopping-and-starting-of-services-on-rhes-servers/37519/2 "2023-01-04T18:16:37Z")

</div>

What is your source of truth?
