diff options
-rw-r--r-- | manifests/simple.pp | 12 | ||||
-rw-r--r-- | vagrant/gluster/Vagrantfile | 10 | ||||
-rw-r--r-- | vagrant/gluster/puppet/manifests/site.pp | 1 |
3 files changed, 17 insertions, 6 deletions
diff --git a/manifests/simple.pp b/manifests/simple.pp index dbd43ed..0fa75da 100644 --- a/manifests/simple.pp +++ b/manifests/simple.pp @@ -129,21 +129,21 @@ class gluster::simple( if has_key($brick_params, "${::fqdn}") { # here some wizardry happens... $brick_params_list = $brick_params["${::fqdn}"] - $valid_count = $count ? { - 0 => inline_template('<%= @brick_params_list.length %>'), + $valid_count = "${count}" ? { + '0' => inline_template('<%= @brick_params_list.length %>'), default => $count, } validate_array($brick_params_list) $yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {'${::fqdn}:${valid_path}brick' + (i+1).to_s.rjust(7, '0') + '/' => ((i < @brick_params_list.length) ? @brick_params_list[i] : {})}.merge(h) }.to_yaml %>") } else { # here we base our brick list on the $count variable alone... - $valid_count = $count ? { - 0 => 1, # 0 means undefined, so use the default + $valid_count = "${count}" ? { + '0' => 1, # 0 means undefined, so use the default default => $count, } - $brick_params_list = $valid_count ? { + $brick_params_list = "${valid_count}" ? { # TODO: should we use the same pattern for 1 or many ? - 1 => ["${::fqdn}:${valid_path}"], + '1' => ["${::fqdn}:${valid_path}"], default => split(inline_template("<%= (1..@valid_count.to_i).collect{|i| '${::fqdn}:${valid_path}brick' + i.to_s.rjust(7, '0') + '/' }.join(',') %>"), ','), } $yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {@brick_params_list[i] => {}}.merge(h) }.to_yaml %>") diff --git a/vagrant/gluster/Vagrantfile b/vagrant/gluster/Vagrantfile index 00e58f7..a3162b9 100644 --- a/vagrant/gluster/Vagrantfile +++ b/vagrant/gluster/Vagrantfile @@ -59,6 +59,7 @@ offset = 100 # start gluster hosts after here # mutable by ARGV and settings file count = 4 # default number of gluster hosts to build +bricks = 0 # default number of bricks to build (0 defaults to 1) version = '' # default gluster version (empty string means latest!) firewall = false # default firewall enabled (FIXME: default to true when keepalived bug is fixed) replica = 1 # default replica count @@ -77,6 +78,7 @@ f = File.join(projectdir, 'puppet-gluster.yaml') if File.exist?(f) settings = YAML::load_file f count = settings[:count] + bricks = settings[:bricks] version = settings[:version] firewall = settings[:firewall] replica = settings[:replica] @@ -97,6 +99,12 @@ while skip < ARGV.length count = v.to_i # set gluster host count + elsif ARGV[skip].start_with?(arg='--gluster-bricks=') + v = ARGV.delete_at(skip).dup + v.slice! arg + + bricks = v.to_i # set gluster brick count + elsif ARGV[skip].start_with?(arg='--gluster-version=') v = ARGV.delete_at(skip).dup v.slice! arg @@ -157,6 +165,7 @@ end # save settings (ARGV overrides) settings = { :count => count, + :bricks => bricks, :version => version, :firewall => firewall, :replica => replica, @@ -417,6 +426,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| puppet.options = '--test' # see the output puppet.facter = { 'vagrant' => '1', + 'vagrant_gluster_bricks' => bricks.to_s, 'vagrant_gluster_replica' => replica.to_s, 'vagrant_gluster_layout' => layout, 'vagrant_gluster_setgroup' => setgroup, diff --git a/vagrant/gluster/puppet/manifests/site.pp b/vagrant/gluster/puppet/manifests/site.pp index 6a7a7c4..55183f5 100644 --- a/vagrant/gluster/puppet/manifests/site.pp +++ b/vagrant/gluster/puppet/manifests/site.pp @@ -53,6 +53,7 @@ node /^annex\d+$/ inherits default { # annex{1,2,..N} class { '::gluster::simple': volume => 'puppet', replica => "${::vagrant_gluster_replica}", + count => "${::vagrant_gluster_bricks}", # brick count layout => "${::vagrant_gluster_layout}", vip => "${::vagrant_gluster_vip}", # from vagrant version => "${::vagrant_gluster_version}", |