Reference Airship manifests, CICD, and reference architecture.
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.

airship-in-a-bottle.sh 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/bin/bash
  2. #
  3. # Copyright 2018 AT&T Intellectual Property. All other rights reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. ###############################################################################
  17. # #
  18. # Set up and deploy an Airship environment for demonstration purposes. #
  19. # Many of the defaults and sources used here are NOT production ready, and #
  20. # this should not be used as a copy/paste source for any production use. #
  21. # #
  22. ###############################################################################
  23. AIAB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  24. usage ()
  25. {
  26. echo "Usage: $(basename $0) {-y|-h}" 1>&2
  27. echo " -y don't ask questions, trust autodetection" 1>&2
  28. echo " -h this help" 1>&2
  29. }
  30. # See how we were called.
  31. case "$1" in
  32. "" ) ;;
  33. "-y" ) ASSUME_YES=1;;
  34. "-h"|* ) usage; exit 1;;
  35. esac
  36. echo ""
  37. echo "Welcome to Airship in a Bottle"
  38. echo ""
  39. echo " /--------------------\\"
  40. echo "| \\"
  41. echo "| |---| \\----"
  42. echo "| | x | \\"
  43. echo "| |---| |"
  44. echo "| | /"
  45. echo "| \____|____/ /----"
  46. echo "| /"
  47. echo " \--------------------/"
  48. echo ""
  49. echo ""
  50. echo "A prototype example of deploying the Airship suite on a single VM."
  51. echo ""
  52. sleep 1
  53. echo ""
  54. echo "This example will run through:"
  55. echo " - Setup"
  56. echo " - Genesis of Airship (Kubernetes)"
  57. echo " - Basic deployment of Openstack (including Nova, Neutron, and Horizon using Openstack Helm)"
  58. echo " - VM creation automation using Heat"
  59. echo ""
  60. echo "The expected runtime of this script is greater than 1 hour"
  61. echo ""
  62. sleep 1
  63. echo ""
  64. echo "The minimum recommended size of the Ubuntu 16.04 VM is 4 vCPUs, 20GB of RAM with 32GB disk space."
  65. CPU_COUNT=$(grep -c processor /proc/cpuinfo)
  66. RAM_TOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
  67. # Blindly assume that all storage on this VM is under root FS
  68. DISK_SIZE=$(df --output=source,size / | awk '/dev/ {print $2}')
  69. source /etc/os-release
  70. if [[ $CPU_COUNT -lt 4 || $RAM_TOTAL -lt 20000000 || $DISK_SIZE -lt 30000000 || $NAME != "Ubuntu" || $VERSION_ID != "16.04" ]]; then
  71. echo "Error: minimum VM recommendations are not met. Exiting."
  72. exit 1
  73. fi
  74. if [[ $(id -u) -ne 0 ]]; then
  75. echo "Please execute this script as root!"
  76. exit 1
  77. fi
  78. sleep 1
  79. echo "Let's collect some information about your VM to get started."
  80. sleep 1
  81. # IP and Hostname setup
  82. get_local_ip ()
  83. {
  84. ip addr | awk "/inet/ && /${HOST_IFACE}/{sub(/\/.*$/,\"\",\$2); print \$2}"
  85. }
  86. HOST_IFACE=$(ip route | grep "^default" | head -1 | awk '{ print $5 }')
  87. LOCAL_IP=$(get_local_ip)
  88. if [[ $ASSUME_YES -ne 1 ]]; then
  89. read -p "Is your HOST IFACE $HOST_IFACE? (Y/n) " YN_HI
  90. if [[ ! "$YN_HI" =~ ^([yY]|"")$ ]]; then
  91. read -p "What is your HOST IFACE? " HOST_IFACE
  92. fi
  93. LOCAL_IP=$(get_local_ip)
  94. read -p "Is your LOCAL IP $LOCAL_IP? (Y/n) " YN_IP
  95. if [[ ! "$YN_IP" =~ ^([yY]|"")$ ]]; then
  96. read -p "What is your LOCAL IP? " LOCAL_IP
  97. fi
  98. fi
  99. # Shells out to get the hostname for the single-node deployment to avoid some
  100. # config conflicts
  101. set -x
  102. export SHORT_HOSTNAME=$(hostname -s)
  103. set +x
  104. # Updates the /etc/hosts file
  105. HOSTS="${LOCAL_IP} ${SHORT_HOSTNAME}"
  106. HOSTS_REGEX="${LOCAL_IP}.*${SHORT_HOSTNAME}"
  107. if grep -q "$HOSTS_REGEX" "/etc/hosts"; then
  108. echo "Not updating /etc/hosts, entry ${HOSTS} already exists."
  109. else
  110. echo "Updating /etc/hosts with: ${HOSTS}"
  111. cat << EOF | tee -a /etc/hosts
  112. $HOSTS
  113. EOF
  114. fi
  115. # x/32 will work for CEPH in a single node deploy.
  116. CIDR="$LOCAL_IP/32"
  117. # Variable setup
  118. set -x
  119. # The IP address of the genesis node
  120. export HOSTIP=$LOCAL_IP
  121. # The CIDR of the network for the genesis node
  122. export HOSTCIDR=$CIDR
  123. # The network interface on the genesis node
  124. export NODE_NET_IFACE=$HOST_IFACE
  125. export TARGET_SITE="aiab"
  126. set +x
  127. # Changes DNS servers in common-addresses.yaml to the system's DNS servers
  128. get_dns_servers ()
  129. {
  130. if hash nmcli 2>/dev/null; then
  131. nmcli dev show | awk '/IP4.DNS/ {print $2}' | xargs
  132. else
  133. cat /etc/resolv.conf | awk '/nameserver/ {print $2}' | xargs
  134. fi
  135. }
  136. if grep -q "10.96.0.10" "/etc/resolv.conf"; then
  137. echo "Not changing DNS servers, /etc/resolv.conf already updated."
  138. else
  139. DNS_CONFIG_FILE="${AIAB_DIR}/../../../site/${TARGET_SITE}/networks/common-addresses.yaml"
  140. declare -a DNS_SERVERS=($(get_dns_servers))
  141. NS1=${DNS_SERVERS[0]:-8.8.8.8}
  142. NS2=${DNS_SERVERS[1]:-$NS1}
  143. echo "Using DNS servers $NS1 and $NS2."
  144. sed -i "s/8.8.8.8/$NS1/" $DNS_CONFIG_FILE
  145. sed -i "s/8.8.4.4/$NS2/" $DNS_CONFIG_FILE
  146. fi
  147. echo ""
  148. echo "Starting Airship deployment..."
  149. sleep 1
  150. ${AIAB_DIR}/common/deploy-airship.sh demo