From aaef306069ce4e38e3fbf8cb9c8635aaa587046e Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 12 Mar 2013 14:35:51 -0300 Subject: [PATCH] Override lxc default configs on dev boxes based on hostname to avoid conflicting IPs --- development/lxc-configs/lxc-dev-box | 37 +++++++++++++++++++ .../lxc-configs/{lxc-dev-default => vbox} | 0 development/site.pp | 8 ++-- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 development/lxc-configs/lxc-dev-box rename development/lxc-configs/{lxc-dev-default => vbox} (100%) diff --git a/development/lxc-configs/lxc-dev-box b/development/lxc-configs/lxc-dev-box new file mode 100644 index 0000000..36b401d --- /dev/null +++ b/development/lxc-configs/lxc-dev-box @@ -0,0 +1,37 @@ +############################################################################### +# This file has the same configs as the built in /etc/default/lxc on Ubuntu, +# we only changed IPs to 10.0.254.* to avoid collision with LXC default 10.0.3.* +# which is likely to be running from the host machine +############################################################################### + + +# MIRROR to be used by ubuntu template at container creation: +# Leaving it undefined is fine +#MIRROR="http://archive.ubuntu.com/ubuntu" +# or +#MIRROR="http://:3142/archive.ubuntu.com/ubuntu" + +# LXC_AUTO - whether or not to start containers symlinked under +# /etc/lxc/auto +LXC_AUTO="true" + +# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your +# containers. Set to "false" if you'll use virbr0 or another existing +# bridge, or mavlan to your host's NIC. +USE_LXC_BRIDGE="true" + +# If you change the LXC_BRIDGE to something other than lxcbr1, then +# you will also need to update your /etc/lxc/lxc.conf as well as the +# configuration (/var/lib/lxc//config) for any containers +# already created using the default config to reflect the new bridge +# name. +# If you have the dnsmasq daemon installed, you'll also have to update +# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. +LXC_BRIDGE="lxcbr0" +LXC_ADDR="10.0.253.1" +LXC_NETMASK="255.255.255.0" +LXC_NETWORK="10.0.253.0/24" +LXC_DHCP_RANGE="10.0.253.2,10.0.253.254" +LXC_DHCP_MAX="253" + +LXC_SHUTDOWN_TIMEOUT=120 diff --git a/development/lxc-configs/lxc-dev-default b/development/lxc-configs/vbox similarity index 100% rename from development/lxc-configs/lxc-dev-default rename to development/lxc-configs/vbox diff --git a/development/site.pp b/development/site.pp index fa64b55..94c0498 100644 --- a/development/site.pp +++ b/development/site.pp @@ -12,10 +12,10 @@ exec { # Overwrite LXC default configs exec { 'config-lxc': - # We need to do this otherwise IPs will collide with the host's lxc dhcp server. - # If we install the package prior to setting this configs the container will go crazy. - command => 'cp /vagrant/development/lxc-configs/lxc-dev-default /etc/default/lxc', - unless => 'grep -q "10.0.254" /etc/default/lxc' + # We need to do this otherwise IPs will collide with the host's lxc dhcp server. + # If we install the package prior to setting this configs the container will go crazy. + command => "cp /vagrant/development/lxc-configs/${hostname} /etc/default/lxc" + ; } # Install dependencies