Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define vars on multi VM Vagrant file #407

Open
macklus opened this issue Oct 31, 2014 · 4 comments
Open

Define vars on multi VM Vagrant file #407

macklus opened this issue Oct 31, 2014 · 4 comments

Comments

@macklus
Copy link

macklus commented Oct 31, 2014

Hi:

I use Vagrant to work with 3-4 VMs. I try Vaprobash and really like it, but i dont know how can i define vars (as mysql_root_password) inside a VM config block, and not in global block

is this possible?

Thanks in advance

@fideloper
Copy link
Owner

My Ruby is a bit limited, but I think using some Ruby objects for each server might be appropriate. That would mean editing the Vagrantfile to contain or include other objects, then using those for each VM.

Overall, however, I'd recommend using something more fancy. Consider using Ansible to setup each server. That would allow you to have one configuration usable for each VM in your "cluster". (Ansible can configure them all based on roles, or can make three duplicate servers - really any combo you might need).

@macklus
Copy link
Author

macklus commented Nov 3, 2014

Hi
I wish to keep it simple, so use ruby objects are better option than deploy throught Ansible or Puppet.
Maybe can you put here an example of how works on Ruby objects to do that?

Really thanks.

@fideloper
Copy link
Owner

Can you show your Vagrantfile so I can see how you setup provisioning multiple servers?

@macklus
Copy link
Author

macklus commented Nov 3, 2014

Simple sample of Vagrant file:

Vagrant.configure("2") do |config|

  # 
  config.vm.define "video" do |video|
    video.vm.box = "ubuntu/trusty64"
    video.vm.network "public_network", ip: "192.168.1.201", bridge: 'wlan0'
    video.vm.synced_folder "/home/macklus/desarrollo/videomensajes.net", "/home/vagrant/"

    video.vm.hostname = "videomensajes.local"

    video.vm.provider :virtualbox do |vb|
      vb.name = "videomensajes"
      vb.customize ["modifyvm", :id, "--memory", 2048]
    end

    # Provision
    video.vm.provision "shell", path: "scripts/base.sh", args: ["", "512", "UTC"]
    video.vm.provision "shell", path: "scripts/base_box_optimizations.sh", privileged: true
    video.vm.provision "shell", path: "scripts/php.sh", args: ["UTC", "false"]
    video.vm.provision "shell", path: "scripts/nginx.sh", args: ["192.168.1.221", "/home/vagrant/public_html", "videomensajes.local", ""]
    video.vm.provision "shell", path: "scripts/mariadb.sh", args: ["root", "true"]
    video.vm.provision "shell", path: "scripts/screen.sh"
    video.vm.provision "shell", path: "scripts/mailcatcher.sh"

  end
end

Is this enought ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants