diff --git a/Vagrantfile b/Vagrantfile index 088d868..5479799 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -27,6 +27,14 @@ if defined? antidote_config['vm_config']['provider'] then ENV['VAGRANT_DEFAULT_PROVIDER'] = antidote_config['vm_config']['provider'] end +# Allow customization of the option passed to the selfmedicate.sh provisionning script +if defined? antidote_config['selfmedicate_prefs']['PRELOADED_IMAGES'] then + ENV['SELFMEDICATE_PRELOADED_IMAGES'] = antidote_config['selfmedicate_prefs']['PRELOADED_IMAGES'].join(' ') +end +if antidote_config['selfmedicate_prefs']['KUBERNETES_VERSION'] then + ENV['KUBERNETES_VERSION'] = antidote_config['selfmedicate_prefs']['KUBERNETES_VERSION'] +end + ## Configure VAGRANT Variables trimmed_version = antidote_config['version'].to_s.tr('.','') antidote_config['hostname'] = "antidote-#{trimmed_version}" @@ -104,11 +112,11 @@ Vagrant.configure("2") do |config| # Provisioning antidote vagrant vm # This will install docker, kubectl and minikube - config.vm.provision "default", type: "shell", path: "vagrant-provision.sh", env: {CHANGE_MINIKUBE_NONE_USER: true} + config.vm.provision "default", type: "shell", path: "vagrant-provision.sh", env: {CHANGE_MINIKUBE_NONE_USER: true, "K8SVERSION" => ENV['KUBERNETES_VERSION']} # Running initial selfmedicate script as the Vagrant user. $script = "/bin/bash --login $HOME/selfmedicate.sh start" - config.vm.provision "custom", type: "shell", privileged: false, inline: $script + config.vm.provision "custom", type: "shell", privileged: false, inline: $script, env: {"PRELOADED_IMAGES" => ENV['SELFMEDICATE_PRELOADED_IMAGES'], "K8SVERSION" => ENV['KUBERNETES_VERSION']} # Start antidote on reload $script = "/bin/bash --login $HOME/selfmedicate.sh resume" diff --git a/antidote-config.yml b/antidote-config.yml index 718c846..119fbd2 100644 --- a/antidote-config.yml +++ b/antidote-config.yml @@ -11,3 +11,12 @@ vm_config: memory: 8192 cores: 2 provider: virtualbox + +# Providing a value for options supported by the +# selfmedicate.sh script, relevant in the Vagrant context. For the +# moment PRELOADED_IMAGES +# For instance: +# +#selfmedicate_prefs: +# PRELOADED_IMAGES: ["utility", "vqfx-snap1"] +# KUBERNETES_VERSION: "v1.14.8" diff --git a/vagrant-provision.sh b/vagrant-provision.sh index 9d0853a..6580122 100644 --- a/vagrant-provision.sh +++ b/vagrant-provision.sh @@ -94,9 +94,14 @@ setup_docker() { } install_kubectl() { - # Download the latest version of kubectl - echo "Installing Kubectl" - curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl &>/dev/null + if [[ $K8SVERSION = v* ]]; then + echo "Installing Kubectl version $K8SVERSION" + curl -LO https://storage.googleapis.com/kubernetes-release/release/$K8SVERSION/bin/linux/amd64/kubectl &>/dev/null + else + # Download the latest version of kubectl + echo "Installing Kubectl" + curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl &>/dev/null + fi # Make the kubectl binary executable chmod +x ./kubectl # Move the binary into the PATH