# Systemd service status check

**URL:** <https://forum.ansible.com/t/systemd-service-status-check/38039>\
**Category:** Ansible Project\
**Created:** [May 30, 2023, 10:07pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039 "2023-05-30T22:07:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 30, 2023, 10:07pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/1 "2023-05-30T22:07:23Z")

</div>

I am trying to run my playbook to check/restart/stop kestrel service on given node. I am able to ping that node using ansible but when running the task its is failing with connection timeout error.  
here is the playbook

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [May 30, 2023, 10:13pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/2 "2023-05-30T22:13:10Z")

</div>

Just wonder whether you can disable that service manually in 5 mins?

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 30, 2023, 10:20pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/3 "2023-05-30T22:20:25Z")

</div>

yea, I tried that option just to check if its timing out before it is disabling  
btw, I got it fixed I changed the user: root at the top level instead of play level

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 30, 2023, 10:21pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/4 "2023-05-30T22:21:06Z")

</div>

But I had one more question here, can I delete the kestrel service using ansible??

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [May 30, 2023, 10:24pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/5 "2023-05-30T22:24:11Z")

</div>

> yea, I tried that option just to check if its timing out before it is disabling  
> btw, I got it fixed I changed the user: root at the top level instead of play level

Aha, you can also opt to become root in task level, with sudo as well.

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 30, 2023, 10:26pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/6 "2023-05-30T22:26:19Z")

</div>

Right, I had it in the task level, some how it did not work.

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [May 30, 2023, 11:09pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/7 "2023-05-30T23:09:36Z")

</div>

Just wonder whether the user you initially ran on had sudo access…

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 31, 2023, 12:04am UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/8 "2023-05-31T00:04:53Z")

</div>

it has…

coming to my other question, can I delete a service on linux using ansible…

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [May 31, 2023, 12:15am UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/9 "2023-05-31T00:15:26Z")

</div>

Don’t believe you can from systemctl commands, but just like we create service definitions, we can delete them as well. I’m thinking:

1. Stop the service, and disable
2. Track down the service definition file, delete it
3. Perform a systemctl daemon-reload… might have to do this as a command.

But, why delete? DIsable is not good enough?

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 31, 2023, 12:19am UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/10 "2023-05-31T00:19:24Z")

</div>

There are applications migrating from vms to k8s, so we don’t need to have service kept disabled on old systems, may cause confusion and maintenance.

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [May 31, 2023, 5:59pm UTC](https://forum.ansible.com/t/systemd-service-status-check/38039/11 "2023-05-31T17:59:51Z")

</div>

btw, i got this working … thought it would be helpful for someone, so posting it…
