diff options
author | James Shubin <james@shubin.ca> | 2013-12-31 17:15:11 -0500 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2013-12-31 17:33:52 -0500 |
commit | f533720ebe319a8120e9bbd8e1ef765fb7bf929f (patch) | |
tree | 83c334875791fa13e2f38d989b316c0c19cfacfc | |
parent | 2b1e94f559a5d952068ed1ffb5051ca0c6e6dd04 (diff) | |
download | puppet-gluster-f533720ebe319a8120e9bbd8e1ef765fb7bf929f.tar.gz puppet-gluster-f533720ebe319a8120e9bbd8e1ef765fb7bf929f.tar.xz puppet-gluster-f533720ebe319a8120e9bbd8e1ef765fb7bf929f.zip |
Update template variables to use the '@' prefix.
I've updated wrapper.pp too, but I haven't tested it recently.
-rw-r--r-- | manifests/brick.pp | 2 | ||||
-rw-r--r-- | manifests/simple.pp | 2 | ||||
-rw-r--r-- | manifests/volume.pp | 32 | ||||
-rw-r--r-- | manifests/volume/property.pp | 2 | ||||
-rw-r--r-- | manifests/wrapper.pp | 22 | ||||
-rw-r--r-- | templates/glusterd.info.erb | 6 |
6 files changed, 33 insertions, 33 deletions
diff --git a/manifests/brick.pp b/manifests/brick.pp index 8ab9241..bbaf707 100644 --- a/manifests/brick.pp +++ b/manifests/brick.pp @@ -151,7 +151,7 @@ define gluster::brick( # put all the options in an array, remove the empty ones, and join with # commas (this removes ',,' double comma uglyness) # adding 'defaults' here ensures no ',' (leading comma) in mount command - $mount_options = inline_template('<%= (["defaults"]+options_list).delete_if {|x| x.empty? }.join(",") %>') + $mount_options = inline_template('<%= (["defaults"]+@options_list).delete_if {|x| x.empty? }.join(",") %>') $exec_noop = $areyousure ? { true => false, diff --git a/manifests/simple.pp b/manifests/simple.pp index c750196..2078c85 100644 --- a/manifests/simple.pp +++ b/manifests/simple.pp @@ -91,7 +91,7 @@ class gluster::simple( # the gluster_fqdns fact is alphabetical, but not complete till # at least a puppet run of each node has occured. watch out for # partial clusters missing some of the nodes with bad ordering! - #bricks => split(inline_template("<%= gluster_fqdns.split(',').collect {|x| x+':${valid_path}' }.join(',') %>"), ','), + #bricks => split(inline_template("<%= @gluster_fqdns.split(',').collect {|x| x+':${valid_path}' }.join(',') %>"), ','), # the only semi-safe way is the new built in automatic collect: bricks => true, # automatic brick collection... start => true, diff --git a/manifests/volume.pp b/manifests/volume.pp index 5058d24..8fa6e2c 100644 --- a/manifests/volume.pp +++ b/manifests/volume.pp @@ -86,7 +86,7 @@ define gluster::volume( } # helpful debugging! - notice(inline_template('valid_bricks: <%= valid_bricks.inspect %>')) + notice(inline_template('valid_bricks: <%= @valid_bricks.inspect %>')) # NOTE: we're using the valid_bricks value here, and not the collected # value. while we only need the $collected value for settle detection, @@ -111,21 +111,21 @@ define gluster::volume( $stack_full = split("${stack_fact}", ',') $stack_trim = "${maxlength}" ? { '-1' => $stack_full, # unlimited - #default => split(inline_template('<%= stack_full[0,maxlength.to_i.abs].join(",") %>'), ','), - default => split(inline_template('<%= stack_full[[stack_full.size-maxlength.to_i.abs,0].max,maxlength.to_i.abs].join(",") %>'), ','), + #default => split(inline_template('<%= @stack_full[0,@maxlength.to_i.abs].join(",") %>'), ','), + default => split(inline_template('<%= @stack_full[[@stack_full.size-@maxlength.to_i.abs,0].max,@maxlength.to_i.abs].join(",") %>'), ','), } $watch_fact = getvar("gluster_volume_fsm_watch_${name}") # fact ! $watch_full = split("${watch_fact}", ',') $watch_trim = "${maxlength}" ? { '-1' => $watch_full, # unlimited - #default => split(inline_template('<%= watch_full[0,maxlength.to_i.abs].join(",") %>'), ','), - default => split(inline_template('<%= watch_full[[watch_full.size-maxlength.to_i.abs,0].max,maxlength.to_i.abs].join(",") %>'), ','), + #default => split(inline_template('<%= @watch_full[0,@maxlength.to_i.abs].join(",") %>'), ','), + default => split(inline_template('<%= @watch_full[[@watch_full.size-@maxlength.to_i.abs,0].max,@maxlength.to_i.abs].join(",") %>'), ','), } # if the last $settle_count elements are the same, the template # should reduce down to the value '1'. check this and the size. - $one = inline_template('<%= watch_trim[[watch_trim.size-settle_count.to_i,0].max,settle_count.to_i].uniq.size %>') + $one = inline_template('<%= @watch_trim[[@watch_trim.size-@settle_count.to_i,0].max,@settle_count.to_i].uniq.size %>') $watch_trim_size = size($watch_trim) $settled = ((! $settle_count_check) or ((size($watch_trim) >= $settle_count) and "${one}" == '1')) @@ -152,7 +152,7 @@ define gluster::volume( } # returns interface name that has vip, or '' if none are found. - $vipif = inline_template("<%= interfaces.split(',').find_all {|x| '${valid_vip}' == scope.lookupvar('ipaddress_'+x) }[0,1].join('') %>") + $vipif = inline_template("<%= @interfaces.split(',').find_all {|x| '${valid_vip}' == scope.lookupvar('ipaddress_'+x) }[0,1].join('') %>") #Gluster::Brick[$valid_bricks] -> Gluster::Volume[$name] # volume requires bricks @@ -160,7 +160,7 @@ define gluster::volume( # return only these paths, which can be used to build the volume dirs. # NOTE: gluster v3.4 won't create a volume if this dir already exists. # TODO: is this needed when bricks are devices and not on filesystem ? - #$volume_dirs = split(inline_template("<%= valid_bricks.find_all{|x| x.split(':')[0] == '${fqdn}' }.collect {|y| y.split(':')[1].chomp('/')+'/${name}' }.join(' ') %>"), ' ') + #$volume_dirs = split(inline_template("<%= @valid_bricks.find_all{|x| x.split(':')[0] == '${fqdn}' }.collect {|y| y.split(':')[1].chomp('/')+'/${name}' }.join(' ') %>"), ' ') #file { $volume_dirs: # ensure => directory, # make sure this is a directory # recurse => false, # don't recurse into directory @@ -171,7 +171,7 @@ define gluster::volume( #} # add /${name} to the end of each: brick:/path entry - $brick_spec = inline_template("<%= valid_bricks.collect {|x| ''+x.chomp('/')+'/${name}' }.join(' ') %>") + $brick_spec = inline_template("<%= @valid_bricks.collect {|x| ''+x.chomp('/')+'/${name}' }.join(' ') %>") # if volume creation fails for a stupid reason, in many cases, glusterd # already did some of the work and left us with volume name directories @@ -180,10 +180,10 @@ define gluster::volume( # we error we should rmdir any empty volume dirs to keep it pristine... # TODO: this should be a gluster bug... we must hope it doesn't happen! # maybe related to: https://bugzilla.redhat.com/show_bug.cgi?id=835494 - $rmdir_volume_dirs = sprintf("/bin/rmdir '%s'", inline_template("<%= valid_bricks.find_all{|x| x.split(':')[0] == '${fqdn}' }.collect {|y| y.split(':')[1].chomp('/')+'/${name}/' }.join('\' \'') %>")) + $rmdir_volume_dirs = sprintf("/bin/rmdir '%s'", inline_template("<%= @valid_bricks.find_all{|x| x.split(':')[0] == '${fqdn}' }.collect {|y| y.split(':')[1].chomp('/')+'/${name}/' }.join('\' \'') %>")) # get the list of bricks fqdn's that don't have our fqdn - $others = inline_template("<%= valid_bricks.find_all{|x| x.split(':')[0] != '${fqdn}' }.collect {|y| y.split(':')[0] }.join(' ') %>") + $others = inline_template("<%= @valid_bricks.find_all{|x| x.split(':')[0] != '${fqdn}' }.collect {|y| y.split(':')[0] }.join(' ') %>") $fping = sprintf("/usr/sbin/fping -q %s", $others) $status = sprintf("/usr/sbin/gluster peer status --xml | ${vardir}/xml.py connected %s", $others) @@ -303,7 +303,7 @@ define gluster::volume( $ips = $::gluster::server::ips # override host ip list $ip = $::gluster::host::data::ip # ip of brick's host... $source_ips = type($ips) ? { - 'array' => inline_template("<%= (ips+[]).uniq.delete_if {|x| x.empty? }.join(',') %>"), + 'array' => inline_template("<%= (@ips+[]).uniq.delete_if {|x| x.empty? }.join(',') %>"), default => ["${ip}"], } @@ -338,13 +338,13 @@ define gluster::volume( $diff = "/usr/bin/test '${valid_input}' != '${valid_last}'" $stack_truncate = "${maxlength}" ? { '-1' => '', # unlimited - #default => sprintf("&& /bin/sed -i '%d,$ d' ${stackfile}", inline_template('<%= maxlength.to_i.abs+1 %>')), - default => sprintf(" && (/bin/grep -v '^$' ${stackfile} | /usr/bin/tail -n %d | /usr/bin/sponge ${stackfile})", inline_template('<%= maxlength.to_i.abs %>')), + #default => sprintf("&& /bin/sed -i '%d,$ d' ${stackfile}", inline_template('<%= @maxlength.to_i.abs+1 %>')), + default => sprintf(" && (/bin/grep -v '^$' ${stackfile} | /usr/bin/tail -n %d | /usr/bin/sponge ${stackfile})", inline_template('<%= @maxlength.to_i.abs %>')), } $watch_truncate = "${maxlength}" ? { '-1' => '', # unlimited - #default => sprintf("&& /bin/sed -i '%d,$ d' ${watchfile}", inline_template('<%= maxlength.to_i.abs+1 %>')), - default => sprintf(" && (/bin/grep -v '^$' ${watchfile} | /usr/bin/tail -n %d | /usr/bin/sponge ${watchfile})", inline_template('<%= maxlength.to_i.abs %>')), + #default => sprintf("&& /bin/sed -i '%d,$ d' ${watchfile}", inline_template('<%= @maxlength.to_i.abs+1 %>')), + default => sprintf(" && (/bin/grep -v '^$' ${watchfile} | /usr/bin/tail -n %d | /usr/bin/sponge ${watchfile})", inline_template('<%= @maxlength.to_i.abs %>')), } if $are_bricks_collected and ("${valid_input}" != '') { # ready or not? diff --git a/manifests/volume/property.pp b/manifests/volume/property.pp index e8d93ec..f0b8add 100644 --- a/manifests/volume/property.pp +++ b/manifests/volume/property.pp @@ -74,7 +74,7 @@ define gluster::volume::property( $jchar = '' } - $safe_value = inline_template('<%= value.join(jchar) %>') + $safe_value = inline_template('<%= @value.join(jchar) %>') #} elsif ... { # TODO: add more conversions here if needed } else { diff --git a/manifests/wrapper.pp b/manifests/wrapper.pp index d7ade6c..54156de 100644 --- a/manifests/wrapper.pp +++ b/manifests/wrapper.pp @@ -29,8 +29,8 @@ class gluster::wrapper( # build gluster::server # - $hosts = split(inline_template("<%= nodetree.keys.join(',') %>"), ',') - $ips = split(inline_template('<%= nodetree.map{ |host,value| \'#{value["ip"]}\' }.join(",") %>'), ',') + $hosts = split(inline_template("<%= @nodetree.keys.join(',') %>"), ',') + $ips = split(inline_template('<%= @nodetree.map{ |host,value| \'#{value["ip"]}\' }.join(",") %>'), ',') class { 'gluster::server': hosts => $hosts, @@ -54,8 +54,8 @@ class gluster::wrapper( # filter the nodetree so that only host elements with uuid's are left # XXX: each_with_object doesn't exist in rhel6 ruby, so use inject - #$hosttree = inline_template('<%= nodetree.each_with_object({}) {|(x,y), h| h[x] = y.select{ |key,value| ["uuid"].include?(key) } }.to_yaml %>') - $hosttree = inline_template('<%= nodetree.inject({}) {|h, (x,y)| h[x] = y.select{ |key,value| ["uuid"].include?(key) }; h }.to_yaml %>') + #$hosttree = inline_template('<%= @nodetree.each_with_object({}) {|(x,y), h| h[x] = y.select{ |key,value| ["uuid"].include?(key) } }.to_yaml %>') + $hosttree = inline_template('<%= @nodetree.inject({}) {|h, (x,y)| h[x] = y.select{ |key,value| ["uuid"].include?(key) }; h }.to_yaml %>') # newhash = oldhash.inject({}) { |h,(k,v)| h[k] = some_operation(v); h } # XXX: does this form work ? $yaml_host = parseyaml($hosttree) create_resources('gluster::host', $yaml_host) @@ -76,9 +76,9 @@ class gluster::wrapper( #} # filter the nodetree and build out each brick element from the hosts - $bricktree = inline_template('<%= r = {}; nodetree.each {|x,y| y["bricks"].each {|k,v| r[x+":"+k] = v} }; r.to_yaml %>') + $bricktree = inline_template('<%= r = {}; @nodetree.each {|x,y| y["bricks"].each {|k,v| r[x+":"+k] = v} }; r.to_yaml %>') # this version removes any invalid keys from the brick specifications - #$bricktree = inline_template('<%= r = {}; nodetree.each {|x,y| y["bricks"].each {|k,v| r[x+":"+k] = v.select{ |key,value| ["dev", "labeltype", "fstype", "fsuuid", "..."].include?(key) } } }; r.to_yaml %>') + #$bricktree = inline_template('<%= r = {}; @nodetree.each {|x,y| y["bricks"].each {|k,v| r[x+":"+k] = v.select{ |key,value| ["dev", "labeltype", "fstype", "fsuuid", "..."].include?(key) } } }; r.to_yaml %>') $yaml_brick = parseyaml($bricktree) create_resources('gluster::brick', $yaml_brick) @@ -94,7 +94,7 @@ class gluster::wrapper( #} # to be used as default gluster::volume brick list - $bricklist = split(inline_template("<%= bricktree.keys.join(',') %>"), ',') + $bricklist = split(inline_template("<%= @bricktree.keys.join(',') %>"), ',') # semi ok method: #$volumetree_defaults_all = { @@ -105,7 +105,7 @@ class gluster::wrapper( # "vip" => $vip, # "start" => undef, # ? #} - #$semi_ok = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x] = volumetree_defaults_all.each_with_object({}) {|(xx,yy), hh| hh[xx] = y.fetch(xx, volumetree_defaults_all[xx])} }.to_yaml %>') + #$semi_ok = inline_template('<%= @volumetree.each_with_object({}) {|(x,y), h| h[x] = @volumetree_defaults_all.each_with_object({}) {|(xx,yy), hh| hh[xx] = y.fetch(xx, @volumetree_defaults_all[xx])} }.to_yaml %>') # good method $volumetree_defaults = { @@ -113,7 +113,7 @@ class gluster::wrapper( 'vip' => $vip, } # loop through volumetree... if special defaults are missing, then add! - $volumetree_updated = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x] = y; volumetree_defaults.each {|k,v| h[k] = h.fetch(k, v)} }.to_yaml %>') + $volumetree_updated = inline_template('<%= @volumetree.each_with_object({}) {|(x,y), h| h[x] = y; @volumetree_defaults.each {|k,v| h[k] = h.fetch(k, v)} }.to_yaml %>') $yaml_volume = parseyaml($volumetree_updated) create_resources('gluster::volume', $yaml_volume) @@ -126,8 +126,8 @@ class gluster::wrapper( # value => '192.0.2.13,198.51.100.42,203.0.113.69', #} - #$simplewrongname = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x+"#auth.allow"] = y.select{ |key,value| ["clients"].include?(key) } }.to_yaml %>') - $propertytree = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x+"#auth.allow"] = { "value" => y.fetch("clients", []) } }.to_yaml %>') + #$simplewrongname = inline_template('<%= @volumetree.each_with_object({}) {|(x,y), h| h[x+"#auth.allow"] = y.select{ |key,value| ["clients"].include?(key) } }.to_yaml %>') + $propertytree = inline_template('<%= @volumetree.each_with_object({}) {|(x,y), h| h[x+"#auth.allow"] = { "value" => y.fetch("clients", []) } }.to_yaml %>') $yaml_volume_property = parseyaml($propertytree) create_resources('gluster::volume::property', $yaml_volume_property) } diff --git a/templates/glusterd.info.erb b/templates/glusterd.info.erb index a02a379..94acebc 100644 --- a/templates/glusterd.info.erb +++ b/templates/glusterd.info.erb @@ -1,4 +1,4 @@ -UUID=<%= valid_uuid %> -<% if operating_version != '' and operating_version != '-1' -%> -operating-version=<%= operating_version %> +UUID=<%= @valid_uuid %> +<% if @operating_version != '' and @operating_version != '-1' -%> +operating-version=<%= @operating_version %> <% end -%> |