# platform = multi_platform_all
# reboot = false
# strategy = disable
# complexity = low
# disruption = low
{{%- if init_system == "systemd" %}}
- name: "Unit Service Exists - {{{ DAEMONNAME }}}.service"
  command: systemctl list-unit-files {{{ DAEMONNAME }}}.service
  register: service_file_exists
  changed_when: False
  ignore_errors: True
- name: Disable service {{{ SERVICENAME }}}
  systemd:
    name: "{{{ DAEMONNAME }}}.service"
    enabled: "no"
    state: "stopped"
{{%- if MASK_SERVICE %}}
    masked: "yes"
{{%- endif %}}
  when: '"{{{ DAEMONNAME }}}.service" in service_file_exists.stdout_lines[1]'
- name: "Unit Socket Exists - {{{ DAEMONNAME }}}.socket"
  command: systemctl list-unit-files {{{ DAEMONNAME }}}.socket
  register: socket_file_exists
  changed_when: False
  ignore_errors: True
- name: Disable socket {{{ SERVICENAME }}}
  systemd:
    name: "{{{ DAEMONNAME }}}.socket"
    enabled: "no"
    state: "stopped"
{{%- if MASK_SERVICE %}}
    masked: "yes"
{{%- endif %}}
  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 %}}
