diff --git a/manifests/peer.pp b/manifests/peer.pp index cd490af3..35465a6d 100644 --- a/manifests/peer.pp +++ b/manifests/peer.pp @@ -56,12 +56,23 @@ # 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}", + } } + } } } diff --git a/manifests/volume.pp b/manifests/volume.pp index 6a709748..a0920116 100644 --- a/manifests/volume.pp +++ b/manifests/volume.pp @@ -101,8 +101,20 @@ $binary = $::gluster_binary if $binary{ # we need the Gluster binary to do anything! + + 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 ! member( split( $::gluster_volume_list, ',' ), $title ) { + 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 @@ -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 @@ -161,7 +173,7 @@ } } - } else { + } elsif $already_exists { # this volume exists # our fact lists bricks comma-separated, but we need an array @@ -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 { @@ -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 ) @@ -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 ) }