summaryrefslogtreecommitdiffstats
path: root/scripts/sbd-device/main.yml
blob: 27fe8d03bfb7a08aa39e604e3977ba4dcc664bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright (C) 2016 Kristoffer Gronlund
#
# License: GNU General Public License (GPL)
version: 2.2
category: Script
shortdesc: "Create SBD Device"
longdesc: |
  Optional step to initialize and configure the SBD Device.

  Prerequisites:

    * The environment must have shared storage reachable by all nodes.

parameters:
  - name: device
    shortdesc: Shared Storage Device
    example: /dev/disk/by-id/...
    required: true
    type: string

  - name: watchdog
    shortdesc: Watchdog Device
    value: /dev/watchdog
    type: string

actions:
  - shortdesc: Verify configuration
    sudo: true
    call: |
      #!/bin/sh
      set -e
      systemctl is-active --quiet sbd && { echo "ERROR: SBD daemon is already running"; exit 1; } || true
      test -b "{{device}}" || { echo "ERROR: Not a device: {{device}"; exit 1; }
      lsmod | egrep "(wd|dog)" || { echo "ERROR: No watchdog kernel module loaded"; exit 1; }
      test -c "{{watchdog}}" || { echo "ERROR: Not a device: {{watchdog}}"; exit 1; }

  - shortdesc: Initialize the SBD device
    sudo: true
    nodes: local
    call: |
      #!/bin/sh
      sbd dump &> /dev/null || sbd -d "{{device}}" create
      # sbd allocate "$(uname -n)" # FIXME

  - shortdesc: Verify SBD Device
    call: |
      #!/bin/sh
      sbd -d "{{device}}" list

  - shortdesc: Configure SBD Daemon
    sudo: true
    call: |
      #!/bin/sh
      [ -f "/etc/sysconfig/sbd" ] && rm -f /etc/sysconfig/sbd || true
      <<EOF
      SBD_DEVICE="{{device}}"
      SBD_WATCHDOG="yes"
      SBD_WATCHDOG_DEV="{{watchdog}}"
      EOF > /etc/sysconfig/sbd

  - shortdesc: Enable SBD Daemon
    service:
      - sbd: start