Skip to content

Instantly share code, notes, and snippets.

@jrmoserbaltimore
Created February 7, 2013 21:25
Show Gist options
  • Save jrmoserbaltimore/4734311 to your computer and use it in GitHub Desktop.
Save jrmoserbaltimore/4734311 to your computer and use it in GitHub Desktop.
# 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"]
}
# 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