Puppet Class: pacemaker

Defined in:
manifests/init.pp

Overview

Class: pacemaker

Installs the pacemaker package and heartbeat high availability service. This class sets up heartbeat on the nodes of the cluster, then optionally loads the cluster configuration.

The default communication between nodes is via network broadcast. So mind your network and firewall settings !

Once you have included this class, you should be able to see in the system logs that the cluster nodes are talking to each other. “crm status” should display all your cluster nodes as “online”.

It is then your job to define the cluster resources and relationships using the “crm” command. For more details, see clusterlabs.org/wiki/Documentation

Class variables:

  • *$pacemaker_authkey*: the secret key shared between cluster nodes. It is required to set this attribute.

  • *$pacemaker_crmcli*: the configuration file we want to activate as a configuration file. If this attribute is not set, puppet will not manage the cluster’s configuration.

  • *$pacemaker_hacf*: An alternate file to use instead of the default /etc/ha.d/ha.cf defined in this class. This attribute should point to an ERB template somewhere in your modulepath.

  • *$pacemaker_port*: UDP port used in default configuration. Defaults to 691.

  • *$pacemaker_interface*: Interface used in default configuration. Defaults to eth0.

  • *$pacemaker_keepalive*: keepalive parameter used in default configuration. Defaults to 1.

  • *$pacemaker_warntime*: warntime parameter used in default configuration. Defaults to 6.

  • *$pacemaker_deadtime*: deadtime parameter used in default configuration. Defaults to 10.

  • *$pacemaker_initdead*: initdead parameter used in default configuration. Defaults to 15.

# Example usage:

# use ha.cf template from $moduledir/mymodule/templates/myproject.ha.cf.erb

include pacemaker

class{ 'pacemaker':
  pacemaker_authkey   => 'TheAuthKey',
  pacemaker_nodes     => [$host1, $host2],
  pacemaker_interface => 'eth1',
  pacemaker_deadtime  => 60,
  pacemaker_initdead  => 60,
  pacemaker_warntime  => 30,
  pacemaker_ping      => '0.0.0.0',
  pacemaker_hacf      => 'mymodule/myproject.ha.cf.erb'
}

Parameters:

  • pacemaker_authkey (Any)
  • pacemaker_nodes (Any)
  • pacemaker_ping (Any)
  • pacemaker_hacf (Any)
  • pacemaker_port (Any) (defaults to: '691')
  • 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_crmcli (Any) (defaults to: undef)


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

class pacemaker(
  $pacemaker_authkey,
  $pacemaker_nodes,
  $pacemaker_ping,
  $pacemaker_hacf,
  $pacemaker_port      = '691',
  $pacemaker_interface = 'eth0',
  $pacemaker_keepalive = '1',
  $pacemaker_warntime  = '6',
  $pacemaker_deadtime  = '10',
  $pacemaker_initdead  = '15',
  $pacemaker_crmcli    = undef,
) {

  case $::operatingsystem {
    'RedHat': {

      case $::operatingsystemmajrelease {
        '5': {

          # clusterlabs.org hosts an up to date repository for RHEL.
          yumrepo { 'server_ha-clustering':
            descr    => "High Availability/Clustering server technologies (RHEL_${::operatingsystemmajrelease})",
            baseurl  => "http://www.clusterlabs.org/rpm/epel-${::operatingsystemmajrelease}/",
            enabled  => 1,
            gpgcheck => 0,
          }

          # 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/server_ha-clustering.repo':
            ensure  => file,
            mode    => '0644',
            owner   => 'root',
            require => Yumrepo['server_ha-clustering'],
          }

          package { 'pacemaker':
            ensure  => present,
            name    => "pacemaker.${::architecture}",
            require => Package['heartbeat'],
          }

          package { 'heartbeat':
            ensure => present,
            name   => "heartbeat.${::architecture}",
          }
        }

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

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

    default: {
      fail "Unsupported operating system ${::operatingsystem}"
    }
  }



  file { '/etc/ha.d/authkeys':
    content => "auth 1\n1 sha1 ${pacemaker_authkey}\n",
    owner   => 'root',
    mode    => '0600',
    notify  => Service['heartbeat'],
    require => Package['heartbeat'],
  }

  # heartbeat configuration file, which can be either an ERB template located
  # at $pacemaker_hacf, or the default file shipped with this module.
  $file_content = $pacemaker_hacf ? {
    default => template($pacemaker_hacf),
    ''      => template('pacemaker/ha.cf.erb'),
  }
  file { '/etc/ha.d/ha.cf':
    content => $file_content,
    notify  => Service['heartbeat'],
    require => Package['heartbeat'],
  }

  service { 'heartbeat':
    ensure    => running,
    hasstatus => true,
    enable    => true,
    require   => Package['heartbeat'],
  }

  if ( $pacemaker_crmcli ) {

    # actually load the configuration into heartbeat
    exec { 'reload crm config':
      command     => 'crm configure load replace /etc/ha.d/crm-config.cli',
      refreshonly => true,
      require     => Service['heartbeat'],
    }

    # this file contains the configuration to be loaded into the cluster.
    file { '/etc/ha.d/crm-config.cli':
      notify  => Exec['reload crm config'],
      source  => $pacemaker_crmcli,
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      require => Package['heartbeat'],
    }
  }
}