summaryrefslogtreecommitdiffstats
path: root/manifests
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-01-02 19:06:56 -0500
committerJames Shubin <james@shubin.ca>2014-01-02 19:06:56 -0500
commitd2b1e38a8ea8125033d6d576438007ef801e5c07 (patch)
tree69cd58e74410b4d86874741cc1f7c17d19a2bc63 /manifests
parentf646fd61a6cf6474fb622285c26f66d637af716a (diff)
downloadpuppet-gluster-d2b1e38a8ea8125033d6d576438007ef801e5c07.tar.gz
puppet-gluster-d2b1e38a8ea8125033d6d576438007ef801e5c07.tar.xz
puppet-gluster-d2b1e38a8ea8125033d6d576438007ef801e5c07.zip
Try and pick the _right_ default IP address.
If you choose your IP addresses manually, this won't affect you. If you're automatically deploying Puppet-Gluster with Vagrant, this will probably be the missing piece that makes your build more automatic.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/host.pp23
1 files changed, 17 insertions, 6 deletions
diff --git a/manifests/host.pp b/manifests/host.pp
index 21df69d..5db8e6b 100644
--- a/manifests/host.pp
+++ b/manifests/host.pp
@@ -20,7 +20,7 @@
# only the host holding the vip is allowed to execute cluster peer operations.
define gluster::host(
- $ip = $::ipaddress, # specify which ip address to use (if multiple)
+ $ip = '', # you can specify which ip address to use (if multiple)
$uuid = '', # if empty, puppet will attempt to use the gluster fact
$password = '' # if empty, puppet will attempt to choose one magically
) {
@@ -38,10 +38,21 @@ define gluster::host(
# if we're on itself
if "${fqdn}" == "${name}" {
+ $valid_ip = "${ip}" ? {
+ '' => "${::gluster_host_ip}" ? { # smart fact...
+ '' => "${::ipaddress}", # puppet picks!
+ default => "${::gluster_host_ip}", # smart
+ },
+ default => "${ip}", # user selected
+ }
+ if "${valid_ip}" == '' {
+ fail('No valid IP exists!')
+ }
+
# store the ip here so that it can be accessed by bricks...
class { '::gluster::host::data':
#name => $name,
- ip => "${ip}",
+ ip => "${valid_ip}",
fqdn => "${fqdn}",
}
@@ -225,7 +236,7 @@ define gluster::host(
# store so that a fact can figure out the interface and cidr...
file { "${vardir}/vrrp/ip":
- content => "${ip}\n",
+ content => "${valid_ip}\n",
owner => root,
group => root,
mode => 600, # might as well...
@@ -259,7 +270,7 @@ define gluster::host(
File <<| tag == 'gluster_vrrp' |>> { # collect to make facts
}
- # this figures out the interface from the $ip value
+ # this figures out the interface from the $valid_ip value
$if = "${::gluster_vrrp_interface}" # a smart fact!
$cidr = "${::gluster_vrrp_cidr}" # even smarter!
$p = "${::gluster::server::password}" ? { # shh secret...
@@ -279,7 +290,7 @@ define gluster::host(
default => 'BACKUP', # other in list
},
interface => "${if}",
- mcastsrc => "${ip}",
+ mcastsrc => "${valid_ip}",
# TODO: support configuring the label index!
# label ethX:1 for first VIP ethX:2 for second...
ipaddress => "${vip}/${cidr} dev ${if} label ${if}:1",
@@ -304,7 +315,7 @@ define gluster::host(
#$all_ips = inline_template("<%= (ips+[vip]+clients).uniq.delete_if {|x| x.empty? }.join(',') %>")
$source_ips = type($ips) ? {
'array' => inline_template("<%= (ips+[]).uniq.delete_if {|x| x.empty? }.join(',') %>"),
- default => ["${ip}"],
+ default => ["${valid_ip}"],
}
@@shorewall::rule { "glusterd-management-${name}":