# SPDX-License-Identifier: MIT
---
- name: Enable or disable configured cluster services on boot
  service:
    name: "{{ item }}"
    enabled: "{{ ha_cluster_start_on_boot }}"
  loop: "{{ __ha_cluster_services }}"
  when:
    # Null (i.e. nochange) is currently not supported: Either all nodes are
    # configured to start the cluster on boot or not to start the cluster on
    # boot. Null (nochange) could lead to situations where part of cluster
    # nodes are configured to start the cluster on boot while other nodes in
    # the same cluster are not.
    - item != 'corosync-qdevice' or __ha_cluster_qdevice_in_use

- name: Get services status - detect SBD
  service_facts:

- name: Enable or disable SBD
  service:
    name: sbd
    enabled: "{{ ha_cluster_sbd_enabled }}"
    # Enabling SBD doesn't depend on 'ha_cluster_start_on_boot' variable as SBD
    # is started automatically by pacemaker.
  when:
    - '"sbd.service" in ansible_facts.services'
  register: __ha_cluster_sbd_service_enable_disable
