Defined Type: labstore::drbd::resource

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

Overview

Parameters:

  • drbd_cluster (Hash)
  • port (Stdlib::Port)
  • device (Stdlib::Unixpath)
  • disk (Stdlib::Unixpath)
  • mount_path (Stdlib::Unixpath)


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 (
    Hash $drbd_cluster,
    Stdlib::Port $port,
    Stdlib::Unixpath $device,
    Stdlib::Unixpath $disk,
    Stdlib::Unixpath $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}": }  # lint:ignore:only_variable_string  titles must be strings
    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,
    }
}