-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathenv_setup.sh
More file actions
executable file
·163 lines (146 loc) · 5.21 KB
/
env_setup.sh
File metadata and controls
executable file
·163 lines (146 loc) · 5.21 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env bash
set -e
DOCKER_CE_VERSION=5:20.10.7~3-0~ubuntu-focal
DOCKER_CE_CLI_VERSION=5:20.10.7~3-0~ubuntu-focal
FABRIC_VERSION=2.2.0
FABRIC_CA_VERSION=1.5.0
YQ_VERSION=v4.2.0
TERRAFORM_VERSION=1.0.0
KUBECTL_VERSION=v1.21.0
HELM_VERSION=v3.0.0
JQ_VERSION=1.6-1ubuntu0.20.04.1
ARGO_VERSION=v3.1.1
# override StrictHostKeyChecking in ssh config
touch ~/.ssh/config
cat << EOF > ~/.ssh/config
Host *
StrictHostKeyChecking accept-new
EOF
chmod 755 ./
# cd to project root
cd `dirname $0`/..
# Update the submodule code
echo "############## Update the submodule code ##############"
set -x
git submodule sync
git submodule update --init --recursive
set +x
# Setup python environment
echo "############## Setup python environment ##############"
set -x
sudo apt update
sudo apt-get install --yes python3-pip
sudo pip3 install -r kubespray/requirements.txt
set +x
# Generates keys if do not exist.
echo "############## Generates keys if do not exist ##############"
if test -f "/home/ubuntu/.ssh/id_rsa";
then
echo -e "keys already exist."
else
ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa
fi
# Install docker
echo "############## Install docker ##############"
if compgen -c | grep -q "^docker" >/dev/null;
then
echo -e "docker already installed"
else
# Install packages to allow apt to use a repository over HTTPS
sudo apt-get install --yes apt-transport-https ca-certificates curl gnupg lsb-release
# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# set up the stable repository
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the apt package index, and install a specific version of Docker Engine and containerd
sudo apt-get update
sudo apt-get install --yes docker-ce=$DOCKER_CE_VERSION docker-ce-cli=$DOCKER_CE_CLI_VERSION containerd.io
fi
# Install fabric binaries
echo "############## Install fabric binaries ##############"
if compgen -c | grep -q "^peer" >/dev/null;
then
echo -e "Fabric binaries already installed"
else
# Download the Hyperledger Fabric docker images for the version specified
curl -sSL https://bit.ly/2ysbOFE | sudo bash -s -- $FABRIC_VERSION $FABRIC_CA_VERSION -d -s
# Move binary to path
sudo mv -v ./bin/* /usr/local/bin/
# Clean home
sudo rm -r ./bin
sudo rm -r ./config
fi
# Install yq
echo "############## Install yq ##############"
if test -f "/usr/local/bin/yq";
then
echo -e "yq already installed"
else
# Download yq
wget https://github.com/mikefarah/yq/releases/download/$YQ_VERSION/yq_linux_amd64.tar.gz -O - | tar xz
# Move binary to path
sudo mv yq_linux_amd64 /usr/local/bin/yq
fi
# Install Terraform
echo "############## Install Terraform ##############"
if dpkg --get-selections | grep -q "^terraform[[:space:]]*install$" >/dev/null;
then
echo -e "terraform already installed"
else
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install --yes terraform=$TERRAFORM_VERSION
fi
# Install Kubectl
echo "############## Install Kubectl ##############"
if compgen -c | grep -q "^kubectl" >/dev/null;
then
echo -e "kubectl already installed"
else
curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
fi
# Install Helm
echo "############## Install Helm ##############"
if compgen -c | grep -q "^helm" >/dev/null;
then
echo -e "helm already installed"
else
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh -v $HELM_VERSION
fi
# Install jq
echo "############## Install jq ##############"
if dpkg --get-selections | grep -q "^jq[[:space:]]*install$" >/dev/null;
then
echo -e "jq already installed"
else
sudo apt-get install --yes jq=$JQ_VERSION
fi
# Install argo cli
echo "############## Install argo cli ##############"
if compgen -c | grep -q "^argo" >/dev/null;
then
echo -e "argo already installed"
else
# Download the binary
curl -sLO https://github.com/argoproj/argo-workflows/releases/download/$ARGO_VERSION/argo-linux-amd64.gz
# Unzip
gunzip argo-linux-amd64.gz
# Make binary executable
chmod +x argo-linux-amd64
# Move binary to path
sudo mv ./argo-linux-amd64 /usr/local/bin/argo
# Test installation
argo version
fi
# Create ansible.log file if not present
if [[ ! -f ansible.log ]]
then
touch ansible.log
fi