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