summaryrefslogtreecommitdiffstats
path: root/manifests
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
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')
-rw-r--r--manifests/host.pp10
-rw-r--r--manifests/host/data.pp26
-rw-r--r--manifests/volume.pp46
3 files changed, 70 insertions, 12 deletions
diff --git a/manifests/host.pp b/manifests/host.pp
index cc34564..390b4c4 100644
--- a/manifests/host.pp
+++ b/manifests/host.pp
@@ -31,7 +31,15 @@ define gluster::host(
Gluster::Host[$name] -> Service['glusterd'] # glusterd requires host
# if we're on itself
- if ( "${fqdn}" == "${name}" ) {
+ if "${fqdn}" == "${name}" {
+
+ # store the ip here so that it can be accessed by bricks...
+ class { '::gluster::host::data':
+ #name => $name,
+ ip => "${ip}",
+ fqdn => "${fqdn}",
+ }
+
# don't purge the uuid file generated within
file { "${vardir}/uuid/":
ensure => directory, # make sure this is a directory
diff --git a/manifests/host/data.pp b/manifests/host/data.pp
new file mode 100644
index 0000000..ee54efb
--- /dev/null
+++ b/manifests/host/data.pp
@@ -0,0 +1,26 @@
+# Simple? gluster module by James
+# Copyright (C) 2010-2013+ James Shubin
+# Written by James Shubin <james@shubin.ca>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+class gluster::host::data(
+ #$name,
+ $ip,
+ $fqdn
+) {
+ # so far, this does nothing but 'store' variables
+}
+
+# vim: ts=8
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