Puppet Class: drbd::base

Defined in:
manifests/base.pp

Overview

Class: drbd::base

Basic class which installs the drbd modules and tools, and enables the service at boot time.

Usage:

include drbd::base

Require:

module kmod (git@github.com:camptocamp/puppet-kmod.git)

Parameters:

  • centos_mirror (Any) (defaults to: 'http://mirror.switch.ch/ftp/mirror/centos/')
  • atrpms_mirror (Any) (defaults to: 'http://ftp-stud.fht-esslingen.de/Mirrors/atrpms/dl.atrpms.net/')


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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'manifests/base.pp', line 14

class drbd::base(
  $centos_mirror = 'http://mirror.switch.ch/ftp/mirror/centos/',
  $atrpms_mirror = 'http://ftp-stud.fht-esslingen.de/Mirrors/atrpms/dl.atrpms.net/',
) {

  case $::operatingsystem {

    'RedHat': {

      case $::lsbmajdistrelease {
        '6': {
          # ATrpms repository doesn't exist anymore, so we're pulling from a
          # mirror which is obviously not updated anymore. Don't have any
          # better alternative right now.

          yumrepo { 'atrpms-drbd':
            descr       => "DRBD packages from an ATrpms mirror for RHEL ${::lsbmajdistrelease}",
            baseurl     => "${atrpms_mirror}el6-${::architecture}/atrpms/stable",
            enabled     => 1,
            gpgcheck    => 0,
            includepkgs => 'drbd,drbd-kmdl-*',
          }

          # ensure file is managed in case we want to purge /etc/yum.repos.d/
          # http://projects.puppetlabs.com/issues/3152
          file { '/etc/yum.repos.d/atrpms-drbd.repo':
            ensure  => file,
            mode    => '0644',
            owner   => 'root',
            require => Yumrepo['atrpms-drbd'],
          }

          if $::virtual == 'xenu' {
            fail 'DRDB on a XEN instance not supported with RHEL6 yet, sorry.'
          }

          package { 'drbd':
            ensure  => present,
            require => [
              Yumrepo['atrpms-drbd'],
              File['/etc/yum.repos.d/atrpms-drbd.repo'],
            ],
          }

          package { 'drbd-module':
            ensure  => present,
            name    => "drbd-kmdl-${::kernelrelease}",
            require => [
              Yumrepo['atrpms-drbd'],
              File['/etc/yum.repos.d/atrpms-drbd.repo'],
            ],
            before  => Kmod::Load['drbd'],
          }

          # Should probably be created by the drbd package, but is not.
          file { '/var/lib/drbd':
            ensure => directory,
          }

        }
        default: {

          yumrepo { 'centos-extra-drbd':
            descr       => "DRBD packages from Centos-extras for RHEL ${::lsbmajdistrelease}",
            baseurl     => "${centos_mirror}${::lsbmajdistrelease}/extras/${::architecture}/",
            enabled     => 1,
            gpgkey      => "${centos_mirror}/RPM-GPG-KEY-CentOS-${::lsbmajdistrelease}",
            gpgcheck    => 1,
            includepkgs => 'drbd83,kmod-drbd83,kmod-drbd83-xen',
          }

          # ensure file is managed in case we want to purge /etc/yum.repos.d/
          # http://projects.puppetlabs.com/issues/3152
          file { '/etc/yum.repos.d/centos-extra-drbd.repo':
            ensure  => file,
            mode    => '0644',
            owner   => 'root',
            require => Yumrepo['centos-extra-drbd'],
          }

          if $::virtual == 'xenu' {
            $kmodpkg = 'kmod-drbd83-xen'
          } else {
            $kmodpkg = 'kmod-drbd83'
          }

          package { 'drbd':
            ensure  => present,
            name    => 'drbd83',
            require => Yumrepo['centos-extra-drbd'],
          }

          package { 'drbd-module':
            ensure  => present,
            name    => $kmodpkg,
            require => Yumrepo['centos-extra-drbd'],
            before  => Kmod::Load['drbd'],
          }

        }
      }


    }

    'Debian': {
      if $::lsbmajdistrelease == '6' {
        package { 'drbd':
          ensure => present,
          name   => 'drbd8-utils',
        }
      }
    }

    'Ubuntu': {
      package { 'drbd':
        ensure => present,
        name   => 'drbd8-utils',
      }

      package { 'drbd-module':
        ensure => present,
        name   => 'drbd8-source',
        before => Kmod::Load['drbd'],
      }
    }

    default: {
      fail "Unsupported OS ${::operatingsystem}"
    }
  }

  kmod::load {'drbd': }

  augeas { 'remove legacy modprobe.conf install entry':
    incl    => '/etc/modprobe.d/modprobe.conf',
    lens    => 'Modprobe.lns',
    changes => "rm install[. = 'drbd']",
    onlyif  => "match install[. = 'drbd'] size > 0",
    before  => Kmod::Load['drbd'],
  }

  service { 'drbd':
    ensure    => running,
    hasstatus => true,
    restart   => '/etc/init.d/drbd reload',
    enable    => true,
    require   => [Package['drbd'], Kmod::Load['drbd']],
  }

  # this file just includes other files
  file { '/etc/drbd.conf':
    ensure  => file,
    mode    => '0644',
    owner   => 'root',
    content => '# file managed by puppet
include "/etc/drbd.conf.d/*.conf";
',
    require => Package['drbd'],
    before  => Service['drbd'],
    notify  => Service['drbd'],
  }

  # only allow files managed by puppet in this directory.
  file { '/etc/drbd.conf.d/':
    ensure  => directory,
    # lint:ignore:fileserver
    source  => 'puppet:///modules/drbd/drbd.conf.d/',
    # lint:endignore
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    purge   => true,
    recurse => true,
    force   => true,
    require => Package['drbd'],
    notify  => Service['drbd'],
  }

}