Puppet Class: pacemaker::corosync

Defined in:
manifests/corosync.pp

Overview

Class: pacemaker::corosync

$pacemaker_log_time_unit: a valid value for logrotate: daily, monthly, weekly

Parameters:

  • corosync_mcast_ip (Any)
  • corosync_mcast_port (Any)
  • corosync_authkey_file (Any)
  • pacemaker_authkey (Any)
  • corosync_conf_template (Any) (defaults to: undef)
  • corosync_conf_content (Any) (defaults to: undef)
  • corosync_manage_service (Any) (defaults to: true)
  • pacemaker_interface (Any) (defaults to: 'eth0')
  • pacemaker_keepalive (Any) (defaults to: 1)
  • pacemaker_warntime (Any) (defaults to: 6)
  • pacemaker_deadtime (Any) (defaults to: 10)
  • pacemaker_initdead (Any) (defaults to: 15)
  • pacemaker_logrotate_template (Any) (defaults to: undef)
  • pacemaker_logrotate_content (Any) (defaults to: undef)
  • pacemaker_log_units_hold (Any) (defaults to: 32)
  • pacemaker_log_time_unit (Any) (defaults to: 'daily')


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
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
# File 'manifests/corosync.pp', line 5

class pacemaker::corosync(
  $corosync_mcast_ip,
  $corosync_mcast_port,
  $corosync_authkey_file,
  $pacemaker_authkey,
  $corosync_conf_template       = undef,
  $corosync_conf_content        = undef,
  $corosync_manage_service      = true,
  $pacemaker_interface          = 'eth0',
  $pacemaker_keepalive          = 1,
  $pacemaker_warntime           = 6,
  $pacemaker_deadtime           = 10,
  $pacemaker_initdead           = 15,
  # For logrotate configuration
  $pacemaker_logrotate_template = undef,
  $pacemaker_logrotate_content  = undef,
  $pacemaker_log_units_hold     = 32,
  $pacemaker_log_time_unit      = 'daily',
) {

  case $::operatingsystem {
    'RedHat': {

      case $::operatingsystemmajrelease {
        '6': {

          package { 'pacemaker':
            ensure  => present,
            require => Package['corosync'],
          }

          package { 'corosync':
            ensure  => present,
          }

          selinux::module { 'ha':
            content => file('pacemaker/selinux/ha.te'),
            require => Package['corosync'],
          }

          # Me thinks these should be created by the packages, but, well, it's not Debian..
          file { '/var/run/crm':
            ensure  => directory,
            owner   => 'hacluster',
            group   => 'haclient',
            mode    => '0755',
            require => Package['corosync'],
          }
          file { '/var/run/heartbeat':
            ensure => directory,
            owner  => 'root',
            group  => 'root',
            mode   => '0755',
          }

          if $corosync_manage_service {
            Service['corosync'] {
              require => [ Package['corosync'], File['/etc/corosync/authkey'], File['/etc/corosync/corosync.conf'],
                          File['/var/run/crm'], File['/var/run/heartbeat'] ],
            }
          }
        }

        default: { fail("pacemaker::corosync not implemented on ${::operatingsystem} ${::operatingsystemmajrelease}")
        }
      }
    }

    'Debian': {
      case $::lsbmajdistrelease {

        '6': {

          package { ['pacemaker', 'corosync']:
            ensure => present,
          }

          if $corosync_manage_service {
            Service['corosync'] {
              require => [ Package['corosync'], File['/etc/corosync/authkey'], File['/etc/corosync/corosync.conf'] ],
            }
          }

          augeas { 'corosync start on boot' :
            context => '/files/etc/default/corosync',
            changes => [ 'set START yes' ],
          }

        }

        default: { fail("pacemaker::corosync not implemented on ${::operatingsystem} ${::lsbmajdistrelease}")
        }

      }
    }

    default: { fail("pacemaker::corosync not implemented on ${::operatingsystem}")
    }
  }

  if $corosync_conf_content and $corosync_conf_template {
    fail 'Cannot pass both $corosync_conf_content and $corosync_conf_template'
  }

  if $corosync_conf_template {
    warning 'Using $corosync_conf_template is deprecated. Using $corosync_conf_content instead.'
    $_corosync_conf_content = template($corosync_conf_template)
  } elsif ($corosync_conf_content) {
    $_corosync_conf_content = $corosync_conf_content
  } else {
    fail 'You must pass either $corosync_conf_content or $corosync_conf_template'
  }

  file { '/etc/corosync/corosync.conf':
    owner   => 'root',
    group   => 'root',
    mode    => '0600',
    content => $_corosync_conf_content,
    require => Package['corosync'],
  }

  file { '/etc/corosync/authkey':
    owner   => 'root',
    group   => 'root',
    mode    => '0400',
    source  => $corosync_authkey_file,
    require => Package['corosync'],
  }

  if $pacemaker_logrotate_content and $pacemaker_logrotate_template {
    fail 'Cannot pass both $pacemaker_logrotate_content and $pacemaker_logrotate_template'
  }

  if $pacemaker_logrotate_template {
    warning 'Using $pacemaker_logrotate_template is deprecated. Using $pacemaker_logrotate_content instead.'
    $_pacemaker_logrotate_content = template($pacemaker_logrotate_template)
  } elsif ($pacemaker_logrotate_content) {
    $_pacemaker_logrotate_content = $pacemaker_logrotate_content
  } else {
    $_pacemaker_logrotate_content = template('pacemaker/corosync.logrotate.erb')
  }

  file { '/etc/logrotate.d/corosync':
    ensure  => file,
    owner   => root,
    group   => root,
    content => $_pacemaker_logrotate_content,
    replace => false,
  }

  if $corosync_manage_service {
    service { 'corosync':
      ensure    => running,
      hasstatus => true,
      enable    => true,
    }
  }

}