$lxc_script = <<-SCRIPT

apt-get update

# install util for persistent ip tables
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
apt-get -y install iptables-persistent

# install lxc
apt-get install lxc lxc-templates wget bridge-utils jq -y
lxc-checkconfig

# configure lxc for specific CIDR network
touch /etc/lxc/dnsmasq.conf
sed -i s/10.0.3/172.40.231/g /etc/default/lxc-net
sed -i s/#LXC_DHCP_CONFILE/LXC_DHCP_CONFILE/g /etc/default/lxc-net
service lxc-net restart

# enable NTP
# use network time to make sure we are synchronised
echo "Disabling timesyncd..."
timedatectl set-ntp no
until timedatectl | grep -m 1 "Network time on: no";
do
  echo "Waiting for timesyncd to turn off.."
  sleep 1
done
apt-get install ntp
echo "timesync set to ntpd"

# set timezone to London
timedatectl set-timezone Europe/London

SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.provider "virtualbox" do |vb|
    vb.cpus = 4
    vb.memory = "8192"
  end

  #config.vm.network "forwarded_port", guest: 8888, host: 8888

  # Install lxc
  config.vm.provision :shell, inline: $lxc_script
end