summaryrefslogtreecommitdiffstats
path: root/manifests/volume.pp
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2013-09-18 05:52:23 -0400
committerJames Shubin <james@shubin.ca>2013-09-18 05:52:23 -0400
commit4dbba38fc44e8d7226fdecec12b1237fc24d026d (patch)
tree215fa7e931f7c9b71bbdd2d7fade629dea5546d0 /manifests/volume.pp
parent269be1cc13c43df0e8e3a3c0babbe494ed727e60 (diff)
downloadpuppet-gluster-4dbba38fc44e8d7226fdecec12b1237fc24d026d.tar.gz
puppet-gluster-4dbba38fc44e8d7226fdecec12b1237fc24d026d.tar.xz
puppet-gluster-4dbba38fc44e8d7226fdecec12b1237fc24d026d.zip
Finally, Fancy Firewalling...
This adds experimental support for automatic firewalling. Initially, we don't know the other hosts (until they are exported and collected) so we start with an blank firewall to all hosts. After hosts start checking in, we start only allowing specify host ips. For the volume building, we can't predict (AFAICT) which ports will be used until after the volume is started, so we initially allow all ports inbound, until the fact gets the data from the started volume and uses those specific ports. This naturally takes multiple puppet runs to complete.
Diffstat (limited to 'manifests/volume.pp')
-rw-r--r--manifests/volume.pp46
1 files changed, 35 insertions, 11 deletions
diff --git a/manifests/volume.pp b/manifests/volume.pp
index b1bc712..0873ad4 100644
--- a/manifests/volume.pp
+++ b/manifests/volume.pp
@@ -122,17 +122,6 @@ define gluster::volume(
}
}
- # TODO:
- #if $shorewall {
- # shorewall::rule { 'gluster-TODO':
- # rule => "
- # ACCEPT ${zone} $FW tcp 24009:${endport}
- # ",
- # comment => 'TODO',
- # before => Service['glusterd'],
- # }
- #}
-
# run if vip not defined (by pass mode) or vip exists on this machine
if ($vip == '' or $vipif != '') {
if $start == true {
@@ -161,6 +150,41 @@ define gluster::volume(
# don't manage volume run state
}
}
+
+ $shorewall = $::gluster::server::shorewall
+ if $shorewall {
+ $zone = $::gluster::server::zone # firewall zone
+
+ $ips = $::gluster::server::ips # override host ip list
+ $ip = $::gluster::host::data::ip # ip of brick's host...
+ $source_ips = type($ips) ? {
+ 'array' => inline_template("<%= (ips+[]).uniq.delete_if {|x| x.empty? }.join(',') %>"),
+ default => ["${ip}"],
+ }
+
+ $port = getvar("gluster_ports_volume_${name}") # fact !
+
+ # NOTE: we need to add the $fqdn so that exported resources
+ # don't conflict... I'm not sure they should anyways though
+ @@shorewall::rule { "gluster-volume-${name}-${fqdn}":
+ action => 'ACCEPT',
+ source => "${zone}", # override this on collect...
+ source_ips => $source_ips,
+ dest => '$FW',
+ proto => 'tcp',
+ port => "${port}", # comma separated string or list
+ #comment => "${fqdn}",
+ comment => 'Allow incoming tcp port from glusterfsds.',
+ tag => 'gluster_firewall_volume',
+ ensure => present,
+ }
+ # we probably shouldn't collect the above rule from our self...
+ #Shorewall::Rule <<| tag == 'gluster_firewall_volume' and comment != "${fqdn}" |>> {
+ Shorewall::Rule <<| tag == 'gluster_firewall_volume' |>> {
+ source => "${zone}", # use our source zone
+ before => Service['glusterd'],
+ }
+ }
}
# vim: ts=8