-
Notifications
You must be signed in to change notification settings - Fork 25
Improve ubuntu upgrade bash scripts #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stackhpc/2024.1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,34 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||
| #! /usr/bin/bash | ||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [[ ! $1 ]]; then | ||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$1" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Usage: infra-vm-ubuntu-upgrade.sh <infra-vm-hostname>" | ||||||||||||||||||||||||||||||||||||||||
| exit 2 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [[ ! $KAYOBE_PATH ]]; then | ||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$KAYOBE_PATH" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Environment variable \$KAYOBE_PATH is not defined" | ||||||||||||||||||||||||||||||||||||||||
| exit 2 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [[ ! $KAYOBE_CONFIG_PATH ]]; then | ||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined" | ||||||||||||||||||||||||||||||||||||||||
| exit 2 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [[ ! $ANSIBLE_ROLES_PATH ]]; then | ||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| set -x | ||||||||||||||||||||||||||||||||||||||||
| export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles | ||||||||||||||||||||||||||||||||||||||||
| export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles" | ||||||||||||||||||||||||||||||||||||||||
| set +x | ||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||
| set -x | ||||||||||||||||||||||||||||||||||||||||
| export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles | ||||||||||||||||||||||||||||||||||||||||
| export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles" | ||||||||||||||||||||||||||||||||||||||||
| set +x | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic for setting
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| set -x | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit $1 | ||||||||||||||||||||||||||||||||||||||||
| kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \ | ||||||||||||||||||||||||||||||||||||||||
| -e os_release=noble --limit "$1" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| kayobe infra vm host configure --limit $1 -e os_release=noble | ||||||||||||||||||||||||||||||||||||||||
| kayobe infra vm host configure --limit "$1" -e os_release=noble | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,38 @@ | ||
| #! /usr/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| if [[ ! $1 ]]; then | ||
| if [[ -z "$1" ]]; then | ||
| echo "Usage: overcloud-ubuntu-upgrade.sh <overcloud-hostname>" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $KAYOBE_PATH ]]; then | ||
| if [[ -z "$KAYOBE_PATH" ]]; then | ||
| echo "Environment variable \$KAYOBE_PATH is not defined" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $KAYOBE_CONFIG_PATH ]]; then | ||
| if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then | ||
| echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $ANSIBLE_ROLES_PATH ]]; then | ||
| if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then | ||
| set -x | ||
| export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles | ||
| export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles" | ||
| set +x | ||
| else | ||
| set -x | ||
| export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles | ||
| export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles" | ||
| set +x | ||
| fi | ||
|
|
||
| set -x | ||
|
|
||
| kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit $1 | ||
| kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \ | ||
| -e os_release=noble --limit "$1" | ||
|
|
||
| kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ovn-fix-chassis-priorities.yml | ||
| kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ovn-fix-chassis-priorities.yml" | ||
|
|
||
| kayobe overcloud host configure --limit "$1" -e os_release=noble | ||
|
|
||
| kayobe overcloud host configure --limit $1 -e os_release=noble |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,30 @@ | ||
| #! /usr/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| if [[ ! $KAYOBE_PATH ]]; then | ||
| if [[ -z "$KAYOBE_PATH" ]]; then | ||
| echo "Environment variable \$KAYOBE_PATH is not defined" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $KAYOBE_CONFIG_PATH ]]; then | ||
| if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then | ||
| echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $ANSIBLE_ROLES_PATH ]]; then | ||
| if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then | ||
| set -x | ||
| export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles | ||
| export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles" | ||
| set +x | ||
| else | ||
| set -x | ||
| export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles | ||
| export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles" | ||
| set +x | ||
| fi | ||
|
|
||
| set -x | ||
|
|
||
| kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit seed-hypervisor | ||
| kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \ | ||
| -e os_release=noble --limit seed-hypervisor | ||
|
|
||
| kayobe seed hypervisor host configure -e os_release=noble |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,30 @@ | ||
| #! /usr/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| if [[ ! $KAYOBE_PATH ]]; then | ||
| if [[ -z "$KAYOBE_PATH" ]]; then | ||
| echo "Environment variable \$KAYOBE_PATH is not defined" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $KAYOBE_CONFIG_PATH ]]; then | ||
| if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then | ||
| echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ ! $ANSIBLE_ROLES_PATH ]]; then | ||
| if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then | ||
| set -x | ||
| export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles | ||
| export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles" | ||
| set +x | ||
| else | ||
| set -x | ||
| export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles | ||
| export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles" | ||
| set +x | ||
| fi | ||
|
|
||
| set -x | ||
|
|
||
| kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit seed | ||
| kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \ | ||
| -e os_release=noble --limit seed | ||
|
|
||
| kayobe seed host configure -e os_release=noble |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For checking required environment variables, you can use parameter expansion to make the code more concise and idiomatic. This will check if the variable is set and not empty, and if not, it will print the error message to stderr and exit the script due to
set -e. This pattern can be applied to the other scripts as well.