flix-tech / vagrant-kubernetes

A simple Kubernetes all-in-one box for development based on Debian Jessie
https://atlas.hashicorp.com/flixtech/boxes/kubernetes
Apache License 2.0
61 stars 23 forks source link

Automatically add route on box start #5

Open hanikesn opened 7 years ago

hanikesn commented 7 years ago

People often forget adding the route or have typos in their command. Therefore the box should add the correct routes automatically (with the option to turn that off).

mente commented 7 years ago

Automatic provision on start?

hanikesn commented 7 years ago

It's not really provisioning as the route command needs to be executed on the host itself with sudo.

ph-teven commented 7 years ago

maybe this would help. put this in your Vagrantfile.

module LocalCommand
    class Config < Vagrant.plugin("2", :config)
        attr_accessor :command
    end

    class Plugin < Vagrant.plugin("2")
        name "local_shell"

        config(:local_shell, :provisioner) do
            Config
        end

        provisioner(:local_shell) do
            Provisioner
        end
    end

    class Provisioner < Vagrant.plugin("2", :provisioner)
        def provision
            result = system "#{config.command}"
        end
    end
end
k8s.vm.provision "access",
            type: "local_shell",
            command: "#route command#",
            run: 'always'