-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh.in
executable file
·103 lines (89 loc) · 4.52 KB
/
install.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
#
# MIT License
#
# (C) Copyright 2020-2023 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# Install the SAT product. This loads the cray/cray-sat docker image into nexus
# so that it can be pulled down by podman and sets up RPM repositories in nexus
# and uploads SAT rpms to those repos. It also uploads the
# cray/cray-product-catalog-update docker image to Nexus, and then uses it to
# add an entry to the cray-product-catalog Kubernetes configuration map.
# Finally, it uses a Loftsman manifest to deploy a Helm chart that creates
# a Kubernetes job to import Ansible configuration content into VCS, and
# it waits for the job's completion.
#
set -e
[ -n "${SAT_INSTALL_DEBUG}" ] && set -x
ROOTDIR="$(dirname "${BASH_SOURCE[0]}")"
source "${ROOTDIR}/lib/version.sh"
source "${ROOTDIR}/lib/install.sh"
source "${ROOTDIR}/install-utils.sh"
print_stage "Installing System Admin Toolkit version ${RELEASE_VERSION}"
print_stage "Loading install dependencies"
load-install-deps
print_stage "Uploading container images to the Docker registry in Nexus"
skopeo-sync "${ROOTDIR}/docker"
print_stage "Setting up Nexus repositories and blobstores"
nexus-setup blobstores "${ROOTDIR}/nexus-blobstores.yaml"
nexus-setup repositories "${ROOTDIR}/nexus-repositories.yaml"
print_stage "Uploading repository contents"
nexus-upload raw "${ROOTDIR}/rpms/${RELEASE_NAME}-sle-15sp2" "${RELEASE}-sle-15sp2"
print_stage "Importing SAT configuration to VCS"
default_config_import_image_name="registry.local/cray/cf-gitea-import"
config_import_image=${CONFIG_IMPORT_IMAGE:-$default_config_import_image_name:@CF_GITEA_IMPORT_VERSION@}
# Running the config import will write a file to ${ROOTDIR}/results
mkdir -p ${ROOTDIR}/results
# Note: CF_IMPORT_GITEA_ORG and CF_IMPORT_CONTENT are set to their defaults.
podman run --rm --name sat-config-import \
--user="root" \
--entrypoint /opt/csm/cf-gitea-import/standalone_entrypoint.sh \
-e CF_IMPORT_GITEA_URL="https://api-gw-service-nmn.local/vcs" \
-e CF_IMPORT_GITEA_USER=$(get_vcs_creds username) \
-e CF_IMPORT_GITEA_PASSWORD=$(get_vcs_creds password) \
-e CF_IMPORT_PRODUCT_NAME="sat" \
-e CF_IMPORT_PRODUCT_VERSION="$RELEASE_VERSION" \
-e CF_IMPORT_GITEA_ORG="cray" \
-e CF_IMPORT_CONTENT="/content" \
--mount "type=bind,src=${ROOTDIR}/ansible,target=/content,ro=true" \
--mount "type=bind,src=${ROOTDIR}/results,target=/results" \
--mount "type=bind,src=/etc/pki/trust/anchors,target=/usr/local/share/ca-certificates,ro=true" \
$config_import_image
# Concatenate results from config import and component version data.
cat ${ROOTDIR}/cray-product-catalog/sat-component-versions.yaml \
${ROOTDIR}/results/records.yaml > ${ROOTDIR}/cray-product-catalog/sat.yaml
print_stage "Adding SAT to cray-product-catalog"
default_product_catalog_image_name="registry.local/cray/cray-product-catalog-update"
product_catalog_image=${CRAY_PRODUCT_CATALOG_UPDATE_IMAGE:-$default_product_catalog_image_name:@CPCU_VERSION@}
podman run --rm --name sat-cpc \
--user="root" \
-e PRODUCT="sat" \
-e PRODUCT_VERSION=$RELEASE_VERSION \
-e KUBECONFIG="/.kube/admin.conf" \
-e YAML_CONTENT="/cray-product-catalog/sat.yaml" \
-e VALIDATE_SCHEMA="true" \
-e REMOVE_ACTIVE_FIELD="true" \
-v "/etc/kubernetes:/.kube:ro" \
-v "${ROOTDIR}/cray-product-catalog:/cray-product-catalog:ro" \
$product_catalog_image
print_stage "Cleaning up install dependencies"
clean-install-deps
print_stage "SAT version ${RELEASE_VERSION} has been installed."