Defined Type: labstore::drbd::resource

Defined in:
modules/labstore/manifests/drbd/resource.pp

Overview

Parameters:

  • drbd_cluster (Any)
  • port (Any)
  • device (Any)
  • disk (Any)
  • mount_path (Any)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'modules/labstore/manifests/drbd/resource.pp', line 53

define labstore::drbd::resource (
    $drbd_cluster,
    $port,
    $device,
    $disk,
    $mount_path,
) {

    require ::labstore::drbd::node

    $drbd_hosts = keys($drbd_cluster)

    if size(unique($drbd_hosts)) != 2 {
        fail('specify two nodes by hostname as keys')
    }

    # cheap way to ensure uniqueness across resources
    labstore::drbd::resource::port { $port: }
    labstore::drbd::resource::port { $disk: }
    labstore::drbd::resource::port { $device: }
    labstore::drbd::resource::port { $mount_path: }

    file { "/etc/drbd.d/${name}.res":
        content => template('labstore/drbd/drbd_resource.res.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        require => File['/etc/drbd.d/global_common.conf'],
        notify  => Exec["${name}-drbdadm-adjust"],
    }

    exec { "${name}-drbdadm-adjust":
        command     => "/sbin/drbdadm adjust ${name}",
        onlyif      => "/sbin/drbdadm role ${name} | grep -i -e ^primary -e ^secondary",
        logoutput   => true,
        refreshonly => true,
    }
}