-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap-observability.sh
More file actions
executable file
·61 lines (51 loc) · 1.78 KB
/
bootstrap-observability.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.78 KB
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
#!/bin/bash
function create_ssm_user {
# check if user already exists
getent passwd ssm-user > /dev/null
if [[ $? = 0 ]]; then
echo "ssm-user user already exists. Don't need to do anything more."
else
# ssm-user creation
useradd --comment "mirror AWS System Manager ssm-user" --create-home --shell /bin/bash ssm-user
if [[ $? != 0 ]]; then
>&2 echo "Error while creating user."
exit 1
fi
usermod -a -G wheel ssm-user
if [[ $? != 0 ]]; then
>&2 echo "Error while updating user permissions."
exit 1
fi
echo "ssm-user ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/dont-prompt-ssm-user-for-sudo-password
if [[ $? != 0 ]]; then
>&2 echo "Error while updating user sudo password policy."
exit 1
fi
fi
}
#/usr/bin/env bash
echo "Bootstrapping Observability Control Plane"
# ensure git is installed
echo "- Installing bootstrapping and observability tools"
yum install -y less jq git-core tar unzip which sudo procps openssl shadow-utils ca-certificates findutils logrotate
# create the ssm user
create_ssm_user
OZONE_HOME="/usr/o3"
OBS_HOME=${OZONE_HOME}/observability-ctrl-plane
if [[ -d ${OBS_HOME} ]]; then
echo "- Cleaning old ${OBS_HOME}"
sudo rm -rf ${OBS_HOME}
fi
echo "- Creating ${OBS_HOME}"
sudo mkdir -p ${OBS_HOME}
# assign right permissions
echo "- Assign user permissions to ${OZONE_HOME}"
sudo chown -R ssm-user:ssm-user ${OZONE_HOME}
CWD=$(dirname $0)
REAL_DIR=$(realpath ${CWD})
echo "- run the ssm-bootstrap-observability bootstrap script in ${REAL_DIR}"
sudo -iu ssm-user GITHUB_HTTPS_CREDS=${GITHUB_HTTPS_CREDS} OBS_BRANCH=${OBS_BRANCH:-${BRANCH}} AUTODEPLOY=${AUTODEPLOY:-"false"} ${REAL_DIR}/ssm-bootstrap-observability.sh
if [[ $? != 0 ]]; then
>&2 echo "Bootstrap initialization failed."
exit 1
fi