Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Provide a way to set env vars for selfmedicate.sh #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions antidote-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ vm_config:
memory: 8192
cores: 2
provider: virtualbox

# Providing a value for options supported by the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's clear from this comment when I should modify these values. I think the idea is that if you're both a) using Vagrant and b) wish to override the default values in selfmedicate.sh, you should uncomment this - but I'd like to see more clarity here if that's true. My over-arching comment about why this only applies to Vagrant still stands though.

# 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"
11 changes: 8 additions & 3 deletions vagrant-provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure of the purpose of this. Since K8SVERSION should have a default value, let's just install whatever version is indicated there.

To be clear, I am in favor of installing the version under K8SVERSION, so I like the inner change, just not sure of the outer conditional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I aimed at being able to use the provisionning scripts outside the context of Vagrant, thus not necessarily having K8SVERSION set

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
Expand Down