Created
February 5, 2011 05:36
-
-
Save mbbx6spp/812241 to your computer and use it in GitHub Desktop.
Riak cluster Vagrantfile to offer an alternative to Basho Chef+Vagrant blog post suggestion and receive feedback at http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Offering alternative Chef + Vagrant Riak cluster setup to the following blog post at basho: | |
# http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/ | |
# Assumes Vagrant 0.7.0+ and VirtualBox 4.0+ | |
# Now you should be able to launch your X (where X=4 in this case) vagrant VMs with the following: | |
# % vagrant up db1 | |
# % vagrant up db2 | |
# % vagrant up db3 | |
# % vagrant up db4 | |
# % vagrant up webapp | |
Vagrant::Config.run do |config| | |
config.ssh.username = "sudoableuser" | |
config.ssh.max_tries = 25 | |
config.vm.share_folder "tint", "/releases", "rel", :auto => true | |
config.vm.share_folder "chef", "/vm/root/path", "your/chef/root", :auto => true | |
(1..4).each do |index| | |
config.vm.define "db#{index}".to_sym do |cfg| | |
cfg.vm.box = "my-server-box" | |
cfg.vm.host_name = "db#{index}" | |
cfg.vm.customize do |vm| | |
vm.name = "My Riak DB#{index} VM" | |
vm.memory_size = 512 | |
vm.network "33.33.33.#{index}" | |
vm.forward_port "ssh", 22, "220#{index}".to_i | |
end | |
cfg.vm.provision :chef_solo do |chef| | |
# fill in here, I usually use CHEF_ROOT="/var/tmp/chef" | |
chef.provisioning_path = "/path/to/chef/root" | |
chef.cookbooks_path = [:vm, "cookbooks"] | |
chef.roles_path = [:vm, "roles"] | |
chef.add_role :my_db | |
# HOSTS might be something like: ["app1", "app2", "app3"] | |
# DOMAIN would be something like: "mydomainname.tld" | |
# RELEASE_DIR would be something like: "/releases/name_of_otp_release" | |
chef.json.merge! :hosts => HOSTS, :domain => DOMAIN, | |
:release_dir => RELEASE_DIR | |
end | |
# add share_folder to share your webapp code below... | |
end | |
end | |
config.vm.define :webapp do |cfg| | |
cfg.vm.box = "my-server-box" | |
cfg.vm.host_name = "www" | |
cfg.vm.customize do |vm| | |
vm.name = "My WebApp VM" | |
vm.memory_size = 512 | |
vm.network "33.33.33.5" | |
vm.forward_port "ssh", 22, 2205 | |
end | |
cfg.vm.provision :chef_solo do |chef| | |
chef.provisioning_path = "/path/to/chef/root" | |
chef.cookbooks_path = [:vm, "cookbooks"] | |
chef.roles_path = [:vm, "roles"] | |
chef.add_role :my_db | |
# HOSTS might be something like: ["app1", "app2", "app3"] | |
# DOMAIN would be something like: "mydomainname.tld" | |
# RELEASE_DIR would be something like: "/releases/name_of_otp_release" | |
chef.json.merge! :hosts => HOSTS, :domain => DOMAIN, | |
:release_dir => RELEASE_DIR | |
end | |
# add share_folder to share your webapp code below... | |
end | |
end |
I just noticed the comment and realized I didn't include some important parts of my Vagrantfile. Will need to fix momentarily.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! Note that with host-only networking you have two interfaces, so you still need to specify the node name, otherwise it will be [email protected] (or similar), which will not be reachable by the other nodes.