Created
February 7, 2013 21:25
-
-
Save jrmoserbaltimore/4734311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# type gluster::peer | |
# Verifies a peer in the Gluster cluster | |
# | |
define gluster::peer( | |
$hostname, | |
) { | |
$peergrep = regsubst($hostname, '(\.)', '\\.', 'G') | |
# Do unless current system is peer | |
if ( $hostname != $::fqdn ) { | |
exec { "gluster probe $hostname": | |
path => '/bin:/sbin:/usr/bin:/usr/sbin', | |
onlyif => "! (gluster peer status | egrep -q '$peergrep')" | |
provider => shell, | |
} | |
} | |
Service <| tags == 'gluster' |> -> | |
Exec ["gluster probe $hostname"] | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# peer/prune.pp | |
# class gluster::peer::prune | |
# Prunes all not-peers in the cluster | |
# | |
class gluster::peer::prune { | |
$peers = $::gluster::peers | |
$peergrep = regsubst(join($peers, "|"), '(\.)', '\\.', 'G') | |
# egrep -v '(peer-1\.example\.com|peer-2\.example\.com)' | |
exec { "gluster peer status | egrep -v '($peergrep)' | awk '/^Hostname:/{print $2}' | xargs -n 1 gluster peer detach": | |
path => '/bin:/sbin:/usr/bin:/usr/sbin', | |
provider => shell, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment