Override default network settings: lxc__bridge_name (KeyError)
Closed this issue · 4 comments
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: APP_HOST
config.vm.provider :parallels do |vb, override|
override.vm.box = "parallels/ubuntu-14.04"
end
config.vm.provider :lxc do |lxc, override|
override.vm.network "private_network", ip: "192.168.3.100", lxc__bridge_name: 'vlxcbr1'
override.vm.box = "fgrehm/trusty64-lxc"
end
end
Error message: ~/.vagrant.d/gems/gems/vagrant-lxc-1.1.0/lib/vagrant-lxc/action/private_networks.rb:31:in `fetch': key not found: :lxc__bridge_name (KeyError)
I think you can check and if bridge is not defined - setup it automatically. If bridge is exists you can raise error, or increase counter and use new bridge.
So when config.vm.network defined outer config.vm.provider :lxc block, I get following error:
==> default: Setting up private networks...
There was an error executing ["sudo", "/root/.vagrant.d/gems/gems/vagrant-lxc-1.1.0/scripts/pipework", "vlxcbr1", "vm", "192.168.2.100/24"]
For more information on the failure, enable detailed logging by setting
the environment variable VAGRANT_LOG to DEBUG .
stdout: Could not locate cgroup mount point.
Part 2:
When override.vm.network "private_network"
was removed, and configured port forwarding, I still got: key not found: :lxc__bridge_name (KeyError)
Really very strange behavior.
So when code is commented, and vm is removed, after port forwarding working without any problems.
Part 3:
Forwarding configuration:
config.vm.network :forwarded_port, guest: 8080, host: 8080
config.vm.network :forwarded_port, guest: 3306, host: 4306
Result:
root@ubuntu-sever:~/project# lxc-attach -n project -- curl -I http://localhost:8080
HTTP/1.0 200 OK
Date: Mon, 14 Sep 2015 18:15:40 GMT
Server: WSGIServer/0.1 Python/2.7.6
Vary: Cookie, Accept-Encoding
Content-Type: text/html; charset=utf-8
18:15:40 GMT; Max-Age=31449600; Path=/
root@ubuntu-sever:~/project# curl -I http://localhost:8080
curl: (56) Recv failure: Connection reset by peer
root@ubuntu-sever:~/project# nc -vz localhost 4306
nc: connect to localhost port 4306 (tcp) failed: Connection refused
Connection to localhost 4306 port [tcp/*] succeeded!
PS - Strange, but after host rebooting port is working fine.
This issue affects me too, as soon as I simply try to set a static IP with:
machine.vm.network "private_network", ip: "192.168.51.4"
I have vagrant 1.8.1, with vagrant-lxc 1.2.1.
@mwild1, you need to specify the bridge name explicitly:
Private Networks [EXPERIMENTAL]
Starting with vagrant-lxc 1.1.0, there is some rudimentary support for configuring
Private Networks
by leveraging the pipework project.On its current state, there is a requirement for setting the bridge name that
will be created and will allow your machine to comunicate with the containerFor example:
Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.2.100", lxc__bridge_name: 'vlxcbr1' endWill create a new
veth
device for the container and will set up (or reuse)
avlxcbr1
bridge between your machine and theveth
device. Once the last
vagrant-lxc container attached to the bridge getsvagrant halt
ed, the plugin
will delete the bridge.
(from the README.md)