From 52100da456038eba94657562f875d771bfa66af7 Mon Sep 17 00:00:00 2001 From: Richard Dark Date: Thu, 30 Dec 2010 14:43:16 +0000 Subject: [PATCH 1/7] init.pp should check for lsbmajdistrelease rather than operatingsystemrelease on RedHat/CentOS nodes --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7c74052..9d13902 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,7 +25,7 @@ case $operatingsystem { RedHat,CentOS: { - case $operatingsystemrelease { + case $lsbmajdistrelease { 5: { package { "pacemaker": From d04a3217295acbe216c871394ca3dc52a9d57e9d Mon Sep 17 00:00:00 2001 From: Richard Dark Date: Fri, 31 Dec 2010 00:48:43 +0000 Subject: [PATCH 2/7] minor updates to init.pp - missing comma + imports --- manifests/crm/primitive.pp | 2 +- manifests/init.pp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/crm/primitive.pp b/manifests/crm/primitive.pp index 8512f9a..8d658b1 100644 --- a/manifests/crm/primitive.pp +++ b/manifests/crm/primitive.pp @@ -1,4 +1,4 @@ -define ha::crm::primitive($resource_type, $ensure=present, $monitor_interval, $ignore_dc="false" +define ha::crm::primitive($resource_type, $ensure=present, $monitor_interval, $ignore_dc="false", $priority="", $target_role="", $is_managed="", $resource_stickiness="", $migration_threshold="", $failure_timeout="", $multiple_active="") { diff --git a/manifests/init.pp b/manifests/init.pp index 9d13902..0a6f4f0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,4 @@ -import "primitive.pp" +import "crm/*.pp" import "stonith.pp" import "ip.pp" @@ -82,7 +82,7 @@ mode => 0440, owner => "root", group => "root", - source => "puppet:///ha/etc/logd.cf"; + source => "puppet:///modules/ha/etc/logd.cf"; # Augeas lenses "/usr/share/augeas/lenses/hacf.aug": @@ -90,13 +90,13 @@ mode => 0444, owner => "root", group => "root", - source => "puppet:///ha/usr/share/augeas/lenses/hacf.aug"; + source => "puppet:///modules/ha/usr/share/augeas/lenses/hacf.aug"; "/usr/share/augeas/lenses/haauthkeys.aug": ensure => present, mode => 0444, owner => "root", group => "root", - source => "puppet:///ha/usr/share/augeas/lenses/haauthkeys.aug"; + source => "puppet:///modules/ha/usr/share/augeas/lenses/haauthkeys.aug"; } augeas { From fdd937d18bcb739b25fa675e5b2278c476028d77 Mon Sep 17 00:00:00 2001 From: Richard Dark Date: Fri, 31 Dec 2010 14:56:11 +0000 Subject: [PATCH 3/7] Updated - mail binary location for non Debian distros, CentOS/RHEL: locked versions to current clusterlabs versions, force x64 installation of pacemaker when running on x64 as it pulls both architectures by default, causing a dependency on 32bit perl --- manifests/init.pp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0a6f4f0..357c70e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -22,17 +22,29 @@ Augeas { context => "/files/etc/ha.d/ha.cf" } $email_content = "Heartbeat config on ${fqdn} has changed." + $email_bin = $operatingsystem ? { + Debian => "/usr/bin/mail", + Ubuntu => "/usr/bin/mail", + default => "/bin/mail" + } case $operatingsystem { RedHat,CentOS: { case $lsbmajdistrelease { 5: { package { + # Force x86_64 installation when running x64 as by default it pulls both and has a dependency on 32 bit perl "pacemaker": - ensure => "1.0.4-23.1", + name => $architecture ? { + x86_64 => "pacemaker.x86_64", + default => "pacemaker", + }, + ensure => "1.0.10-1.4.el5", require => Package["heartbeat"]; "heartbeat": - ensure => "2.99.2-8.1"; + # dependency on our yum::centos::five::clusterlabs class here + require => Yumrepo["clusterlabs"], + ensure => "3.0.3-2.3.el5"; } } } @@ -139,7 +151,7 @@ exec { "Send restart email": alias => "restart-email", - command => "/bin/echo \"${email_content}\" | /usr/bin/mail -s \"Heartbeat restart required\" ${alert_email_address}", + command => "/bin/echo \"${email_content}\" | $email_bin -s \"Heartbeat restart required\" ${alert_email_address}", refreshonly => true, } } From fbac054a8db43f92b61f054a09ba5f2480d7caad Mon Sep 17 00:00:00 2001 From: Richard Dark Date: Fri, 31 Dec 2010 16:37:23 +0000 Subject: [PATCH 4/7] removed version lock on pacemaker - #2662 --- manifests/init.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 357c70e..9ad2ea1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -39,7 +39,8 @@ x86_64 => "pacemaker.x86_64", default => "pacemaker", }, - ensure => "1.0.10-1.4.el5", + # Can't lock version and specify architecture currently - see bug #2662 + # ensure => "1.0.10-1.4.el5", require => Package["heartbeat"]; "heartbeat": # dependency on our yum::centos::five::clusterlabs class here From 91f5166a4446b61d8517ce01137591af1e914661 Mon Sep 17 00:00:00 2001 From: Richard Dark Date: Tue, 4 Jan 2011 16:33:06 +0000 Subject: [PATCH 5/7] updated ha::ip so it shouuld actually work.. --- manifests/ip.pp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/manifests/ip.pp b/manifests/ip.pp index c6ec668..119d725 100644 --- a/manifests/ip.pp +++ b/manifests/ip.pp @@ -1,17 +1,18 @@ -define ha::ip($address, $stickiness="undef", $ensure = present) { - ha::primitive { "ha-ip-${address}": - class_name => "ocf:heartbeat:IPaddr2", - monitor_interval => "20", +# Note that setting stickiness by default to 1000 will ensure that failback does NOT happen by default - set this to a lower value if this is the desired behaviour +define ha::ip($address, $stickiness="1000", $ensure = present) { + ha::crm::primitive { "ha-ip-${address}": + resource_type => "ocf:heartbeat:IPaddr2", + monitor_interval => "10s", ensure => $ensure, - stickiness => $stickiness, + resource_stickiness => $stickiness, } if $ensure != absent { - ha::parameter { "ha-ip-${address}-ip": + ha::crm::parameter { "ha-ip-${address}-ip": resource => "ha-ip-${address}", parameter => "ip", value => $address, - require => Ha::Primitive["ha-ip-${address}"], + require => Ha::Crm::Primitive["ha-ip-${address}"], } } } From 286e4bb39c56632e2b469c0c4eb906e8c35119b4 Mon Sep 17 00:00:00 2001 From: Richard Dark Date: Wed, 5 Jan 2011 10:16:31 +0000 Subject: [PATCH 6/7] started merging diffs between my version and some extra commits made by blt04 --- .../functions/augeas_array_to_changes.rb | 13 +++ manifests/init.pp | 86 +++++++++++++++---- templates/ha_logd.cf.erb | 7 ++ 3 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 lib/puppet/parser/functions/augeas_array_to_changes.rb create mode 100644 templates/ha_logd.cf.erb diff --git a/lib/puppet/parser/functions/augeas_array_to_changes.rb b/lib/puppet/parser/functions/augeas_array_to_changes.rb new file mode 100644 index 0000000..b9d8cce --- /dev/null +++ b/lib/puppet/parser/functions/augeas_array_to_changes.rb @@ -0,0 +1,13 @@ +module Puppet::Parser::Functions + newfunction(:augeas_array_to_changes, :type => :rvalue) do |args| + + path = args.shift + changes = Array.new + + args[0].each_with_index do |arg, i| + changes << "set #{path}[#{i+1}] '#{arg}'" + end + + changes + end +end diff --git a/manifests/init.pp b/manifests/init.pp index 9ad2ea1..0dede25 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,4 @@ -import "crm/*.pp" +import "crm/primitive.pp" import "stonith.pp" import "ip.pp" @@ -15,9 +15,9 @@ } } -define ha::node($autojoin="any", $use_logd="on", $compression="bz2", +define ha::node($autojoin="any", $nodes=[], $use_logd="on", $compression="bz2", $keepalive="1", $warntime="5", $deadtime="10", $initdead="60", $authkey, - $alert_email_address) { + $alert_email_address, $logfacility='none', $logfile='/var/log/ha-log', $debugfile='', $debuglevel='0') { Augeas { context => "/files/etc/ha.d/ha.cf" } @@ -39,13 +39,13 @@ x86_64 => "pacemaker.x86_64", default => "pacemaker", }, - # Can't lock version and specify architecture currently - see bug #2662 - # ensure => "1.0.10-1.4.el5", + # Can't lock version and specify architecture currently - see bug #2662 - also, don't really want puppet upgrading a live cluster + ensure => "installed", require => Package["heartbeat"]; "heartbeat": # dependency on our yum::centos::five::clusterlabs class here require => Yumrepo["clusterlabs"], - ensure => "3.0.3-2.3.el5"; + ensure => "installed"; } } } @@ -53,10 +53,10 @@ Debian,Ubuntu: { package { "pacemaker": - ensure => "1.0.4-1.1anchor", + ensure => "installed", require => Package["heartbeat"]; "heartbeat": - ensure => "2.99.2+sles11r9-1.1anchor"; + ensure => "installed"; "openais": ensure => purged; } @@ -89,24 +89,38 @@ ensure => present, mode => 0600; + # ha.cf, only if it doesn't already exist + # augeas will control settings, this just ensures that everything gets + # initialized in the right order + "/etc/ha.d/ha.cf": + ensure => present, + replace => false, + mode => 0644, + owner => "root", + group => "root", + source => "puppet:///modules/ha/etc/ha.d/ha.cf"; + # logd config, it's very simple and can be the same everywhere + "/etc/ha.d/ha_logd.cf": + ensure => present, + mode => 0644, + owner => "root", + group => "root", + content => template('ha/ha_logd.cf.erb'); "/etc/logd.cf": - ensure => present, - mode => 0440, - owner => "root", - group => "root", - source => "puppet:///modules/ha/etc/logd.cf"; - + ensure => link, + target => 'ha.d/ha_logd.cf'; + # Augeas lenses "/usr/share/augeas/lenses/hacf.aug": ensure => present, - mode => 0444, + mode => 0644, owner => "root", group => "root", source => "puppet:///modules/ha/usr/share/augeas/lenses/hacf.aug"; "/usr/share/augeas/lenses/haauthkeys.aug": ensure => present, - mode => 0444, + mode => 0644, owner => "root", group => "root", source => "puppet:///modules/ha/usr/share/augeas/lenses/haauthkeys.aug"; @@ -114,35 +128,53 @@ augeas { "Setting /files/etc/ha.d/ha.cf/port": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set udpport 694"; "Setting /files/etc/ha.d/ha.cf/autojoin": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set autojoin ${autojoin}"; + "Setting /files/etc/ha.d/ha.cf/debug": + require => File["/etc/ha.d/ha.cf"], + notify => Exec["restart-email"], + changes => "set debug ${debuglevel}"; "Setting /files/etc/ha.d/ha.cf/use_logd": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set use_logd ${use_logd}"; "Setting /files/etc/ha.d/ha.cf/traditional_compression": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set traditional_compression off"; "Setting /files/etc/ha.d/ha.cf/compression": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set compression ${compression}"; "Setting /files/etc/ha.d/ha.cf/keepalive": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set keepalive ${keepalive}"; "Setting /files/etc/ha.d/ha.cf/warntime": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set warntime ${warntime}"; "Setting /files/etc/ha.d/ha.cf/deadtime": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set deadtime ${deadtime}"; "Setting /files/etc/ha.d/ha.cf/initdead": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], changes => "set initdead ${initdead}"; "Setting /files/etc/ha.d/ha.cf/crm": + require => File["/etc/ha.d/ha.cf"], notify => Exec["restart-email"], - changes => "set crm yes"; + changes => "set crm respawn"; + "Setting /files/etc/ha.d/ha.cf/node": + require => File["/etc/ha.d/ha.cf"], + notify => Exec["restart-email"], + changes => $joined_nodes ? { '' => "rm node", default => "set node '${joined_nodes}" }; "Setting /files/etc/ha.d/authkeys/auth": context => "/files/etc/ha.d/authkeys", changes => "set auth ${authkey}", @@ -168,9 +200,27 @@ ], onlyif => "match mcast/interface[.='${name}'] size == 0", } - + augeas { "Disable broadcast on ${name}": context => "/files/etc/ha.d/ha.cf", changes => "rm bcast" } } + +define ha::ucast($directives) { + # This only works if the ucast nodes are at the end of the file + # Need a better way to detect if the current setting is already set + # but "onlyif" doesn't lend too much support to our cause + augeas { "Configure unicast nodes on ${name}": + context => "/files/etc/ha.d/ha.cf", + changes => ['rm ucast', augeas_array_to_changes('ucast', $directives)], + } + + augeas { "Disable broadcast and multicast on ${name}": + context => "/files/etc/ha.d/ha.cf", + changes => [ + 'rm bcast', + 'rm mcast', + ], + } +} diff --git a/templates/ha_logd.cf.erb b/templates/ha_logd.cf.erb new file mode 100644 index 0000000..f74beb8 --- /dev/null +++ b/templates/ha_logd.cf.erb @@ -0,0 +1,7 @@ +# file managed by puppet + +logfacility <%= logfacility %> +logfile <%= logfile %> +<% if has_variable?('debugfile') and debugfile != '' %> +debugfile <%= debugfile %> +<% end %> From f1cfc7a21e8f593446dd2853727be14c5da06424 Mon Sep 17 00:00:00 2001 From: Kris Buytaert Date: Fri, 29 Apr 2011 11:51:24 +0200 Subject: [PATCH 7/7] Adding a default resource property define --- manifests/crm/rscdefault.pp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 manifests/crm/rscdefault.pp diff --git a/manifests/crm/rscdefault.pp b/manifests/crm/rscdefault.pp new file mode 100644 index 0000000..c12220f --- /dev/null +++ b/manifests/crm/rscdefault.pp @@ -0,0 +1,16 @@ +define ha::crm::rscdefault($value, $ensure=present) { + + if($ha_cluster_dc == $fqdn) { + if($ensure == absent) { + exec { "Deleting Resource Default ${name}": + command => "/usr/sbin/crm_attribute -t rsc_defaults -n ${name} -D", + onlyif => "/usr/sbin/crm_attribute -t rsc_defaults -n ${name} -G -Q", + } + } else { + exec { "Setting Resource Default ${name} to ${value}": + command => "/usr/sbin/crm_attribute -t rsc_defaults -n ${name} -v ${value}", + unless => "/usr/bin/test `/usr/sbin/crm_attribute -t rsc_defaults -n ${name} -G -Q` = \"${value}\"", + } + } + } +}