Sha256: 087bd31717b4ef1da9d800b009205f1137b0945f71389fd29ce8eea80b2b579e
Contents?: true
Size: 1.7 KB
Versions: 4
Compression:
Stored size: 1.7 KB
Contents
module Clusterfuck class QuaggaBGPRouter < BGPPeer def build(config) super(config) config.vm.define(name) do |box| box.vm.provision :shell, inline: <<-EOS mkdir -p /tmp/quagga chown -R vagrant /tmp/quagga apt-get update apt-get -y install quagga EOS # TODO should be configured from BGP module if enabled # TODO have to move to /tmp/ first and then later to /etc/quagga because # Vagrant doens't copy as root. box.vm.provision :file, source: tmp_daemons_config, destination: "/tmp/quagga/daemons" box.vm.provision :file, source: tmp_bgp_config("../../../templates/quagga.zebra.conf.erb"), destination: "/tmp/quagga/zebra.conf" box.vm.provision :file, source: tmp_bgp_config("../../../templates/quagga.bgpd.conf.erb"), destination: "/tmp/quagga/bgpd.conf" box.vm.provision :shell, inline: <<-EOS echo net.ipv4.ip_forward=1 > /etc/sysctl.d/60-clusterfuck.conf sysctl -p /etc/sysctl.d/60-clusterfuck.conf mv /tmp/quagga/* /etc/quagga chown quagga.quagga /etc/quagga/*.conf chmod 640 /etc/quagga/*.conf service quagga restart EOS end end private # TODO clean up these messy functions def tmp_daemons_config File.expand_path("../../../templates/quagga.daemons", __FILE__) end def tmp_bgp_config(template) temp = Tempfile.new("routes") ObjectSpace.undefine_finalizer(temp) # finalizer removes it, nthx temp.write(bgp_config(template)) temp.flush temp.path end def bgp_config(template) path = File.expand_path(template, __FILE__) ERB.new(File.read(path)).result(binding) end end end
Version data entries
4 entries across 4 versions & 1 rubygems