# GlusterFS module by James # Copyright (C) 2010-2013+ James Shubin # Written by James Shubin # # 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 . class gluster::server( $vip = '', # vip of the cluster (optional but recommended) $nfs = false, # TODO $repo = true, # add a repo automatically? true or false $version = '', # pick a specific version (defaults to latest) $vrrp = false, $password = '', # global vrrp password to use $shorewall = false, $zone = 'net', # TODO: allow a list of zones $ips = false, # an optional list of ip's for each in hosts[] $clients = [] # list of allowed client ip's # TODO: get from exported resources ) { $FW = '$FW' # make using $FW in shorewall easier # $gluster_package_version is a fact; commonly set by vagrant if "${version}" == '' and "${gluster_package_version}" == '' { $valid_version = '' } else { if "${version}" != '' and "${gluster_package_version}" != '' { warning('Requested GlusterFS version specified twice!') if "${version}" != "${gluster_package_version}" { fail('Requested GlusterFS version mismatch!') } $valid_version = "${version}" } elsif "${version}" != '' { $valid_version = "${version}" } elsif "${gluster_package_version}" != '' { $valid_version = "${gluster_package_version}" } else { fail('Programming error!') } } # ensure these are from a gluster repo if $repo { class { '::gluster::repo': version => "${valid_version}", } } package { 'moreutils': # for scripts needing: 'sponge' ensure => present, before => Package['glusterfs-server'], } package { 'glusterfs-server': ensure => "${valid_version}" ? { '' => present, default => "${valid_version}", }, require => $repo ? { false => undef, default => Class['::gluster::repo'], }, } # NOTE: not that we necessarily manage anything in here at the moment... file { '/etc/glusterfs/': ensure => directory, # make sure this is a directory recurse => false, # TODO: eventually... purge => false, # TODO: eventually... force => false, # TODO: eventually... owner => root, group => root, mode => 644, #notify => Service['glusterd'], # TODO: ??? require => Package['glusterfs-server'], } file { '/etc/glusterfs/glusterd.vol': content => template('gluster/glusterd.vol.erb'), # NOTE: currently no templating is being done owner => root, group => root, mode => 644, # u=rw,go=r ensure => present, require => File['/etc/glusterfs/'], } file { '/var/lib/glusterd/': ensure => directory, # make sure this is a directory recurse => false, # TODO: eventually... purge => false, # TODO: eventually... force => false, # TODO: eventually... owner => root, group => root, mode => 644, #notify => Service['glusterd'], # TODO: eventually... require => File['/etc/glusterfs/glusterd.vol'], } file { '/var/lib/glusterd/peers/': ensure => directory, # make sure this is a directory recurse => true, # recursively manage directory purge => true, force => true, owner => root, group => root, mode => 644, notify => Service['glusterd'], require => File['/var/lib/glusterd/'], } if $vrrp { class { '::keepalived': start => true, shorewall => $shorewall, } } if $shorewall { # XXX: WIP #if type($ips) == 'array' { # #$other_host_ips = inline_template("<%= ips.delete_if {|x| x == '${ipaddress}' }.join(',') %>") # list of ips except myself # $source_ips = inline_template("<%= (ips+clients).uniq.delete_if {|x| x.empty? }.join(',') %>") # #$all_ips = inline_template("<%= (ips+[vip]+clients).uniq.delete_if {|x| x.empty? }.join(',') %>") # $src = "${source_ips}" ? { # '' => "${zone}", # default => "${zone}:${source_ips}", # } #$endport = inline_template('<%= 24009+hosts.count %>') #$nfs_endport = inline_template('<%= 38465+hosts.count %>') #shorewall::rule { 'gluster-24000': # rule => " # ACCEPT ${src} $FW tcp 24009:${endport} # ", # comment => 'Allow 24000s for gluster', # before => Service['glusterd'], #} #if $nfs { # FIXME: TODO # shorewall::rule { 'gluster-nfs': rule => " # ACCEPT $(src} $FW tcp 38465:${nfs_endport} # ", comment => 'Allow nfs for gluster'} #} } # start service only after the firewall is opened and hosts are defined service { 'glusterd': enable => true, # start on boot ensure => running, # ensure it stays running hasstatus => false, # FIXME: BUG: https://bugzilla.redhat.com/show_bug.cgi?id=836007 hasrestart => true, # use restart, not start; stop } } # vim: ts=8