adding inital packages for bootstrap cluster
[icn.git] / env / 01_install_package.sh
1 #!/usr/bin/env bash
2 set -ex
3
4 lib/common.sh
5 lib/logging.sh
6
7 if [[ $EUID -ne 0 ]]; then
8     echo "This script must be run as root"
9     exit 1
10 fi
11
12 function install_essential_packages() {
13     apt-get update
14     apt-get -y install \
15                 crudini \
16                 curl \
17                 dnsmasq \
18                 figlet \
19                 golang \
20                 nmap \
21                 patch \
22                 psmisc \
23                 python-pip \
24                 python-requests \
25                 python-setuptools \
26                 vim \
27                 wget
28 }
29
30 function install_ironic_packages() {
31     apt-get update
32     apt-get -y install \
33                 jq \
34                 nodejs \
35                 python-ironicclient \
36                 python-ironic-inspector-client \
37                 python-lxml \
38                 python-netaddr \
39                 python-openstackclient \
40                 unzip \
41                 genisoimage
42
43         if [ "$1" == "offline" ]; then
44                 pip install --no-index
45                         --find-links=file:$PIP_CACHE_DIR locat yq
46                 return
47         fi
48
49     pip install \
50                 lolcat \
51                 yq
52 }
53
54 function install_docker_packages() {
55     apt-get remove docker \
56                 docker-engine \
57                 docker.io \
58                 containerd \
59                 runc
60     apt-get update
61     apt-get -y install \
62                 apt-transport-https \
63                 ca-certificates \
64                 curl \
65                 gnupg-agent \
66                 software-properties-common
67         if [ "$1" != "offline" ]; then
68                 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
69                 add-apt-repository \
70                         "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
71                         $(lsb_release -cs) \
72                         stable"
73                 apt-get update
74         fi
75     apt-get -y install docker-ce=18.06.0~ce~3-0~ubuntu
76 }
77
78 function install_podman_packages() {
79         if [ "$1" != "offline" ]; then
80         add-apt-repository -y ppa:projectatomic/ppa
81                 apt-get update
82         fi
83     apt-get -y install podman
84 }
85
86 function install_kubernetes_packages() {
87         if [ "$1" != "offline" ]; then
88                 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
89                 bash -c 'cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
90 deb https://apt.kubernetes.io/ kubernetes-xenial main
91 EOF'
92                 apt-get update
93         fi
94         apt-get install -y kubelet=1.15.0-00 kubeadm=1.15.0-00 kubectl=1.15.0-00
95         apt-mark hold kubelet kubeadm kubectl
96 }
97
98 install() {
99         install_essential_packages
100         install_ironic_packages $1
101         install_docker_packages $1
102         install_podman_packages $1
103         install_kubernetes_packages $1
104 }
105
106 if ["$1" == "-o"]; then
107         install offline
108         exit 0
109 fi
110
111 install