Blob Blame History Raw
From dc37d3c376cd3f2a2178d82a928629b231662cf9 Mon Sep 17 00:00:00 2001
From: Milan Lysonek <mlysonek@redhat.om>
Date: Fri, 11 Nov 2022 12:05:28 +0100
Subject: [PATCH] Align service_disabled template to service_enabled

---
 .../service_disabled/ansible.template         | 32 +++++--------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/shared/templates/service_disabled/ansible.template b/shared/templates/service_disabled/ansible.template
index 5c70756b8af..752f6ac5099 100644
--- a/shared/templates/service_disabled/ansible.template
+++ b/shared/templates/service_disabled/ansible.template
@@ -3,39 +3,17 @@
 # strategy = disable
 # complexity = low
 # disruption = low
-{{%- if init_system == "systemd" %}}
 - name: Disable service {{{ SERVICENAME }}}
   block:
+  - name: Gather the package facts
+    package_facts:
+      manager: auto
+
   - name: Disable service {{{ SERVICENAME }}}
-    systemd:
-      name: "{{{ DAEMONNAME }}}.service"
+    service:
+      name: "{{{ DAEMONNAME }}}"
       enabled: "no"
       state: "stopped"
       masked: "yes"
-    ignore_errors: 'yes'
-
-- name: "Unit Socket Exists - {{{ DAEMONNAME }}}.socket"
-  command: systemctl list-unit-files {{{ DAEMONNAME }}}.socket
-  args:
-    warn: False
-  register: socket_file_exists
-  changed_when: False
-  ignore_errors: True
-  check_mode: False
-
-- name: Disable socket {{{ SERVICENAME }}}
-  systemd:
-    name: "{{{ DAEMONNAME }}}.socket"
-    enabled: "no"
-    state: "stopped"
-    masked: "yes"
-  when: '"{{{ DAEMONNAME }}}.socket" in socket_file_exists.stdout_lines[1]'
-{{% elif init_system == "upstart" %}}
-- name: Stop {{{ SERVICENAME }}}
-  command: /sbin/service '{{{ DAEMONNAME }}}' stop
-
-- name: Switch off {{{ SERVICENAME }}}
-  command: /sbin/chkconfig --level 0123456 '{{{ DAEMONNAME }}}' off
-{{%- else %}}
-JINJA TEMPLATE ERROR: Unknown init system '{{{ init_system }}}'
-{{%- endif %}}
+    when:
+    - '"{{{ PACKAGENAME }}}" in ansible_facts.packages'