Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #237 from queglay/pull-request-235
Browse files Browse the repository at this point in the history
Pull request 235
  • Loading branch information
brikis98 authored Apr 12, 2021
2 parents 61db1c3 + b33ec3a commit 0b7f606
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions modules/install-vault/install-vault
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set -e

readonly DEFAULT_INSTALL_PATH="/opt/vault"
readonly DEFAULT_VAULT_USER="vault"
readonly DEFAULT_SKIP_PACKAGE_UPDATE="false"

readonly DOWNLOAD_PACKAGE_PATH="/tmp/vault.zip"

Expand All @@ -30,6 +31,7 @@ function print_usage {
echo -e " --download-url\t\tUrl to exact Vault package to be installed. Optional if version is provided."
echo -e " --path\t\tThe path where Vault should be installed. Optional. Default: $DEFAULT_INSTALL_PATH."
echo -e " --user\t\tThe user who will own the Vault install directories. Optional. Default: $DEFAULT_VAULT_USER."
echo -e " --skip-package-update\t\tSkip yum/apt updates. Optional. Only recommended if you already ran yum update or apt-get update yourself. Default: $DEFAULT_SKIP_PACKAGE_UPDATE."
echo
echo "Example:"
echo
Expand Down Expand Up @@ -115,13 +117,19 @@ function has_apt_get {
}

function install_dependencies {
local -r skip_package_update=$1
log_info "Installing dependencies"

if $(has_apt_get); then
sudo apt-get update -y
if [[ "$skip_package_update" != "true" ]]; then
log_info "Running apt-get update"
sudo apt-get update -y
fi
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y awscli curl unzip jq libcap2-bin
elif $(has_yum); then
sudo yum update -y
if [[ "$skip_package_update" != "true" ]]; then
log_info "Running yum update"
sudo yum update -y
fi
sudo yum install -y awscli curl unzip jq
else
log_error "Could not find apt-get or yum. Cannot install dependencies on this OS."
Expand Down Expand Up @@ -218,6 +226,7 @@ function install {
local download_url=""
local path="$DEFAULT_INSTALL_PATH"
local user="$DEFAULT_VAULT_USER"
local skip_package_update="$DEFAULT_SKIP_PACKAGE_UPDATE"

while [[ $# > 0 ]]; do
local key="$1"
Expand All @@ -239,6 +248,9 @@ function install {
user="$2"
shift
;;
--skip-package-update)
skip_package_update="true"
;;
--help)
print_usage
exit
Expand All @@ -259,7 +271,7 @@ function install {

log_info "Starting Vault install"

install_dependencies
install_dependencies "$skip_package_update"
create_vault_user "$user"
create_vault_install_paths "$path" "$user"
fetch_binary "$version" "$download_url"
Expand Down
2 changes: 1 addition & 1 deletion test/vault_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestMainVaultCluster(t *testing.T) {
amisPackerOptions := map[string]*packer.Options{}
for _, ami := range amisData {
// Exclude a few regions as they are missing the instance types we use
awsRegion := aws.GetRandomRegion(t, nil, []string{"eu-north-1", "ca-central-1", "ap-northeast-2"})
awsRegion := aws.GetRandomRegion(t, nil, []string{"eu-north-1", "ca-central-1", "ap-northeast-2", "ap-northeast-3"})

test_structure.SaveString(t, WORK_DIR, fmt.Sprintf("awsRegion-%s", ami.Name), awsRegion)

Expand Down

0 comments on commit 0b7f606

Please sign in to comment.