Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling first volume creation on Puppet > 4 #24

Merged
merged 1 commit into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions manifests/peer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,20 @@

# and we don't want to attach a server that is already a member
# of the current pool
$peers = split($::gluster_peer_list, ',' )
if ! member($peers, $title) {
exec { "gluster peer probe ${title}":
command => "${binary} peer probe ${title}",
if $::gluster_peer_list != undef {
$peers = split($::gluster_peer_list, ',' )
if ! member($peers, $title) {
$already_in_pool = false
} else {
$already_in_pool = true
}
} else {
$already_in_pool = false
}
if !$already_in_pool {
exec { "gluster peer probe ${title}":
command => "${binary} peer probe ${title}",
}
}
}
}
Expand Down
24 changes: 18 additions & 6 deletions manifests/volume.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,19 @@
if $binary{
# we need the Gluster binary to do anything!

if ! member( split( $::gluster_volume_list, ',' ), $title ) {
if $::gluster_peer_list != undef{
$minimal_requirements = true
} else {
$minimal_requirements = false
}

if $::gluster_volume_list != undef and member( split( $::gluster_volume_list, ',' ), $title ) {
$already_exists = true
} else {
$already_exists = false
}

if $minimal_requirements and $already_exists == false {
# this volume has not yet been created

# before we can create it, we need to ensure that all the
Expand Down Expand Up @@ -139,7 +151,7 @@
# volume:option
$vol_opts = prefix( $_options, "${title}:" )
# now we make some YAML, and then parse that to get a Puppet hash
$yaml = join( regsubst( $vol_opts, ': ', ":\n value: ", G), "\n")
$yaml = join( regsubst( $vol_opts, ': ', ":\n value: ", 'G'), "\n")
$hoh = parseyaml($yaml)

# safety check
Expand All @@ -161,7 +173,7 @@
}
}

} else {
} elsif $already_exists {
# this volume exists

# our fact lists bricks comma-separated, but we need an array
Expand All @@ -179,7 +191,7 @@
# number of bricks to add is a factor of that value
if $stripe {
if ( count($new_bricks) % $stripe ) != 0 {
fail("Number of bricks to add is not a multiple of stripe count ${stipe}")
fail("Number of bricks to add is not a multiple of stripe count ${stripe}")
}
$s = "stripe ${stripe}"
} else {
Expand Down Expand Up @@ -256,7 +268,7 @@
# so build up the hash correctly
#
$remove_opts = prefix( $to_remove, "${title}:" )
$remove_yaml = join( regsubst( $remove_opts, ': .+$', ":\n ensure: absent", G ), "\n" )
$remove_yaml = join( regsubst( $remove_opts, ': .+$', ":\n ensure: absent", 'G' ), "\n" )
$remove = parseyaml($remove_yaml)
if $remove_options {
create_resources( ::gluster::volume::option, $remove )
Expand All @@ -268,7 +280,7 @@
if ! empty($to_add) {
# we have some options defined that are not active. Add them
$add_opts = prefix( $to_add, "${title}:" )
$add_yaml = join( regsubst( $add_opts, ': ', ":\n value: ", G ), "\n" )
$add_yaml = join( regsubst( $add_opts, ': ', ":\n value: ", 'G' ), "\n" )
$add = parseyaml($add_yaml)
create_resources( ::gluster::volume::option, $add )
}
Expand Down