Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Ubuntu base build |
| 3 | |
| 4 | # vim: ts=4 sw=4 sts=4 et tw=72 : |
| 5 | |
| 6 | # force any errors to cause the script and job to end in failure |
| 7 | set -xeu -o pipefail |
| 8 | |
| 9 | rh_systems() { |
| 10 | echo 'No changes to apply' |
| 11 | } |
| 12 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 13 | ubuntu_install_java_setup() { |
| 14 | |
| 15 | echo "debconf shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections |
| 16 | |
| 17 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 |
| 18 | |
| 19 | DISTRO=$(lsb_release -cs) |
| 20 | |
| 21 | apt-add-repository \ |
| 22 | "deb http://ppa.launchpad.net/webupd8team/java/ubuntu $DISTRO main" |
| 23 | } |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 24 | |
| 25 | ubuntu_systems() { |
| 26 | apt-get clean |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 27 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 28 | # get prereqs for PPA and apt-over-HTTPS support |
| 29 | apt-get update |
| 30 | apt-get install -y apt-transport-https software-properties-common |
| 31 | |
| 32 | # install java (not needed as SonarQube includes this) |
| 33 | # ubuntu_install_java_setup |
| 34 | # apt-get update |
| 35 | # apt-get install -y oracle-java8-installer |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 36 | # rm -rf /var/cache/oracle-jdk8-installer |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 37 | |
| 38 | # set up ansible repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 39 | apt-add-repository -y ppa:ansible/ansible |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 40 | |
| 41 | # set up docker repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 42 | apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 43 | add-apt-repository \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 44 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ |
| 45 | $(lsb_release -cs) \ |
| 46 | stable" |
| 47 | |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 48 | apt-get update |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 49 | |
| 50 | # install basic sofware requirements |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 51 | apt-get install -y \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 52 | "docker-ce=17.06*" \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 53 | ansible \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 54 | build-essential \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 55 | bzip2 \ |
| 56 | curl \ |
| 57 | git \ |
| 58 | less \ |
Zack Williams | cfe0b94 | 2018-04-12 11:47:57 -0700 | [diff] [blame] | 59 | libxml2-utils \ |
Kailash Khalasi | 1ddc7c6 | 2018-04-20 08:47:56 -0700 | [diff] [blame] | 60 | maven \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 61 | nodejs \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 62 | npm \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 63 | python \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 64 | python-certifi \ |
| 65 | python-cryptography \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 66 | python-dev \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 67 | python-idna \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 68 | python-netaddr \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 69 | python-openssl \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 70 | python-pip \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 71 | python-urllib3 \ |
Zack Williams | 40c06f0 | 2018-04-15 20:31:34 -0700 | [diff] [blame] | 72 | ruby \ |
Zack Williams | eb842ae | 2018-05-15 17:07:32 -0700 | [diff] [blame] | 73 | socat \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 74 | ssh \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 75 | sshpass \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 76 | zip |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 77 | # end of apt-get install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 78 | |
| 79 | # install python modules |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 80 | pip install \ |
| 81 | Jinja2 \ |
| 82 | ansible-lint \ |
| 83 | astroid \ |
| 84 | docker-compose==1.20.1 \ |
| 85 | docker==3.2.1 \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 86 | gitpython \ |
Luca Prete | 90bfa5e | 2018-03-06 20:41:56 -0800 | [diff] [blame] | 87 | graphviz \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 88 | isort \ |
Zack Williams | 6828f82 | 2018-04-12 16:13:33 -0700 | [diff] [blame] | 89 | linkchecker \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 90 | pexpect \ |
| 91 | pylint \ |
| 92 | pyyaml \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 93 | robotframework \ |
Kailash Khalasi | cb327c6 | 2018-04-03 10:41:38 -0700 | [diff] [blame] | 94 | robotframework-httplibrary \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 95 | robotframework-requests \ |
Zack Williams | fd8a004 | 2018-04-12 14:34:17 -0700 | [diff] [blame] | 96 | robotframework-sshlibrary \ |
| 97 | virtualenv |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 98 | # end of pip install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 99 | |
Zack Williams | 40c06f0 | 2018-04-15 20:31:34 -0700 | [diff] [blame] | 100 | # install ruby gems |
| 101 | gem install \ |
| 102 | mdl |
| 103 | # end of gem install list |
| 104 | |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 105 | # install npm modules |
| 106 | npm install -g \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 107 | gitbook-cli \ |
| 108 | markdownlint \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 109 | typings |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 110 | # end of npm install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 111 | |
Zack Williams | 6828f82 | 2018-04-12 16:13:33 -0700 | [diff] [blame] | 112 | # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks |
| 113 | # tools that expect it to be named just `node`. Symlink it to fix |
| 114 | ln -s /usr/bin/nodejs /usr/local/bin/node |
| 115 | |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 116 | # install repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 117 | REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda" |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 118 | curl -o /tmp/repo 'https://gerrit.opencord.org/gitweb?p=repo.git;a=blob_plain;f=repo;hb=refs/heads/stable' |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 119 | echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c - |
| 120 | mv /tmp/repo /usr/local/bin/repo |
| 121 | chmod a+x /usr/local/bin/repo |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 122 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 123 | # install sonarqube scanner |
| 124 | SONAR_SCANNER_CLI_VERSION="3.1.0.1141" |
| 125 | SONAR_SCANNER_CLI_SHA256SUM="efbe7d1a274bbed220846eccc5b36db853a6bab3ee576aebf93ddc604a89ced4" |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 126 | curl -L -o /tmp/sonarscanner.zip "https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip" |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 127 | echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c - |
| 128 | pushd /opt |
| 129 | unzip /tmp/sonarscanner.zip |
| 130 | mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 131 | rm -f /tmp/sonarscanner.zip |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 132 | popd |
| 133 | |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 134 | # install helm |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 135 | HELM_VERSION="2.8.2" |
| 136 | HELM_SHA256SUM="614b5ac79de4336b37c9b26d528c6f2b94ee6ccacb94b0f4b8d9583a8dd122d3" |
| 137 | HELM_PLATFORM="linux-amd64" |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 138 | curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 139 | echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c - |
| 140 | pushd /tmp |
| 141 | tar -xzvf helm.tgz |
| 142 | mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 143 | chmod a+x /usr/local/bin/helm |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 144 | rm -rf helm.tgz ${HELM_PLATFORM} |
| 145 | popd |
| 146 | |
Zack Williams | 4c5bfab | 2018-05-08 16:13:50 -0700 | [diff] [blame] | 147 | # install kubectl |
| 148 | KUBECTL_VERSION="1.9.5" |
| 149 | KUBECTL_SHA256SUM="9c67b6e80e9dd3880511c7d912c5a01399c1d74aaf4d71989c7d5a4f2534bcd5" |
| 150 | curl -L -o /tmp/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" |
| 151 | echo "$KUBECTL_SHA256SUM /tmp/kubectl" | sha256sum -c - |
| 152 | mv /tmp/kubectl /usr/local/bin/kubectl |
| 153 | chmod a+x /usr/local/bin/kubectl |
| 154 | rm -f /tmp/kubectl |
| 155 | |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 156 | # install minikube |
| 157 | MINIKUBE_VERSION="0.26.1" |
| 158 | MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')" |
| 159 | MINIKUBE_SHA256SUM="4a97ff448347eb374e1c48b4578cc3cf61af51cca4ff002101a57e77ffaa1575" |
| 160 | curl -L -o /tmp/minikube.deb "https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube_${MINIKUBE_DEB_VERSION}.deb" |
| 161 | echo "$MINIKUBE_SHA256SUM /tmp/minikube.deb" | sha256sum -c - |
| 162 | pushd /tmp |
| 163 | dpkg -i minikube.deb |
| 164 | rm -f minikube.deb |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 165 | popd |
| 166 | |
Zack Williams | 8173977 | 2018-05-14 16:35:47 -0700 | [diff] [blame] | 167 | # give sudo permissions on minikube to jenkins user, so `minikube init` can be run |
| 168 | cat <<EOF >/etc/sudoers.d/88-jenkins-minikube |
| 169 | Defaults:jenkins !requiretty |
| 170 | jenkins ALL=(ALL) NOPASSWD:SETENV: /usr/bin/minikube |
| 171 | EOF |
| 172 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 173 | # clean up |
| 174 | apt-get clean |
| 175 | apt-get purge -y |
| 176 | apt-get autoremove -y |
| 177 | rm -rf /var/lib/apt/lists/* |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 178 | } |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 179 | |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 180 | all_systems() { |
| 181 | echo 'No common distribution configuration to perform' |
| 182 | } |
| 183 | |
| 184 | echo "---> Detecting OS" |
| 185 | ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') |
| 186 | |
| 187 | case "${ORIGIN}" in |
| 188 | fedora|centos|redhat) |
| 189 | echo "---> RH type system detected" |
| 190 | rh_systems |
| 191 | ;; |
| 192 | ubuntu) |
| 193 | echo "---> Ubuntu system detected" |
| 194 | ubuntu_systems |
| 195 | ;; |
| 196 | *) |
| 197 | echo "---> Unknown operating system" |
| 198 | ;; |
| 199 | esac |
| 200 | |
| 201 | # execute steps for all systems |
| 202 | all_systems |