Integrated deployment configuration and documentation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.3 KiB

  1. #!/usr/bin/env bash
  2. # Copyright 2018 AT&T Intellectual Property. All other rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -e
  16. SCRIPT_DIR=$(realpath "$(dirname "${0}")")
  17. WORKSPACE=$(realpath "${SCRIPT_DIR}/..")
  18. GATE_UTILS=${WORKSPACE}/multi_nodes_gate/airship_gate/lib/all.sh
  19. GATE_COLOR=${GATE_COLOR:-1}
  20. export GATE_COLOR
  21. export GATE_UTILS
  22. export WORKSPACE
  23. source "${GATE_UTILS}"
  24. REQUIRE_RELOG=0
  25. log_stage_header "Installing Packages"
  26. export DEBIAN_FRONTEND=noninteractive
  27. sudo -E apt-get update -qq
  28. sudo -E apt-get install -q -y --no-install-recommends \
  29. curl \
  30. docker.io \
  31. fio \
  32. genisoimage \
  33. jq \
  34. libstring-shellquote-perl \
  35. libvirt-bin \
  36. qemu-kvm \
  37. qemu-utils \
  38. virtinst
  39. log_stage_header "Joining User Groups"
  40. for grp in docker libvirtd libvirt; do
  41. if ! groups | grep $grp > /dev/null; then
  42. sudo adduser "$(id -un)" $grp || echo "Group $grp not found, not added to user"
  43. REQUIRE_RELOG=1
  44. fi
  45. done
  46. make_virtmgr_account
  47. HTTPS_PROXY=${HTTPS_PROXY:-${https_proxy}}
  48. HTTPS_PROXY=${HTTP_PROXY:-${http_proxy}}
  49. if [[ ! -z "${HTTPS_PROXY}" ]]
  50. then
  51. log_stage_header "Configuring Apt Proxy"
  52. cat << EOF | sudo tee /etc/apt/apt.conf.d/50proxyconf
  53. Acquire::https::proxy "${HTTPS_PROXY}";
  54. Acquire::http::proxy "${HTTPS_PROXY}";
  55. EOF
  56. log_stage_header "Configuring Docker Proxy"
  57. sudo mkdir -p /etc/systemd/system/docker.service.d/
  58. cat << EOF | sudo tee /etc/systemd/system/docker.service.d/proxy.conf
  59. [Service]
  60. Environment="HTTP_PROXY=${HTTP_PROXY}"
  61. Environment="HTTPS_PROXY=${HTTPS_PROXY}"
  62. Environment="NO_PROXY=${NO_PROXY}"
  63. EOF
  64. sudo systemctl daemon-reload
  65. sudo systemctl restart docker
  66. fi
  67. log_stage_header "Setting Kernel Parameters"
  68. if [ "xY" != "x$(cat /sys/module/kvm_intel/parameters/nested)" ]; then
  69. log_note Enabling nested virtualization.
  70. sudo modprobe -r kvm_intel
  71. sudo modprobe kvm_intel nested=1 || log_error Nested Virtualization not supported
  72. echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf
  73. fi
  74. if ! sudo virt-host-validate qemu &> /dev/null; then
  75. log_note Host did not validate virtualization check:
  76. sudo virt-host-validate qemu || true
  77. fi
  78. if [[ ! -d ${VIRSH_POOL_PATH} ]]; then
  79. sudo mkdir -p "${VIRSH_POOL_PATH}"
  80. fi
  81. log_stage_header "Disabling br_netfilter"
  82. cat << EOF | sudo tee /etc/sysctl.d/60-bridge.conf
  83. net.bridge.bridge-nf-call-ip6tables = 0
  84. net.bridge.bridge-nf-call-iptables = 0
  85. net.bridge.bridge-nf-call-arptables = 0
  86. EOF
  87. cat << EOF | sudo tee /etc/udev/rules.d/99-bridge.rules
  88. ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \
  89. RUN+="/lib/systemd/systemd-sysctl --prefix=/net/bridge"
  90. EOF
  91. besteffort sudo sysctl -p /etc/sysctl.d/60-bridge.conf
  92. if [[ ${REQUIRE_RELOG} -eq 1 ]]; then
  93. echo
  94. log_note "You must ${C_HEADER}log out${C_CLEAR} and back in before the gate is ready to run."
  95. fi
  96. log_huge_success