aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/functions/ip_to_erl_format.rb31
-rw-r--r--manifests/profile/base/pacemaker.pp60
-rw-r--r--manifests/profile/base/pacemaker_remote.pp37
-rw-r--r--manifests/profile/base/rabbitmq.pp28
-rw-r--r--spec/functions/ip_to_erl_format_spec.rb11
5 files changed, 158 insertions, 9 deletions
diff --git a/lib/puppet/parser/functions/ip_to_erl_format.rb b/lib/puppet/parser/functions/ip_to_erl_format.rb
new file mode 100644
index 0000000..4c066b9
--- /dev/null
+++ b/lib/puppet/parser/functions/ip_to_erl_format.rb
@@ -0,0 +1,31 @@
+require 'ipaddr'
+
+# Custom function to convert an IP4/6 address from a string to the
+# erlang inet kernel format.
+# For example from "172.17.0.16" to {172,17,0,16}
+# See http://erlang.org/doc/man/kernel_app.html and http://erlang.org/doc/man/inet.html
+# for more information.
+module Puppet::Parser::Functions
+ newfunction(:ip_to_erl_format, :type => :rvalue, :doc => "Convert an IP address to the erlang inet format.") do |arg|
+ if arg[0].class != String
+ raise Puppet::ParseError, "Syntax error: #{arg[0]} must be a String"
+ end
+ ip = IPAddr.new arg[0]
+ output = '{'
+ if ip.ipv6?
+ split_char = ':'
+ base = 16
+ else
+ split_char = '.'
+ base = 10
+ end
+ # to_string() prints the canonicalized form
+ ip.to_string().split(split_char).each {
+ |x| output += x.to_i(base).to_s + ','
+ }
+ # Remove the last spurious comma
+ output = output.chomp(',')
+ output += '}'
+ return output
+ end
+end
diff --git a/manifests/profile/base/pacemaker.pp b/manifests/profile/base/pacemaker.pp
index a5a2ccd..6021731 100644
--- a/manifests/profile/base/pacemaker.pp
+++ b/manifests/profile/base/pacemaker.pp
@@ -27,10 +27,50 @@
# (Optional) The number of times pcs commands should be retried.
# Defaults to hiera('pcs_tries', 20)
#
+# [*remote_short_node_names*]
+# (Optional) List of short node names for pacemaker remote nodes
+# Defaults to hiera('pacemaker_remote_short_node_names', [])
+#
+# [*remote_node_ips*]
+# (Optional) List of node ips for pacemaker remote nodes
+# Defaults to hiera('pacemaker_remote_node_ips', [])
+#
+# [*remote_authkey*]
+# (Optional) Authkey for pacemaker remote nodes
+# Defaults to undef
+#
+# [*remote_reconnect_interval*]
+# (Optional) Reconnect interval for the remote
+# Defaults to hiera('pacemaker_remote_reconnect_interval', 60)
+#
+# [*remote_monitor_interval*]
+# (Optional) Monitor interval for the remote
+# Defaults to hiera('pacemaker_monitor_reconnect_interval', 20)
+#
+# [*remote_tries*]
+# (Optional) Number of tries for the remote resource creation
+# Defaults to hiera('pacemaker_remote_tries', 5)
+#
+# [*remote_try_sleep*]
+# (Optional) Number of seconds to sleep between remote creation tries
+# Defaults to hiera('pacemaker_remote_try_sleep', 60)
+#
class tripleo::profile::base::pacemaker (
- $step = hiera('step'),
- $pcs_tries = hiera('pcs_tries', 20),
+ $step = hiera('step'),
+ $pcs_tries = hiera('pcs_tries', 20),
+ $remote_short_node_names = hiera('pacemaker_remote_short_node_names', []),
+ $remote_node_ips = hiera('pacemaker_remote_node_ips', []),
+ $remote_authkey = undef,
+ $remote_reconnect_interval = hiera('pacemaker_remote_reconnect_interval', 60),
+ $remote_monitor_interval = hiera('pacemaker_remote_monitor_interval', 20),
+ $remote_tries = hiera('pacemaker_remote_tries', 5),
+ $remote_try_sleep = hiera('pacemaker_remote_try_sleep', 60),
) {
+
+ if count($remote_short_node_names) != count($remote_node_ips) {
+ fail("Count of ${remote_short_node_names} is not equal to count of ${remote_node_ips}")
+ }
+
Pcmk_resource <| |> {
tries => 10,
try_sleep => 3,
@@ -60,6 +100,7 @@ class tripleo::profile::base::pacemaker (
cluster_members => $pacemaker_cluster_members,
setup_cluster => $pacemaker_master,
cluster_setup_extras => $cluster_setup_extras,
+ remote_authkey => $remote_authkey,
}
class { '::pacemaker::stonith':
disable => !$enable_fencing,
@@ -75,6 +116,21 @@ class tripleo::profile::base::pacemaker (
# enable stonith after all fencing devices have been created
Class['tripleo::fencing'] -> Class['pacemaker::stonith']
}
+ # We have pacemaker remote nodes configured so let's add them as resources
+ # We do this during step 1 right after wait-for-settle, because during step 2
+ # resources might already be created on pacemaker remote nodes and we need
+ # a guarantee that remote nodes are already up
+ if $pacemaker_master and count($remote_short_node_names) > 0 {
+ # Creates a { "node" => "ip_address", ...} hash
+ $remotes_hash = hash(zip($remote_short_node_names, $remote_node_ips))
+ pacemaker::resource::remote { $remote_short_node_names:
+ remote_address => $remotes_hash[$title],
+ reconnect_interval => $remote_reconnect_interval,
+ op_params => "monitor interval=${remote_monitor_interval}",
+ tries => $remote_tries,
+ try_sleep => $remote_try_sleep,
+ }
+ }
}
if $step >= 2 {
diff --git a/manifests/profile/base/pacemaker_remote.pp b/manifests/profile/base/pacemaker_remote.pp
new file mode 100644
index 0000000..e0fff63
--- /dev/null
+++ b/manifests/profile/base/pacemaker_remote.pp
@@ -0,0 +1,37 @@
+# Copyright 2016 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# == Class: tripleo::profile::base::pacemaker_remote
+#
+# Pacemaker remote profile for tripleo
+#
+# === Parameters
+#
+# [*remote_authkey*]
+# Authkey for pacemaker remote nodes
+# Defaults to unset
+#
+# [*step*]
+# (Optional) The current step in deployment. See tripleo-heat-templates
+# for more details.
+# Defaults to hiera('step')
+#
+class tripleo::profile::base::pacemaker_remote (
+ $remote_authkey,
+ $step = hiera('step'),
+) {
+ class { '::pacemaker::remote':
+ remote_authkey => $remote_authkey,
+ }
+}
diff --git a/manifests/profile/base/rabbitmq.pp b/manifests/profile/base/rabbitmq.pp
index 15bab44..fd8de8f 100644
--- a/manifests/profile/base/rabbitmq.pp
+++ b/manifests/profile/base/rabbitmq.pp
@@ -34,6 +34,11 @@
# (Optional) RabbitMQ environment.
# Defaults to hiera('rabbitmq_environment').
#
+# [*inet_dist_interface*]
+# (Optional) Address to bind the inter-cluster interface
+# to. It is the inet_dist_use_interface option in the kernel variables
+# Defaults to hiera('rabbitmq::interface', undef).
+#
# [*nodes*]
# (Optional) Array of host(s) for RabbitMQ nodes.
# Defaults to hiera('rabbitmq_node_names', []).
@@ -44,12 +49,13 @@
# Defaults to hiera('step')
#
class tripleo::profile::base::rabbitmq (
- $config_variables = hiera('rabbitmq_config_variables'),
- $environment = hiera('rabbitmq_environment'),
- $ipv6 = str2bool(hiera('rabbit_ipv6', false)),
- $kernel_variables = hiera('rabbitmq_kernel_variables'),
- $nodes = hiera('rabbitmq_node_names', []),
- $step = hiera('step'),
+ $config_variables = hiera('rabbitmq_config_variables'),
+ $environment = hiera('rabbitmq_environment'),
+ $ipv6 = str2bool(hiera('rabbit_ipv6', false)),
+ $kernel_variables = hiera('rabbitmq_kernel_variables'),
+ $inet_dist_interface = hiera('rabbitmq::interface', undef),
+ $nodes = hiera('rabbitmq_node_names', []),
+ $step = hiera('step'),
) {
# IPv6 environment, necessary for RabbitMQ.
if $ipv6 {
@@ -60,6 +66,14 @@ class tripleo::profile::base::rabbitmq (
} else {
$rabbit_env = $environment
}
+ if $inet_dist_interface {
+ $real_kernel_variables = merge(
+ $kernel_variables,
+ { 'inet_dist_use_interface' => ip_to_erl_format($inet_dist_interface) },
+ )
+ } else {
+ $real_kernel_variables = $kernel_variables
+ }
$manage_service = hiera('rabbitmq::service_manage', true)
if $step >= 1 {
@@ -68,7 +82,7 @@ class tripleo::profile::base::rabbitmq (
class { '::rabbitmq':
config_cluster => $manage_service,
cluster_nodes => $nodes,
- config_kernel_variables => $kernel_variables,
+ config_kernel_variables => $real_kernel_variables,
config_variables => $config_variables,
environment_variables => $rabbit_env,
}
diff --git a/spec/functions/ip_to_erl_format_spec.rb b/spec/functions/ip_to_erl_format_spec.rb
new file mode 100644
index 0000000..b587164
--- /dev/null
+++ b/spec/functions/ip_to_erl_format_spec.rb
@@ -0,0 +1,11 @@
+require 'spec_helper'
+require 'puppet'
+
+describe 'ip_to_erl_format' do
+ it { should run.with_params('192.168.2.1').and_return('{192,168,2,1}') }
+ it { should run.with_params('0.0.0.0').and_return('{0,0,0,0}') }
+ it { should run.with_params('5a40:79cf:8251:5dc5:1624:3c03:3c04:9ba8').and_return('{23104,31183,33361,24005,5668,15363,15364,39848}') }
+ it { should run.with_params('fe80::204:acff:fe17:bf38').and_return('{65152,0,0,0,516,44287,65047,48952}') }
+ it { should run.with_params('::1:2').and_return('{0,0,0,0,0,0,1,2}') }
+ it { should run.with_params('192.256.0.0').and_raise_error(IPAddr::InvalidAddressError) }
+end