Systemd service status check

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

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

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

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

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.

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

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

it has…

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

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?

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.

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