ruby - block function until it finishes returning. -



ruby - block function until it finishes returning. -

cluster_size = 5 def build_namenode_box( config ) vmname = "namenode" config.vm.define vmname.to_sym |namenode| namenode.vm.box = "dummy" namenode.vm.provision :chef_solo, preserve_order: true |chef| chef.cookbooks_path = "cookbooks" chef.roles_path = "roles" chef.add_role "test" chef.data_bags_path = "data_bags" chef.add_recipe "cloudera::namenode" chef.add_recipe "cloudera-cluster" end namenode.vm.provision :hostmanager namenode.vm.provision :shell, :inline => $script end end def build_slaves_boxes( config, cluster_size ) (1..cluster_size).each |i| vmname = "slave#{i}" config.vm.define vmname.to_sym |slave| slave.vm.box = "dummy" slave.vm.provision :chef_solo, preserve_order: true |chef| chef.cookbooks_path = "cookbooks" chef.roles_path = "roles" chef.add_role "test" chef.data_bags_path = "data_bags" chef.add_recipe "cloudera::datanode" chef.add_recipe "cloudera-cluster" end slave.vm.provision :shell, :inline => $slavescript end end end vagrant.configure("2") |config| config.omnibus.chef_version = :latest config.vm.provider :aws |aws, override| config.vm.box = "dummy" aws.access_key_id = "myid" aws.secret_access_key = "my_key" aws.keypair_name = "my_key" aws.ami = "ami-7747d01e" aws.security_groups = ["my_group"] override.ssh.username = "ubuntu" override.ssh.private_key_path = "#{current_dir}/my_key.pem" end config.vm.provider :virtualbox |v| config.vm.box = "precise64" config.vm.box_url = "https://vagrantcloud.com/chef/ubuntu-12.04/version/1/provider/virtualbox.box" v.customize ["modifyvm", :id, "--memory", "1024"] end #block programme until returns. build_namenode_box( config ) # have wait until build_namenode_box() returns build_slaves_boxes( config, cluster_size ) end

i'm building vagrantfile (in ruby) create cloudera hadoop cluster. problem creating following: vagrant doesn't enforce order (don't wait until order defined vm's finish execution). need wait until namenode finished, because datanodes in slaves started before jobtracker. solution? block build_namenode_box() function until finished. i'm raw in ruby, how can write function blocker waits until build_namenode_box() homecoming before executing build_slaves_boxes() function? how can utilize yield accomplish that?

this isn't possible in plain vagrant, noted doesn't back upwards inter-vm dependencies. can @ using either external script calls vagrant $name in right order or more complex chef-metal manage provisioning.

ruby chef vagrantfile

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -