diff --git a/CHANGELOG.md b/CHANGELOG.md index e005000..c6af3fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [0.6.5](https://github.com/fgrehm/vagrant-lxc/compare/v0.6.4...master) (unreleased) +IMPROVEMENTS: + + - Warn users about unsupported private / public networking configs [#154](https://github.com/fgrehm/vagrant-lxc/issues/154) + BUG FIXES: - Error out in case an invalid IPs are provided for forwarded ports [#170](https://github.com/fgrehm/vagrant-lxc/issues/170) diff --git a/lib/vagrant-lxc/action.rb b/lib/vagrant-lxc/action.rb index 4db1a17..625646c 100644 --- a/lib/vagrant-lxc/action.rb +++ b/lib/vagrant-lxc/action.rb @@ -18,6 +18,7 @@ require 'vagrant-lxc/action/message' require 'vagrant-lxc/action/remove_temporary_files' require 'vagrant-lxc/action/setup_package_files' require 'vagrant-lxc/action/share_folders' +require 'vagrant-lxc/action/warn_networks' unless Vagrant::LXC.vagrant_1_3_or_later require 'vagrant-lxc/action/wait_for_communicator' @@ -58,6 +59,7 @@ module Vagrant b.use Builtin::HandleForwardedPortCollisions b.use ShareFolders b.use Builtin::SetHostname + b.use WarnNetworks b.use ForwardPorts b.use Boot b.use Builtin::WaitForCommunicator diff --git a/lib/vagrant-lxc/action/warn_networks.rb b/lib/vagrant-lxc/action/warn_networks.rb new file mode 100644 index 0000000..f060080 --- /dev/null +++ b/lib/vagrant-lxc/action/warn_networks.rb @@ -0,0 +1,25 @@ +module Vagrant + module LXC + module Action + class WarnNetworks + def initialize(app, env) + @app = app + end + + def call(env) + if public_or_private_network_configured? + env[:ui].warn(I18n.t("vagrant_lxc.messages.warn_networks")) + end + + @app.call(env) + end + + def public_or_private_network_configured? + config.vm.networks.find do |type| + [:private_network, :public_network].include?(type.to_sym) + end + end + end + end + end +end diff --git a/locales/en.yml b/locales/en.yml index 237881b..2b6f519 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -17,6 +17,10 @@ en: Waiting for container to start. This should not take long. container_ready: |- Container started and ready for use! + warn_networks: |- + Warning! The LXC provider doesn't support any of the Vagrant public / private + network configurations (`config.vm.network :private_network, ip: "some-ip"`). + They will be silently ignored. vagrant: commands: