summaryrefslogtreecommitdiffstats
path: root/scripts/libvirt/main.yml
blob: d982d9f7450af1a58c5df57e47f97efa50100694 (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
64
65
66
# Copyright (C) 2015 Kristoffer Gronlund
#
# License: GNU General Public License (GPL)
version: 2.2
shortdesc: STONITH for libvirt (kvm / Xen)
longdesc: >
  Uses libvirt as a STONITH device to fence a guest node.
  Create a separate resource for each guest node in the cluster.

  Note that the recommended fencing mechanism is SBD whenever
  a shared storage device (like a SAN) is available.
category: Stonith
parameters:
  - name: id
    shortdesc: Resource ID (Name)
    example: stonith-libvirt
    required: true
    type: resource
  - name: target
    shortdesc: Node to Manage With STONITH Device
    type: resource
    required: true
  - name: hostlist
    shortdesc: "List of controlled hosts: hostname[:domain_id].."
    longdesc: >
      The optional domain_id defaults to the hostname.
    type: string
    required: true
  - name: hypervisor_uri
    longdesc: >
      URI for connection to the hypervisor.
      driver[+transport]://[username@][hostlist][:port]/[path][?extraparameters]
      e.g.
      qemu+ssh://my_kvm_server.mydomain.my/system   (uses ssh for root)
      xen://my_kvm_server.mydomain.my/              (uses TLS for client)

      virsh must be installed (e.g. libvirt-client package) and access control must
      be configured for your selected URI.
    example: qemu+ssh://my_kvm_server.example.com/system
    required: true
  - name: reset_method
    required: false
    example: power_cycle
    type: string
    shortdesc: Guest Reset Method
    longdesc: >
      A guest reset may be done by a sequence of off and on commands
      (power_cycle) or by the reboot command. Which method works
      depend on the hypervisor and guest configuration management.
  - name: install
    shortdesc: Enable to Install Required Packages
    type: boolean
    required: false
    value: false
actions:
  - install: cluster-glue libvirt-client
    nodes: all
    when: install
  - cib: |
      primitive {{id}}-{{target}} stonith:external/libvirt
        params
          hostlist="{{hostlist}}"
          hypervisor_uri="{{hypervisor_uri}}"
          {{#reset_method}}reset_method="{{reset_method}}"{{/reset_method}}
        op start timeout=60s
      location l-{{id}}-{{target}} {{id}}-{{target}} -inf: {{target}}