diff --git a/.github/actions/docker-image/action.yml b/.github/actions/docker-image/action.yml index b0ec527bd..e37443637 100644 --- a/.github/actions/docker-image/action.yml +++ b/.github/actions/docker-image/action.yml @@ -20,7 +20,7 @@ runs: with: image: ${{ inputs.image }} - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37 # 0.31.0 + uses: aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4 # 0.32.0 with: image-ref: "${{ inputs.image }}" format: sarif diff --git a/ci/check_aio.sh b/ci/check_aio.sh index 9bb997105..4cd7d22e0 100755 --- a/ci/check_aio.sh +++ b/ci/check_aio.sh @@ -11,7 +11,7 @@ set -o errexit set -o pipefail if [[ ${OS_DEBUG:-false} == "true" ]]; then - set -o xtrace + set -o xtrace fi export OS_DISTRO="${OS_DISTRO:-ubuntu_22}" @@ -22,65 +22,65 @@ export OS_KOLLA_ENABLE_HORIZON="no" export OS_KOLLA_KOLLA_INSTALL_TYPE="source" function info { - _print_msg "INFO" "$1" - echo "::notice::$1" + _print_msg "INFO" "$1" + echo "::notice::$1" } function warn { - _print_msg "WARN" "$1" - echo "::warning::$1" + _print_msg "WARN" "$1" + echo "::warning::$1" } function _print_msg { - echo "$(date +%H:%M:%S) - $1: $2" + echo "$(date +%H:%M:%S) - $1: $2" } function get_release { - local release_pointer=${CI_INITIAL_RELEASE_POINTER:-3} + local release_pointer=${CI_INITIAL_RELEASE_POINTER:-3} - until [ -f "./requirements/$(sed -n "${release_pointer}p" releases.txt)/${OS_DISTRO}.txt" ]; do - release_pointer=$((release_pointer - 1)) - if [[ $release_pointer -lt "0" ]]; then - return - fi - done + until [ -f "./requirements/$(sed -n "${release_pointer}p" releases.txt)/${OS_DISTRO}.txt" ]; do + release_pointer=$((release_pointer - 1)) + if [[ $release_pointer -lt "0" ]]; then + return + fi + done - sed -n "${release_pointer}p" releases.txt + sed -n "${release_pointer}p" releases.txt } function upgrade { - local initial_release=$1 + local initial_release=$1 - release_pointer=$(cat -n releases.txt | grep "$initial_release" | awk '{print $1}') - release_pointer=$((release_pointer - 1)) + release_pointer=$(cat -n releases.txt | grep "$initial_release" | awk '{print $1}') + release_pointer=$((release_pointer - 1)) - while [[ $release_pointer -gt "0" ]]; do - release_name="$(sed -n "${release_pointer}p" releases.txt)" + while [[ $release_pointer -gt "0" ]]; do + release_name="$(sed -n "${release_pointer}p" releases.txt)" - if [ -f "./requirements/${release_name}/${OS_DISTRO}.txt" ]; then - pushd samples/aio/ >/dev/null - info "Upgrading ${OS_DISTRO} distro to OpenStack ${release_name} release" - vagrant ssh -- "cd /vagrant; OPENSTACK_RELEASE=$release_name OS_DEBUG=true ./upgrade.sh" - print_hw_stats - popd >/dev/null - else - warn "There is no more releases for ${OS_DISTRO} distro" - break - fi - release_pointer=$((release_pointer - 1)) - done + if [ -f "./requirements/${release_name}/${OS_DISTRO}.txt" ]; then + pushd samples/aio/ >/dev/null + info "Upgrading ${OS_DISTRO} distro to OpenStack ${release_name} release" + vagrant ssh -- "cd /vagrant; OPENSTACK_RELEASE=$release_name OS_DEBUG=true ./upgrade.sh" + print_hw_stats + popd >/dev/null + else + warn "There is no more releases for ${OS_DISTRO} distro" + break + fi + release_pointer=$((release_pointer - 1)) + done } function print_hw_stats { - ! command -v vm_stat >/dev/null || vm_stat - ! command -v VBoxManage >/dev/null || VBoxManage list runningvms --long - ! command -v virsh >/dev/null || virsh list + ! command -v vm_stat >/dev/null || vm_stat + ! command -v VBoxManage >/dev/null || VBoxManage list runningvms --long + ! command -v virsh >/dev/null || virsh list } initial_release=$(get_release) if [[ -z $initial_release ]]; then - warn "There is no OpenStack release supported for ${OS_DISTRO}" - exit + warn "There is no OpenStack release supported for ${OS_DISTRO}" + exit fi pushd samples/aio/ >/dev/null info "Deploying ${OS_DISTRO} distro with OpenStack ${initial_release} release" diff --git a/ci/update_distros.sh b/ci/update_distros.sh index 47f9bff0d..7fb20a2cc 100755 --- a/ci/update_distros.sh +++ b/ci/update_distros.sh @@ -11,59 +11,59 @@ set -o errexit set -o pipefail if [[ ${OS_DEBUG:-false} == "true" ]]; then - set -o xtrace + set -o xtrace fi PROVIDER=${PROVIDER:-virtualbox} msg="" function _get_box_current_version { - version="" - attempt_counter=0 - max_attempts=5 - name="$1" + version="" + attempt_counter=0 + max_attempts=5 + name="$1" - if [ -f ./ci/pinned_vagrant_boxes.txt ] && grep -q "^${name} .*$PROVIDER" ./ci/pinned_vagrant_boxes.txt; then - version=$(grep "^${name} .*$PROVIDER" ./ci/pinned_vagrant_boxes.txt | awk '{ print $2 }') - else - until [ "$version" ]; do - metadata="$(curl -s "https://app.vagrantup.com/api/v1/box/$name")" - if [ "$metadata" ]; then - version="$(echo "$metadata" | python -c 'import json,sys;print(json.load(sys.stdin)["current_version"]["version"])')" - break - elif [ ${attempt_counter} -eq ${max_attempts} ]; then - echo "Max attempts reached" - exit 1 - fi - attempt_counter=$((attempt_counter + 1)) - sleep $((attempt_counter * 2)) - done - fi + if [ -f ./ci/pinned_vagrant_boxes.txt ] && grep -q "^${name} .*$PROVIDER" ./ci/pinned_vagrant_boxes.txt; then + version=$(grep "^${name} .*$PROVIDER" ./ci/pinned_vagrant_boxes.txt | awk '{ print $2 }') + else + until [ "$version" ]; do + metadata="$(curl -s "https://app.vagrantup.com/api/v1/box/$name")" + if [ "$metadata" ]; then + version="$(echo "$metadata" | python -c 'import json,sys;print(json.load(sys.stdin)["current_version"]["version"])')" + break + elif [ ${attempt_counter} -eq ${max_attempts} ]; then + echo "Max attempts reached" + exit 1 + fi + attempt_counter=$((attempt_counter + 1)) + sleep $((attempt_counter * 2)) + done + fi - echo "${version#*v}" + echo "${version#*v}" } function _vagrant_pull { - local alias="$1" - local name="$2" - local project_id="$3" - local family="$4" - local vb_controller="${5:-IDE Controller}" + local alias="$1" + local name="$2" + local project_id="$3" + local family="$4" + local vb_controller="${5:-IDE Controller}" - version=$(_get_box_current_version "$name") + version=$(_get_box_current_version "$name") - if [ "$(curl "https://app.vagrantup.com/${name%/*}/boxes/${name#*/}/versions/$version/providers/$PROVIDER.box" -o /dev/null -w '%{http_code}\n' -s)" == "302" ] && [ "$(vagrant box list | grep -c "$name .*$PROVIDER, $version")" != "1" ]; then - vagrant box remove --provider "$PROVIDER" --all --force "$name" || : - vagrant box add --provider "$PROVIDER" --box-version "$version" "$name" - elif [ "$(vagrant box list | grep -c "$name .*$PROVIDER, $version")" == "1" ]; then - echo "$name($version, $PROVIDER) box is already present in the host" - else - msg+="$name($version, $PROVIDER) box doesn't exist\n" - return - fi - # editorconfig-checker-disable - # prettier-ignore-start - cat <>.distros_supported.yml + if [ "$(curl "https://app.vagrantup.com/${name%/*}/boxes/${name#*/}/versions/$version/providers/$PROVIDER.box" -o /dev/null -w '%{http_code}\n' -s)" == "302" ] && [ "$(vagrant box list | grep -c "$name .*$PROVIDER, $version")" != "1" ]; then + vagrant box remove --provider "$PROVIDER" --all --force "$name" || : + vagrant box add --provider "$PROVIDER" --box-version "$version" "$name" + elif [ "$(vagrant box list | grep -c "$name .*$PROVIDER, $version")" == "1" ]; then + echo "$name($version, $PROVIDER) box is already present in the host" + else + msg+="$name($version, $PROVIDER) box doesn't exist\n" + return + fi + # editorconfig-checker-disable + # prettier-ignore-start + cat <>.distros_supported.yml $alias: name: $name vb_controller: $vb_controller @@ -71,13 +71,13 @@ $alias: project_id: $project_id family: $family EOT - # prettier-ignore-end - # editorconfig-checker-enable + # prettier-ignore-end + # editorconfig-checker-enable } if ! command -v vagrant >/dev/null; then - # NOTE: Shorten link -> https://raw.githubusercontent.com/electrocucaracha/pkg-mgr_scripts/master/install.sh - curl -fsSL http://bit.ly/install_pkg | PKG=vagrant bash + # NOTE: Shorten link -> https://raw.githubusercontent.com/electrocucaracha/pkg-mgr_scripts/master/install.sh + curl -fsSL http://bit.ly/install_pkg | PKG=vagrant bash fi cat <.distros_supported.yml @@ -98,8 +98,8 @@ _vagrant_pull "debian_11" "debian/bullseye64" "debian-cloud" "debian-11" "SATA C _vagrant_pull "debian_12" "debian/bookworm64" "debian-cloud" "debian-12" "SATA Controller" if [ "$msg" ]; then - echo -e "$msg" - rm .distros_supported.yml + echo -e "$msg" + rm .distros_supported.yml else - mv .distros_supported.yml distros_supported.yml + mv .distros_supported.yml distros_supported.yml fi diff --git a/ci/update_versions.sh b/ci/update_versions.sh index 1f42b7d6b..50fbe92ae 100755 --- a/ci/update_versions.sh +++ b/ci/update_versions.sh @@ -11,7 +11,7 @@ set -o errexit set -o pipefail if [[ ${OS_DEBUG:-false} == "true" ]]; then - set -o xtrace + set -o xtrace fi trap "make fmt" EXIT @@ -19,7 +19,7 @@ trap "make fmt" EXIT # Update GitHub Action commit hashes gh_actions=$(grep -r "uses: [a-zA-Z\-]*/[\_a-z\-]*@" .github/ | sed 's/@.*//' | awk -F ': ' '{ print $3 }' | sort -u) for action in $gh_actions; do - commit_hash=$(git ls-remote "https://github.com/$action" | grep 'refs/tags/[v]\?[0-9][0-9\.]*$' | sed 's|refs/tags/[vV]\?[\.]\?||g' | sort -u -k2 -V | tail -1 | awk '{ printf "%s # %s\n",$1,$2 }') - # shellcheck disable=SC2267 - grep -ElRZ "uses: $action@" .github/ | xargs -0 -l sed -i -e "s|uses: $action@.*|uses: $action@$commit_hash|g" + commit_hash=$(git ls-remote "https://github.com/$action" | grep 'refs/tags/[v]\?[0-9][0-9\.]*$' | sed 's|refs/tags/[vV]\?[\.]\?||g' | sort -u -k2 -V | tail -1 | awk '{ printf "%s # %s\n",$1,$2 }') + # shellcheck disable=SC2267 + grep -ElRZ "uses: $action@" .github/ | xargs -0 -l sed -i -e "s|uses: $action@.*|uses: $action@$commit_hash|g" done diff --git a/commons.sh b/commons.sh index a089afeb5..fb3d5d19b 100755 --- a/commons.sh +++ b/commons.sh @@ -12,22 +12,22 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi function setup_ansible { - # Setup Mitogen - mitogen_ansible_cfg="" - if pip freeze | grep -q mitogen; then - mitogen_ansible_cfg=" + # Setup Mitogen + mitogen_ansible_cfg="" + if pip freeze | grep -q mitogen; then + mitogen_ansible_cfg=" strategy = mitogen_linear strategy_plugins = $(dirname "$(sudo find / -name mitogen_linear.py | head -n 1)") " - fi + fi - sudo tee /etc/ansible/ansible.cfg <") - [ "$v1" != "$v2" ] && [ "$result" = "$v2" ] - return - ;; - "<") - [ "$v1" != "$v2" ] && [ "$result" = "$v1" ] - return - ;; - ">=") - [ "$result" = "$v2" ] - return - ;; - "<=") - [ "$result" = "$v1" ] - return - ;; - *) - echo "unrecognised op: $op" - exit 1 - ;; - esac + case $op in + "==") + [ "$v1" = "$v2" ] + return + ;; + ">") + [ "$v1" != "$v2" ] && [ "$result" = "$v2" ] + return + ;; + "<") + [ "$v1" != "$v2" ] && [ "$result" = "$v1" ] + return + ;; + ">=") + [ "$result" = "$v2" ] + return + ;; + "<=") + [ "$result" = "$v1" ] + return + ;; + *) + echo "unrecognised op: $op" + exit 1 + ;; + esac } function run_kolla_actions { - for action in "$@"; do - ./run_kaction.sh "$action" | tee "$HOME/$action.log" - echo "Kolla Action statistics:" - grep ': .* -* .*s$' "$HOME/$action.log" || : - done + for action in "$@"; do + ./run_kaction.sh "$action" | tee "$HOME/$action.log" + echo "Kolla Action statistics:" + grep ': .* -* .*s$' "$HOME/$action.log" || : + done } diff --git a/compute.sh b/compute.sh index 04216895d..1bdc37fc8 100755 --- a/compute.sh +++ b/compute.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi _start=$(date +%s) @@ -21,14 +21,14 @@ trap 'printf "Compute installation process: %s secs\n" "$(($(date +%s)-_start))" # Install dependencies if ! command -v curl; then - # shellcheck disable=SC1091 - source /etc/os-release || source /usr/lib/os-release - case ${ID,,} in - ubuntu | debian) - sudo apt-get update - sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 --no-install-recommends curl - ;; - esac + # shellcheck disable=SC1091 + source /etc/os-release || source /usr/lib/os-release + case ${ID,,} in + ubuntu | debian) + sudo apt-get update + sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 --no-install-recommends curl + ;; + esac fi # NOTE: Shorten link -> https://github.com/electrocucaracha/pkg-mgr_scripts diff --git a/controller.sh b/controller.sh index e67e1f195..2e8533731 100755 --- a/controller.sh +++ b/controller.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi _start=$(date +%s) diff --git a/install.sh b/install.sh index e2008e079..795f90686 100755 --- a/install.sh +++ b/install.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi ##################### @@ -46,13 +46,13 @@ mgmt_ip=$(ip route get 8.8.8.8 | grep "^8." | awk '{ print $7 }') # than the full range of IP addresses in an IP block. This network is # considered the Public Security Domain. if ip route | grep -q "^10.10"; then - public_nic=$(ip route | grep "^10.10" | awk '{ print $3 }') + public_nic=$(ip route | grep "^10.10" | awk '{ print $3 }') else - if [ -z "${OS_KOLLA_NEUTRON_EXTERNAL_INTERFACE-}" ]; then - echo "ERROR: Using the management network interface as Neutron External can result in losing external connectivity" - exit 1 - fi - public_nic=${mgmt_nic} + if [ -z "${OS_KOLLA_NEUTRON_EXTERNAL_INTERFACE-}" ]; then + echo "ERROR: Using the management network interface as Neutron External can result in losing external connectivity" + exit 1 + fi + public_nic=${mgmt_nic} fi public_ip=$(ip addr | awk "/${public_nic}\$/ { sub(/\/[0-9]*/, \"\","' $2); print $2}') @@ -61,7 +61,7 @@ OS_FOLDER=${OS_FOLDER:-/opt/openstack-multinode} export OS_KOLLA_KOLLA_INTERNAL_VIP_ADDRESS=${OS_KOLLA_KOLLA_INTERNAL_VIP_ADDRESS:-$mgmt_ip} export OS_KOLLA_NETWORK_INTERFACE=$mgmt_nic if [ -z "${OS_KOLLA_NEUTRON_EXTERNAL_INTERFACE-}" ]; then - export OS_KOLLA_NEUTRON_EXTERNAL_INTERFACE=$public_nic + export OS_KOLLA_NEUTRON_EXTERNAL_INTERFACE=$public_nic fi ###################### @@ -70,41 +70,41 @@ fi # Validating passwordless sudo if ! sudo -n "true"; then - echo "" - echo "passwordless sudo is needed for '$(id -nu)' user." - echo "Please fix your /etc/sudoers file. You likely want an" - echo "entry like the following one..." - echo "" - echo "$(id -nu) ALL=(ALL) NOPASSWD: ALL" - exit 1 + echo "" + echo "passwordless sudo is needed for '$(id -nu)' user." + echo "Please fix your /etc/sudoers file. You likely want an" + echo "entry like the following one..." + echo "" + echo "$(id -nu) ALL=(ALL) NOPASSWD: ALL" + exit 1 fi # Validating local IP addresses in no_proxy environment variable if [ -n "${NO_PROXY-}" ]; then - for ip in $(hostname --ip-address || hostname -i) ${mgmt_ip} ${public_ip}; do - if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && $NO_PROXY != *"$ip"* ]]; then - echo "The $ip IP address is not defined in NO_PROXY env" - exit 1 - fi - done + for ip in $(hostname --ip-address || hostname -i) ${mgmt_ip} ${public_ip}; do + if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && $NO_PROXY != *"$ip"* ]]; then + echo "The $ip IP address is not defined in NO_PROXY env" + exit 1 + fi + done fi # Validating SELinux if command -v sestatus && [[ $(sestatus | grep Current) != *permissive* ]]; then - echo "" - echo "SELinux requires to be configured as Permissive mode." - echo "Please fix your /etc/selinux/config file." - exit 1 + echo "" + echo "SELinux requires to be configured as Permissive mode." + echo "Please fix your /etc/selinux/config file." + exit 1 fi # Ensuring project's source code if [ ! -d "${OS_FOLDER}" ]; then - # NOTE: Shorten link -> https://github.com/electrocucaracha/pkg-mgr_scripts - curl -fsSL http://bit.ly/install_pkg | PKG_COMMANDS_LIST="git" bash + # NOTE: Shorten link -> https://github.com/electrocucaracha/pkg-mgr_scripts + curl -fsSL http://bit.ly/install_pkg | PKG_COMMANDS_LIST="git" bash - echo "Cloning and configuring openstack-multinode project..." - sudo -E git clone --depth 1 https://github.com/electrocucaracha/openstack-multinode "${OS_FOLDER:-/opt/openstack-multinode}" - sudo chown -R "$USER" "${OS_FOLDER}" + echo "Cloning and configuring openstack-multinode project..." + sudo -E git clone --depth 1 https://github.com/electrocucaracha/openstack-multinode "${OS_FOLDER:-/opt/openstack-multinode}" + sudo chown -R "$USER" "${OS_FOLDER}" fi cd "${OS_FOLDER}" || exit sudo mkdir -p /etc/kolla/config @@ -112,7 +112,7 @@ sudo cp -R etc/kolla/* /etc/kolla/ sudo chown "$USER" /etc/kolla/passwords.yml for os_var in $(printenv | grep OS_); do - echo "export $os_var" | sudo tee --append /etc/environment + echo "export $os_var" | sudo tee --append /etc/environment done ############################### @@ -120,9 +120,9 @@ done ############################### if [ "${OS_ENABLE_LOCAL_REGISTRY:-false}" == "true" ]; then - export DOCKER_REGISTRY_IP=${mgmt_ip} - export DOCKER_REGISTRY_PORT=${DOCKER_REGISTRY_PORT} - ./registry.sh + export DOCKER_REGISTRY_IP=${mgmt_ip} + export DOCKER_REGISTRY_PORT=${DOCKER_REGISTRY_PORT} + ./registry.sh fi ################################ @@ -133,22 +133,22 @@ fi # Post-Install actions if [ "${OS_KOLLA_RUN_INIT:-true}" == "true" ]; then - python -m pip install --ignore-installed --no-warn-script-location python-openstackclient - - # PEP 370 -- Per user site-packages directory - [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin - openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion >/dev/null - - sudo chown "$USER:" /etc/kolla/admin-openrc.sh - # https://docs.openstack.org/openstacksdk/latest/user/guides/connect_from_config.html - sudo chown "$USER:" /etc/kolla/clouds.yaml || : - # shellcheck disable=SC1091 - source /etc/kolla/admin-openrc.sh - curl -fsSL "https://raw.githubusercontent.com/openstack/kolla-ansible/${OS_KOLLA_VERSION:-stable/2025.1}/tools/init-runonce" | bash - - [ "${OS_KOLLA_ENABLE_CINDER:-yes}" == "yes" ] && ./scripts/cinder.sh - [ "${OS_KOLLA_ENABLE_MAGNUM:-no}" == "yes" ] && ./scripts/magnum.sh - [ "${OS_KOLLA_ENABLE_NEUTRON_TRUNK:-yes}" == "yes" ] && ./scripts/neutron_trunk.sh + python -m pip install --ignore-installed --no-warn-script-location python-openstackclient + + # PEP 370 -- Per user site-packages directory + [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin + openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion >/dev/null + + sudo chown "$USER:" /etc/kolla/admin-openrc.sh + # https://docs.openstack.org/openstacksdk/latest/user/guides/connect_from_config.html + sudo chown "$USER:" /etc/kolla/clouds.yaml || : + # shellcheck disable=SC1091 + source /etc/kolla/admin-openrc.sh + curl -fsSL "https://raw.githubusercontent.com/openstack/kolla-ansible/${OS_KOLLA_VERSION:-stable/2025.1}/tools/init-runonce" | bash + + [ "${OS_KOLLA_ENABLE_CINDER:-yes}" == "yes" ] && ./scripts/cinder.sh + [ "${OS_KOLLA_ENABLE_MAGNUM:-no}" == "yes" ] && ./scripts/magnum.sh + [ "${OS_KOLLA_ENABLE_NEUTRON_TRUNK:-yes}" == "yes" ] && ./scripts/neutron_trunk.sh fi echo "Statistics:" diff --git a/node.sh b/node.sh index 11bbb25c1..f2231273f 100755 --- a/node.sh +++ b/node.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi # shellcheck disable=SC1091 @@ -24,7 +24,7 @@ trap 'printf "Node setup process: %s secs\n" "$(($(date +%s)-_start))"' EXIT # usage() - Prints the usage of the program function usage { - cat </dev/null; then - case ${ID,,} in - ubuntu | debian) - sudo apt-get update -qq >/dev/null - sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 fdisk - ;; - esac - fi + if ! command -v sfdisk >/dev/null; then + case ${ID,,} in + ubuntu | debian) + sudo apt-get update -qq >/dev/null + sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 fdisk + ;; + esac + fi - sudo sfdisk "$dev_name" --no-reread </dev/null; then - case ${ID,,} in - ubuntu | debian) - sudo apt-get -y -qq purge cloud-init - ;; - esac + case ${ID,,} in + ubuntu | debian) + sudo apt-get -y -qq purge cloud-init + ;; + esac fi if [ -n "${dict_volumes-}" ]; then - for kv in ${dict_volumes//,/ }; do - mount_external_partition "${kv%=*}" "${kv#*=}" - done + for kv in ${dict_volumes//,/ }; do + mount_external_partition "${kv%=*}" "${kv#*=}" + done fi if [ -n "${cinder_volumes-}" ]; then - if ! command -v vgs; then - curl -fsSL http://bit.ly/install_pkg | PKG="lvm2" bash - fi - # Creation of cinder LVM - sudo vgcreate cinder-volumes "$cinder_volumes" -f - sudo vgs - sudo pvdisplay + if ! command -v vgs; then + curl -fsSL http://bit.ly/install_pkg | PKG="lvm2" bash + fi + # Creation of cinder LVM + sudo vgcreate cinder-volumes "$cinder_volumes" -f + sudo vgs + sudo pvdisplay - # Configure LVM to only scan devices that contain the cinder-volumes volume group - filter_string="" - for pv_info in $(sudo pvs --noheadings -o name); do - filter_string+="\"a|${pv_info##*/}|\", " - done - # shellcheck disable=SC1003 - sudo sed -i -e '/# global_filter = \[.*\]/a\' -e "\tglobal_filter = [ $filter_string \"r|.*|\" ]" /etc/lvm/lvm.conf + # Configure LVM to only scan devices that contain the cinder-volumes volume group + filter_string="" + for pv_info in $(sudo pvs --noheadings -o name); do + filter_string+="\"a|${pv_info##*/}|\", " + done + # shellcheck disable=SC1003 + sudo sed -i -e '/# global_filter = \[.*\]/a\' -e "\tglobal_filter = [ $filter_string \"r|.*|\" ]" /etc/lvm/lvm.conf - sudo modprobe dm_thin_pool - echo "dm_thin_pool" | sudo tee /etc/modules-load.d/dm_thin_pool.conf - sudo modprobe target_core_mod - echo "target_core_mod" | sudo tee /etc/modules-load.d/target_core_mod.conf + sudo modprobe dm_thin_pool + echo "dm_thin_pool" | sudo tee /etc/modules-load.d/dm_thin_pool.conf + sudo modprobe target_core_mod + echo "target_core_mod" | sudo tee /etc/modules-load.d/target_core_mod.conf fi if [[ -n ${OPENSTACK_NODE_ROLES+x} ]]; then - for role in $OPENSTACK_NODE_ROLES; do - if [ -f "$role.sh" ]; then - bash "$role.sh" | sudo tee "$HOME/$role.log" - fi - done + for role in $OPENSTACK_NODE_ROLES; do + if [ -f "$role.sh" ]; then + bash "$role.sh" | sudo tee "$HOME/$role.log" + fi + done fi curl -fsSL http://bit.ly/install_bin | PKG_BINDEP_PROFILE=node bash diff --git a/registry.sh b/registry.sh index 993b6c231..7e74d14b9 100755 --- a/registry.sh +++ b/registry.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi _start=$(date +%s) trap 'printf "Registry creation process: %s secs\n" "$(($(date +%s)-_start))"' EXIT @@ -22,19 +22,19 @@ trap 'printf "Registry creation process: %s secs\n" "$(($(date +%s)-_start))"' E curl -fsSL http://bit.ly/install_pkg | PKG_COMMANDS_LIST="skopeo,docker,jq,git,crudini" bash if ! command -v uv; then - curl -LsSf https://astral.sh/uv/install.sh | sh - PATH="$HOME/.local/bin:$PATH" + curl -LsSf https://astral.sh/uv/install.sh | sh + PATH="$HOME/.local/bin:$PATH" fi if ! command -v kolla-build; then - sudo "$(command -v uv)" pip install "git+https://github.com/openstack/kolla.git@${OS_KOLLA_VERSION:-stable/2024.2}" --system - sudo "$(command -v uv)" pip install docker-squash --system + sudo "$(command -v uv)" pip install "git+https://github.com/openstack/kolla.git@${OS_KOLLA_VERSION:-stable/2024.2}" --system + sudo "$(command -v uv)" pip install docker-squash --system fi # Start local registry if [[ -z $(sudo docker ps -aqf "name=registry") ]]; then - sudo -E docker run -d --name registry --restart=always \ - -p "${DOCKER_REGISTRY_PORT:-5000}":5000 -v registry:/var/lib/registry registry:2 + sudo -E docker run -d --name registry --restart=always \ + -p "${DOCKER_REGISTRY_PORT:-5000}":5000 -v registry:/var/lib/registry registry:2 fi # Configure custom values @@ -45,28 +45,28 @@ source /etc/os-release || source /usr/lib/os-release num_cpus=$(lscpu | grep "^CPU(s):" | awk '{ print $2 }') for kv in "tag=${OPENSTACK_TAG:-"2024.2-${ID,,}-${VERSION_CODENAME:-${VERSION_ID%%.*}}"}" \ - "profile=${OS_KOLLA_PROFILE:-custom}" \ - "registry=${DOCKER_REGISTRY_IP:-127.0.0.1}:${DOCKER_REGISTRY_PORT:-5000}" \ - "openstack_release=${OPENSTACK_RELEASE:-2024.2}" \ - "base=${OS_KOLLA_BASE:-${ID,,}}" \ - "threads=$((num_cpus * 2))" \ - "push_threads=$((num_cpus * 4))"; do - sudo -E "$(command -v crudini)" --set /etc/kolla/kolla-build.ini DEFAULT "${kv%=*}" "${kv#*=}" + "profile=${OS_KOLLA_PROFILE:-custom}" \ + "registry=${DOCKER_REGISTRY_IP:-127.0.0.1}:${DOCKER_REGISTRY_PORT:-5000}" \ + "openstack_release=${OPENSTACK_RELEASE:-2024.2}" \ + "base=${OS_KOLLA_BASE:-${ID,,}}" \ + "threads=$((num_cpus * 2))" \ + "push_threads=$((num_cpus * 4))"; do + sudo -E "$(command -v crudini)" --set /etc/kolla/kolla-build.ini DEFAULT "${kv%=*}" "${kv#*=}" done bifrost_header="" bifrost_footer="" if [ -n "${HTTP_PROXY-}" ]; then - bifrost_header+="ENV http_proxy=$HTTP_PROXY\n" - bifrost_footer+="ENV http_proxy=\"\"\n" + bifrost_header+="ENV http_proxy=$HTTP_PROXY\n" + bifrost_footer+="ENV http_proxy=\"\"\n" fi if [ -n "${HTTPS_PROXY-}" ]; then - bifrost_header+="ENV https_proxy=$HTTPS_PROXY\n" - bifrost_footer+="ENV https_proxy=\"\"\n" + bifrost_header+="ENV https_proxy=$HTTPS_PROXY\n" + bifrost_footer+="ENV https_proxy=\"\"\n" fi if [ -n "${NO_PROXY-}" ]; then - bifrost_header+="ENV no_proxy=$NO_PROXY\n" - bifrost_footer+="ENV no_proxy=\"\"\n" + bifrost_header+="ENV no_proxy=$NO_PROXY\n" + bifrost_footer+="ENV no_proxy=\"\"\n" fi cat <"$HOME/template-overrides.j2" @@ -91,18 +91,18 @@ newgrp docker </dev/null - sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 curl - fi - if ! command -v dpkg-reconfigure; then - sudo dpkg-reconfigure --frontend=noninteractive locales - fi - ;; + nic="$(ip route get 1.1.1.1 | grep "^1." | awk '{ print $5 }' || :)" + if [ "${ID,,}" == "ubuntu" ] && [ -n "$nic" ] && command -v systemd-resolve && (! systemd-resolve --status | grep -q 1.1.1.1); then + sudo systemd-resolve --interface "$nic" --set-dns 1.1.1.1 + fi + if ! command -v curl; then + sudo apt-get update -qq >/dev/null + sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 curl + fi + if ! command -v dpkg-reconfigure; then + sudo dpkg-reconfigure --frontend=noninteractive locales + fi + ;; esac diff --git a/run_kaction.sh b/run_kaction.sh index fe12bed99..5214938ef 100755 --- a/run_kaction.sh +++ b/run_kaction.sh @@ -12,7 +12,7 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - set -o xtrace + set -o xtrace fi # NOTE: PYTHONPATH helps to pass the kolla_ansible module verification using Ansible's python @@ -21,20 +21,20 @@ EXTRA_OPTS="--extra ansible_user=$USER --extra ansible_become=true --extra ansib export PYTHONPATH EXTRA_OPTS function _get_kolla_ansible_cmd { - local kolla_action=$1 + local kolla_action=$1 - cmd="$(command -v kolla-ansible || echo kolla-ansible) $kolla_action --inventory ${OS_INVENTORY_FILE:-./samples/aio/hosts.ini}" - if [[ ${OS_DEBUG:-false} == "true" ]]; then - cmd+=" --verbose" - fi - if [[ $1 == "destroy" ]]; then - cmd+=" --yes-i-really-really-mean-it" - fi + cmd="$(command -v kolla-ansible || echo kolla-ansible) $kolla_action --inventory ${OS_INVENTORY_FILE:-./samples/aio/hosts.ini}" + if [[ ${OS_DEBUG:-false} == "true" ]]; then + cmd+=" --verbose" + fi + if [[ $1 == "destroy" ]]; then + cmd+=" --yes-i-really-really-mean-it" + fi - echo "$cmd" + echo "$cmd" } if [[ ${__name__:-"__main__"} == "__main__" ]]; then - ansible_cmd=$(_get_kolla_ansible_cmd "$1") - $ansible_cmd + ansible_cmd=$(_get_kolla_ansible_cmd "$1") + $ansible_cmd fi diff --git a/scripts/cinder.sh b/scripts/cinder.sh index 6ac834a26..8c438a185 100755 --- a/scripts/cinder.sh +++ b/scripts/cinder.sh @@ -12,13 +12,13 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi os_cinder_volume_type="lvm-1" if ! openstack volume type list | grep -q "$os_cinder_volume_type"; then - openstack volume type create "$os_cinder_volume_type" \ - --property volume_backend_name="$os_cinder_volume_type" + openstack volume type create "$os_cinder_volume_type" \ + --property volume_backend_name="$os_cinder_volume_type" fi diff --git a/scripts/magnum.sh b/scripts/magnum.sh index 27ffd895a..08aff483a 100755 --- a/scripts/magnum.sh +++ b/scripts/magnum.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi fedora_image_file="$HOME/Fedora-Cloud.qcow2" @@ -28,32 +28,32 @@ os_magnum_cluster=${1:-kubernetes-cluster} curl -fsSL http://bit.ly/install_pkg | PKG_COMMANDS_LIST="pip,kubectl" bash if ! command -v magnum; then - python -m pip install python-magnumclient + python -m pip install python-magnumclient fi if [ ! -f "$fedora_image_file" ]; then - curl -o "$fedora_image_file" -sL https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2 + curl -o "$fedora_image_file" -sL https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2 fi if ! openstack image list --name "$os_glance_image" | grep -q "$os_glance_image"; then - openstack image create --disk-format=qcow2 --container-format=bare \ - --file="$fedora_image_file" --property os_distro='fedora-atomic' \ - "$os_glance_image" + openstack image create --disk-format=qcow2 --container-format=bare \ + --file="$fedora_image_file" --property os_distro='fedora-atomic' \ + "$os_glance_image" fi if ! openstack coe cluster template list | grep -q "$os_magnum_template"; then - openstack coe cluster template create "$os_magnum_template" \ - --image "$os_glance_image" --external-network public1 \ - --dns-nameserver 8.8.8.8 --master-flavor m1.small \ - --flavor m1.small --coe kubernetes --docker-volume-size 3 + openstack coe cluster template create "$os_magnum_template" \ + --image "$os_glance_image" --external-network public1 \ + --dns-nameserver 8.8.8.8 --master-flavor m1.small \ + --flavor m1.small --coe kubernetes --docker-volume-size 3 fi if ! openstack coe cluster list | grep -q "$os_magnum_cluster"; then - openstack coe cluster create "$os_magnum_cluster" \ - --cluster-template "$os_magnum_template" \ - --master-count 1 \ - --node-count 1 \ - --keypair mykey + openstack coe cluster create "$os_magnum_cluster" \ + --cluster-template "$os_magnum_template" \ + --master-count 1 \ + --node-count 1 \ + --keypair mykey fi mkdir -p ~/clusters/kubernetes-cluster diff --git a/scripts/neutron_trunk.sh b/scripts/neutron_trunk.sh index 771c2373c..b517e90c3 100755 --- a/scripts/neutron_trunk.sh +++ b/scripts/neutron_trunk.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi net_prefix=demo-net @@ -24,39 +24,39 @@ port_prefix=demo-port [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin if ! command -v neutron >/dev/null; then - python -m pip install python-neutronclient + python -m pip install python-neutronclient fi # Create networks and subnets for the trunk and subports for i in $(seq 1 5); do - if ! openstack network list -c Name | grep -q "$net_prefix$i"; then - openstack network create "$net_prefix$i" - fi - if ! openstack subnet list -c Name | grep -q "$subnet_prefix$i"; then - openstack subnet create --network "$net_prefix$i" --subnet-range "10.0.$i.0/24" "$subnet_prefix$i" - fi - if ! openstack port list -c name | grep -q "$port_prefix$i"; then - openstack port create --network "$net_prefix$i" "$port_prefix$i" - fi + if ! openstack network list -c Name | grep -q "$net_prefix$i"; then + openstack network create "$net_prefix$i" + fi + if ! openstack subnet list -c Name | grep -q "$subnet_prefix$i"; then + openstack subnet create --network "$net_prefix$i" --subnet-range "10.0.$i.0/24" "$subnet_prefix$i" + fi + if ! openstack port list -c name | grep -q "$port_prefix$i"; then + openstack port create --network "$net_prefix$i" "$port_prefix$i" + fi done if ! openstack port list -c name | grep -q "trunk-parent"; then - openstack port create --network demo-net trunk-parent + openstack port create --network demo-net trunk-parent fi # Create the trunk and add subports to the trunk if ! openstack network trunk list -c Name | grep -q "trunk1"; then - openstack network trunk create --parent-port trunk-parent trunk1 + openstack network trunk create --parent-port trunk-parent trunk1 fi for i in $(seq 1 5); do - openstack network trunk set \ - --subport port="$port_prefix$i,segmentation-type=vlan,segmentation-id=$i" \ - trunk1 + openstack network trunk set \ + --subport port="$port_prefix$i,segmentation-type=vlan,segmentation-id=$i" \ + trunk1 done openstack network trunk show trunk1 if ! openstack server list -c Name | grep -q "demo1"; then - openstack server create --image cirros --flavor m1.tiny \ - --key-name mykey --port trunk-parent --use-config-drive \ - demo1 + openstack server create --image cirros --flavor m1.tiny \ + --key-name mykey --port trunk-parent --use-config-drive \ + demo1 fi diff --git a/undercloud.sh b/undercloud.sh index b46cf6d97..8c1435cee 100755 --- a/undercloud.sh +++ b/undercloud.sh @@ -12,8 +12,8 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - export PKG_DEBUG=true - set -o xtrace + export PKG_DEBUG=true + set -o xtrace fi source defaults.env @@ -22,123 +22,123 @@ source commons.sh source /etc/os-release || source /usr/lib/os-release function _setup_proxy { - if [ -n "${HTTP_PROXY-}" ]; then - sed -i "s|^container_http_proxy: .*$|container_http_proxy: \"${HTTP_PROXY}\"|g" ~/.local/share/kolla-ansible/ansible/group_vars/all.yml - echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf - echo "Environment=\"HTTP_PROXY=$HTTP_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/http-proxy.conf - fi - if [ -n "${HTTPS_PROXY-}" ]; then - sed -i "s|^container_https_proxy: .*$|container_https_proxy: \"${HTTPS_PROXY}\"|g" ~/.local/share/kolla-ansible/ansible/group_vars/all.yml - echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/https-proxy.conf - echo "Environment=\"HTTPS_PROXY=$HTTPS_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/https-proxy.conf - fi - if [ -n "${NO_PROXY-}" ]; then - sed -i "s|^container_no_proxy: .*$|container_no_proxy: \"${NO_PROXY}\"|g" ~/.local/share/kolla-ansible/ansible/group_vars/all.yml - echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/no-proxy.conf - echo "Environment=\"NO_PROXY=$NO_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/no-proxy.conf - fi + if [ -n "${HTTP_PROXY-}" ]; then + sed -i "s|^container_http_proxy: .*$|container_http_proxy: \"${HTTP_PROXY}\"|g" ~/.local/share/kolla-ansible/ansible/group_vars/all.yml + echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf + echo "Environment=\"HTTP_PROXY=$HTTP_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/http-proxy.conf + fi + if [ -n "${HTTPS_PROXY-}" ]; then + sed -i "s|^container_https_proxy: .*$|container_https_proxy: \"${HTTPS_PROXY}\"|g" ~/.local/share/kolla-ansible/ansible/group_vars/all.yml + echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/https-proxy.conf + echo "Environment=\"HTTPS_PROXY=$HTTPS_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/https-proxy.conf + fi + if [ -n "${NO_PROXY-}" ]; then + sed -i "s|^container_no_proxy: .*$|container_no_proxy: \"${NO_PROXY}\"|g" ~/.local/share/kolla-ansible/ansible/group_vars/all.yml + echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/no-proxy.conf + echo "Environment=\"NO_PROXY=$NO_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/no-proxy.conf + fi } function _get_kolla_actions { - local kolla_ansible_version="$1" - local kolla_deploy_profile="${2:-$OS_KOLLA_DEPLOY_PROFILE}" - - kolla_actions=(bootstrap-servers) - # Install Ansible Galaxy dependencies (Yoga release onwards) - if vercmp "$kolla_ansible_version" '>=' '14'; then - kolla_actions=(install-deps "${kolla_actions[@]}") - fi - if [ "${kolla_deploy_profile}" == "complete" ]; then - kolla_actions=("${kolla_actions[@]}" prechecks pull) - fi - kolla_actions=("${kolla_actions[@]}" deploy) - if [ "${kolla_deploy_profile}" == "complete" ] && vercmp "$kolla_ansible_version" '<' '15'; then - # NOTE: Smoke tests have been removed in Zed release (https://github.com/openstack/kolla-ansible/commit/591f366ed736977664e899bd834e363191a9472d#diff-707286526f137598948e03470854d542446836f5dd83cbfcb30caab67bb6c7bb) - kolla_actions=("${kolla_actions[@]}" check) - fi - kolla_actions=("${kolla_actions[@]}" post-deploy) - - echo "${kolla_actions[@]}" + local kolla_ansible_version="$1" + local kolla_deploy_profile="${2:-$OS_KOLLA_DEPLOY_PROFILE}" + + kolla_actions=(bootstrap-servers) + # Install Ansible Galaxy dependencies (Yoga release onwards) + if vercmp "$kolla_ansible_version" '>=' '14'; then + kolla_actions=(install-deps "${kolla_actions[@]}") + fi + if [ "${kolla_deploy_profile}" == "complete" ]; then + kolla_actions=("${kolla_actions[@]}" prechecks pull) + fi + kolla_actions=("${kolla_actions[@]}" deploy) + if [ "${kolla_deploy_profile}" == "complete" ] && vercmp "$kolla_ansible_version" '<' '15'; then + # NOTE: Smoke tests have been removed in Zed release (https://github.com/openstack/kolla-ansible/commit/591f366ed736977664e899bd834e363191a9472d#diff-707286526f137598948e03470854d542446836f5dd83cbfcb30caab67bb6c7bb) + kolla_actions=("${kolla_actions[@]}" check) + fi + kolla_actions=("${kolla_actions[@]}" post-deploy) + + echo "${kolla_actions[@]}" } function _remove_conflicting_python_pkgs { - case ${ID,,} in - ubuntu | debian) - sanity_pkgs="" - for pkg in python-cryptography python3-cryptography python3-distro-info python3-debian python3-openssl python3-docker python3-urllib3; do - if sudo dpkg -l "$pkg" >/dev/null; then - sanity_pkgs+="$pkg " - fi - done - eval "sudo apt remove -y $sanity_pkgs" - ;; - esac + case ${ID,,} in + ubuntu | debian) + sanity_pkgs="" + for pkg in python-cryptography python3-cryptography python3-distro-info python3-debian python3-openssl python3-docker python3-urllib3; do + if sudo dpkg -l "$pkg" >/dev/null; then + sanity_pkgs+="$pkg " + fi + done + eval "sudo apt remove -y $sanity_pkgs" + ;; + esac } function _install_deps { - _remove_conflicting_python_pkgs - - # Install dependencies - curl -fsSL http://bit.ly/install_bin | PKG_BINDEP_PROFILE=undercloud PKG_COMMANDS_LIST="yq" PKG_UPDATE=true bash - - # Install Kolla-Ansible dependencies - sudo ln -s "$(command -v pip3)" /usr/bin/pip3 || : - python -m pip install --ignore-installed --no-warn-script-location --requirement "requirements/${OPENSTACK_RELEASE}/${ID,,}_${VERSION_ID%.*}.txt" - # PEP 370 -- Per user site-packages directory - [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin - # https://review.opendev.org/c/openstack/kolla-ansible/+/584427/17/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2#6 - sudo find / -name rabbitmq-env.conf.j2 -exec sed -i '/export ERL_EPMD_ADDRESS/d' {} \; + _remove_conflicting_python_pkgs + + # Install dependencies + curl -fsSL http://bit.ly/install_bin | PKG_BINDEP_PROFILE=undercloud PKG_COMMANDS_LIST="yq" PKG_UPDATE=true bash + + # Install Kolla-Ansible dependencies + sudo ln -s "$(command -v pip3)" /usr/bin/pip3 || : + python -m pip install --ignore-installed --no-warn-script-location --requirement "requirements/${OPENSTACK_RELEASE}/${ID,,}_${VERSION_ID%.*}.txt" + # PEP 370 -- Per user site-packages directory + [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin + # https://review.opendev.org/c/openstack/kolla-ansible/+/584427/17/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2#6 + sudo find / -name rabbitmq-env.conf.j2 -exec sed -i '/export ERL_EPMD_ADDRESS/d' {} \; } function _cleanup_docker_services { - # Remove docker source list to avoid update conflicts - [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin - ansible control -i "${OS_INVENTORY_FILE:-./samples/aio/hosts.ini}" -m file \ - -a 'path=/etc/apt/sources.list.d/docker.list state=absent' -b \ - -e "ansible_user=$USER" - sudo rm -f /etc/docker/daemon.json + # Remove docker source list to avoid update conflicts + [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin + ansible control -i "${OS_INVENTORY_FILE:-./samples/aio/hosts.ini}" -m file \ + -a 'path=/etc/apt/sources.list.d/docker.list state=absent' -b \ + -e "ansible_user=$USER" + sudo rm -f /etc/docker/daemon.json } function _run_kolla_ansible { - # PEP 370 -- Per user site-packages directory - [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin - kolla-genpwd - kolla_ansible_version="$(pip freeze | grep kolla-ansible | sed 's/^.*=//')" - # shellcheck disable=SC2046 - run_kolla_actions $(_get_kolla_actions "$kolla_ansible_version") - sudo chown "$USER" /etc/kolla/admin-openrc.sh - # shellcheck disable=SC2002 - cat /etc/kolla/admin-openrc.sh | sudo tee --append /etc/environment + # PEP 370 -- Per user site-packages directory + [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin + kolla-genpwd + kolla_ansible_version="$(pip freeze | grep kolla-ansible | sed 's/^.*=//')" + # shellcheck disable=SC2046 + run_kolla_actions $(_get_kolla_actions "$kolla_ansible_version") + sudo chown "$USER" /etc/kolla/admin-openrc.sh + # shellcheck disable=SC2002 + cat /etc/kolla/admin-openrc.sh | sudo tee --append /etc/environment } function main { - sudo touch /etc/timezone + sudo touch /etc/timezone - _start=$(date +%s) - trap 'printf "Provisioning process: %s secs\n" "$(($(date +%s)-_start))"' EXIT + _start=$(date +%s) + trap 'printf "Provisioning process: %s secs\n" "$(($(date +%s)-_start))"' EXIT - _install_deps - sudo mkdir -p /etc/{kolla,ansible,systemd/system/docker.service.d} + _install_deps + sudo mkdir -p /etc/{kolla,ansible,systemd/system/docker.service.d} - # Setup configuration values - if [ "${OS_ENABLE_LOCAL_REGISTRY:-false}" == "true" ]; then - export OS_KOLLA_DOCKER_REGISTRY="${DOCKER_REGISTRY_IP:-127.0.0.1}:${DOCKER_REGISTRY_PORT:-5000}" - export OS_KOLLA_DOCKER_REGISTRY_INSECURE="yes" - export OS_KOLLA_DOCKER_NAMESPACE="kolla" - fi - set_values - _setup_proxy - setup_ansible + # Setup configuration values + if [ "${OS_ENABLE_LOCAL_REGISTRY:-false}" == "true" ]; then + export OS_KOLLA_DOCKER_REGISTRY="${DOCKER_REGISTRY_IP:-127.0.0.1}:${DOCKER_REGISTRY_PORT:-5000}" + export OS_KOLLA_DOCKER_REGISTRY_INSECURE="yes" + export OS_KOLLA_DOCKER_NAMESPACE="kolla" + fi + set_values + _setup_proxy + setup_ansible - _cleanup_docker_services + _cleanup_docker_services - _run_kolla_ansible + _run_kolla_ansible - if groups | grep -q docker && (! getent group docker | grep -q "$USER"); then - sudo usermod -aG docker "$USER" - fi + if groups | grep -q docker && (! getent group docker | grep -q "$USER"); then + sudo usermod -aG docker "$USER" + fi } if [[ ${__name__:-"__main__"} == "__main__" ]]; then - main + main fi diff --git a/upgrade.sh b/upgrade.sh index d1985e5a1..9264eeeff 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -12,7 +12,7 @@ set -o nounset set -o pipefail set -o errexit if [[ ${OS_DEBUG:-false} == "true" ]]; then - set -o xtrace + set -o xtrace fi source defaults.env @@ -21,46 +21,46 @@ source commons.sh source /etc/os-release || source /usr/lib/os-release function _print_state { - # PEP 370 -- Per user site-packages directory - [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin - if command -v openstack; then - echo "OpenStack client version" - openstack --version + # PEP 370 -- Per user site-packages directory + [[ $PATH != *.local/bin* ]] && export PATH=$PATH:$HOME/.local/bin + if command -v openstack; then + echo "OpenStack client version" + openstack --version - echo "OpenStack service versions" - openstack versions show - fi + echo "OpenStack service versions" + openstack versions show + fi - echo "OpenStack Kolla version" - pip freeze | grep kolla + echo "OpenStack Kolla version" + pip freeze | grep kolla - if command -v docker; then - echo "OpenStack Kolla services" - sudo docker ps - fi + if command -v docker; then + echo "OpenStack Kolla services" + sudo docker ps + fi } function _install_deps { - if ! command -v pip; then - # NOTE: Shorten link -> https://github.com/electrocucaracha/pkg-mgr_scripts - curl -fsSL http://bit.ly/install_pkg | PKG=pip bash - fi - echo "Upgrade OpenStack services to ${OPENSTACK_RELEASE} release" - # NOTE: Uninstall mitogen given that it's only supported in some Ansible versions (2.13.x) - pip uninstall mitogen --yes - python -m pip install --ignore-installed --no-warn-script-location --requirement "requirements/${OPENSTACK_RELEASE}/${ID,,}_${VERSION_ID%.*}.txt" - setup_ansible + if ! command -v pip; then + # NOTE: Shorten link -> https://github.com/electrocucaracha/pkg-mgr_scripts + curl -fsSL http://bit.ly/install_pkg | PKG=pip bash + fi + echo "Upgrade OpenStack services to ${OPENSTACK_RELEASE} release" + # NOTE: Uninstall mitogen given that it's only supported in some Ansible versions (2.13.x) + pip uninstall mitogen --yes + python -m pip install --ignore-installed --no-warn-script-location --requirement "requirements/${OPENSTACK_RELEASE}/${ID,,}_${VERSION_ID%.*}.txt" + setup_ansible } function main { - _print_state - trap _print_state EXIT + _print_state + trap _print_state EXIT - _install_deps - set_values - run_kolla_actions pull upgrade + _install_deps + set_values + run_kolla_actions pull upgrade } if [[ ${__name__:-"__main__"} == "__main__" ]]; then - main + main fi