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

Commit 0b7f606

Browse files
authored
Merge pull request #237 from queglay/pull-request-235
Pull request 235
2 parents 61db1c3 + b33ec3a commit 0b7f606

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

modules/install-vault/install-vault

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set -e
1010

1111
readonly DEFAULT_INSTALL_PATH="/opt/vault"
1212
readonly DEFAULT_VAULT_USER="vault"
13+
readonly DEFAULT_SKIP_PACKAGE_UPDATE="false"
1314

1415
readonly DOWNLOAD_PACKAGE_PATH="/tmp/vault.zip"
1516

@@ -30,6 +31,7 @@ function print_usage {
3031
echo -e " --download-url\t\tUrl to exact Vault package to be installed. Optional if version is provided."
3132
echo -e " --path\t\tThe path where Vault should be installed. Optional. Default: $DEFAULT_INSTALL_PATH."
3233
echo -e " --user\t\tThe user who will own the Vault install directories. Optional. Default: $DEFAULT_VAULT_USER."
34+
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."
3335
echo
3436
echo "Example:"
3537
echo
@@ -115,13 +117,19 @@ function has_apt_get {
115117
}
116118

117119
function install_dependencies {
120+
local -r skip_package_update=$1
118121
log_info "Installing dependencies"
119-
120122
if $(has_apt_get); then
121-
sudo apt-get update -y
123+
if [[ "$skip_package_update" != "true" ]]; then
124+
log_info "Running apt-get update"
125+
sudo apt-get update -y
126+
fi
122127
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y awscli curl unzip jq libcap2-bin
123128
elif $(has_yum); then
124-
sudo yum update -y
129+
if [[ "$skip_package_update" != "true" ]]; then
130+
log_info "Running yum update"
131+
sudo yum update -y
132+
fi
125133
sudo yum install -y awscli curl unzip jq
126134
else
127135
log_error "Could not find apt-get or yum. Cannot install dependencies on this OS."
@@ -218,6 +226,7 @@ function install {
218226
local download_url=""
219227
local path="$DEFAULT_INSTALL_PATH"
220228
local user="$DEFAULT_VAULT_USER"
229+
local skip_package_update="$DEFAULT_SKIP_PACKAGE_UPDATE"
221230

222231
while [[ $# > 0 ]]; do
223232
local key="$1"
@@ -239,6 +248,9 @@ function install {
239248
user="$2"
240249
shift
241250
;;
251+
--skip-package-update)
252+
skip_package_update="true"
253+
;;
242254
--help)
243255
print_usage
244256
exit
@@ -259,7 +271,7 @@ function install {
259271

260272
log_info "Starting Vault install"
261273

262-
install_dependencies
274+
install_dependencies "$skip_package_update"
263275
create_vault_user "$user"
264276
create_vault_install_paths "$path" "$user"
265277
fetch_binary "$version" "$download_url"

test/vault_main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func TestMainVaultCluster(t *testing.T) {
102102
amisPackerOptions := map[string]*packer.Options{}
103103
for _, ami := range amisData {
104104
// Exclude a few regions as they are missing the instance types we use
105-
awsRegion := aws.GetRandomRegion(t, nil, []string{"eu-north-1", "ca-central-1", "ap-northeast-2"})
105+
awsRegion := aws.GetRandomRegion(t, nil, []string{"eu-north-1", "ca-central-1", "ap-northeast-2", "ap-northeast-3"})
106106

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

0 commit comments

Comments
 (0)