|
|
f6303c |
From dc37d3c376cd3f2a2178d82a928629b231662cf9 Mon Sep 17 00:00:00 2001
|
|
|
f6303c |
From: Milan Lysonek <mlysonek@redhat.om>
|
|
|
f6303c |
Date: Fri, 11 Nov 2022 12:05:28 +0100
|
|
|
f6303c |
Subject: [PATCH] Align service_disabled template to service_enabled
|
|
|
f6303c |
|
|
|
f6303c |
---
|
|
|
f6303c |
.../service_disabled/ansible.template | 32 +++++--------------
|
|
|
f6303c |
1 file changed, 8 insertions(+), 24 deletions(-)
|
|
|
f6303c |
|
|
|
f6303c |
diff --git a/shared/templates/service_disabled/ansible.template b/shared/templates/service_disabled/ansible.template
|
|
|
f6303c |
index 5c70756b8af..752f6ac5099 100644
|
|
|
f6303c |
--- a/shared/templates/service_disabled/ansible.template
|
|
|
f6303c |
+++ b/shared/templates/service_disabled/ansible.template
|
|
|
f6303c |
@@ -3,39 +3,17 @@
|
|
|
f6303c |
# strategy = disable
|
|
|
f6303c |
# complexity = low
|
|
|
f6303c |
# disruption = low
|
|
|
f6303c |
-{{%- if init_system == "systemd" %}}
|
|
|
f6303c |
- name: Disable service {{{ SERVICENAME }}}
|
|
|
f6303c |
block:
|
|
|
f6303c |
+ - name: Gather the package facts
|
|
|
f6303c |
+ package_facts:
|
|
|
f6303c |
+ manager: auto
|
|
|
f6303c |
+
|
|
|
f6303c |
- name: Disable service {{{ SERVICENAME }}}
|
|
|
f6303c |
- systemd:
|
|
|
f6303c |
- name: "{{{ DAEMONNAME }}}.service"
|
|
|
f6303c |
+ service:
|
|
|
f6303c |
+ name: "{{{ DAEMONNAME }}}"
|
|
|
f6303c |
enabled: "no"
|
|
|
f6303c |
state: "stopped"
|
|
|
f6303c |
masked: "yes"
|
|
|
f6303c |
- ignore_errors: 'yes'
|
|
|
f6303c |
-
|
|
|
f6303c |
-- name: "Unit Socket Exists - {{{ DAEMONNAME }}}.socket"
|
|
|
f6303c |
- command: systemctl list-unit-files {{{ DAEMONNAME }}}.socket
|
|
|
f6303c |
- args:
|
|
|
f6303c |
- warn: False
|
|
|
f6303c |
- register: socket_file_exists
|
|
|
f6303c |
- changed_when: False
|
|
|
f6303c |
- ignore_errors: True
|
|
|
f6303c |
- check_mode: False
|
|
|
f6303c |
-
|
|
|
f6303c |
-- name: Disable socket {{{ SERVICENAME }}}
|
|
|
f6303c |
- systemd:
|
|
|
f6303c |
- name: "{{{ DAEMONNAME }}}.socket"
|
|
|
f6303c |
- enabled: "no"
|
|
|
f6303c |
- state: "stopped"
|
|
|
f6303c |
- masked: "yes"
|
|
|
f6303c |
- when: '"{{{ DAEMONNAME }}}.socket" in socket_file_exists.stdout_lines[1]'
|
|
|
f6303c |
-{{% elif init_system == "upstart" %}}
|
|
|
f6303c |
-- name: Stop {{{ SERVICENAME }}}
|
|
|
f6303c |
- command: /sbin/service '{{{ DAEMONNAME }}}' stop
|
|
|
f6303c |
-
|
|
|
f6303c |
-- name: Switch off {{{ SERVICENAME }}}
|
|
|
f6303c |
- command: /sbin/chkconfig --level 0123456 '{{{ DAEMONNAME }}}' off
|
|
|
f6303c |
-{{%- else %}}
|
|
|
f6303c |
-JINJA TEMPLATE ERROR: Unknown init system '{{{ init_system }}}'
|
|
|
f6303c |
-{{%- endif %}}
|
|
|
f6303c |
+ when:
|
|
|
f6303c |
+ - '"{{{ PACKAGENAME }}}" in ansible_facts.packages'
|