Set IPs on vagrant-lxc VMs

Cross-communication is always nice.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.define "web", primary: true do |web|
    web.vm.box = "quantal64"
    web.vm.provider :lxc do |lxc|
      lxc.customize 'network.ipv4', '10.0.3.100/32'
    end
  end

  config.vm.define "db" do |db|
    db.vm.box = "quantal64"
    db.vm.provider :lxc do |lxc|
      lxc.customize 'network.ipv4', '10.0.3.101/32'
    end
  end

end


FYI, versioning info:

vagrant -v
Vagrant 1.3.3

vagrant plugin list
vagrant-lxc (0.6.0)

Comments

  1. If you use "config.vm.hostname", the ip will defined will be deleted.
    That is because setting the hostname makes:
    comm.sudo("ifdown -a; ifup -a; ifup -a --allow=hotplug")
    https://github.com/mitchellh/vagrant/blob/079a6edade732f13f42d266c8536d437a521154e/plugins/guests/ubuntu/cap/change_host_name.rb

    And that command deletes our defined ip.

    ReplyDelete
  2. Another approach:
    Vagrantfile:
    config.vm.provision "shell", inline: "/sbin/ip addr add 10.0.3.100/32 dev eth0"


    vagrant provision puppetmaster --provision-with shell

    ReplyDelete

Post a Comment

Popular posts from this blog

Openvpn and unbound combined break dig command

Stress Linux system: stress-ng

Google Nexus 4: permanent back panel glass repair for less than a penny