Skip to content

Commit a86d1df

Browse files
authored
Merge pull request #2142 from stackhpc/2024.1/ubuntu-upgrade-script-bash
Improve ubuntu upgrade bash scripts
2 parents eaa3678 + d09fd56 commit a86d1df

4 files changed

Lines changed: 38 additions & 33 deletions

File tree

tools/ubuntu-upgrade-infra-vm.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
#! /usr/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

5-
if [[ ! $1 ]]; then
5+
if [[ -z "$1" ]]; then
66
echo "Usage: infra-vm-ubuntu-upgrade.sh <infra-vm-hostname>"
77
exit 2
88
fi
99

10-
if [[ ! $KAYOBE_PATH ]]; then
10+
if [[ -z "$KAYOBE_PATH" ]]; then
1111
echo "Environment variable \$KAYOBE_PATH is not defined"
1212
exit 2
1313
fi
1414

15-
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
15+
if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then
1616
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
1717
exit 2
1818
fi
1919

20-
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
20+
if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then
2121
set -x
22-
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
22+
export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles"
2323
set +x
2424
else
2525
set -x
26-
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
26+
export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles"
2727
set +x
2828
fi
2929

3030
set -x
3131

32-
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit $1
32+
kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \
33+
-e os_release=noble --limit "$1"
3334

34-
kayobe infra vm host configure --limit $1 -e os_release=noble
35+
kayobe infra vm host configure --limit "$1" -e os_release=noble

tools/ubuntu-upgrade-overcloud.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
1-
#! /usr/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

5-
if [[ ! $1 ]]; then
5+
if [[ -z "$1" ]]; then
66
echo "Usage: overcloud-ubuntu-upgrade.sh <overcloud-hostname>"
77
exit 2
88
fi
99

10-
if [[ ! $KAYOBE_PATH ]]; then
10+
if [[ -z "$KAYOBE_PATH" ]]; then
1111
echo "Environment variable \$KAYOBE_PATH is not defined"
1212
exit 2
1313
fi
1414

15-
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
15+
if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then
1616
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
1717
exit 2
1818
fi
1919

20-
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
20+
if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then
2121
set -x
22-
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
22+
export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles"
2323
set +x
2424
else
2525
set -x
26-
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
26+
export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles"
2727
set +x
2828
fi
2929

3030
set -x
3131

32-
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit $1
32+
kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \
33+
-e os_release=noble --limit "$1"
3334

34-
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ovn-fix-chassis-priorities.yml
35+
kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ovn-fix-chassis-priorities.yml"
36+
37+
kayobe overcloud host configure --limit "$1" -e os_release=noble
3538

36-
kayobe overcloud host configure --limit $1 -e os_release=noble
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
#! /usr/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

5-
if [[ ! $KAYOBE_PATH ]]; then
5+
if [[ -z "$KAYOBE_PATH" ]]; then
66
echo "Environment variable \$KAYOBE_PATH is not defined"
77
exit 2
88
fi
99

10-
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
10+
if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then
1111
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
1212
exit 2
1313
fi
1414

15-
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
15+
if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then
1616
set -x
17-
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
17+
export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles"
1818
set +x
1919
else
2020
set -x
21-
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
21+
export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles"
2222
set +x
2323
fi
2424

2525
set -x
2626

27-
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit seed-hypervisor
27+
kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \
28+
-e os_release=noble --limit seed-hypervisor
2829

2930
kayobe seed hypervisor host configure -e os_release=noble

tools/ubuntu-upgrade-seed.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
#! /usr/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

5-
if [[ ! $KAYOBE_PATH ]]; then
5+
if [[ -z "$KAYOBE_PATH" ]]; then
66
echo "Environment variable \$KAYOBE_PATH is not defined"
77
exit 2
88
fi
99

10-
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
10+
if [[ -z "$KAYOBE_CONFIG_PATH" ]]; then
1111
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
1212
exit 2
1313
fi
1414

15-
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
15+
if [[ -z "$ANSIBLE_ROLES_PATH" ]]; then
1616
set -x
17-
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
17+
export ANSIBLE_ROLES_PATH="$KAYOBE_PATH/ansible/roles"
1818
set +x
1919
else
2020
set -x
21-
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
21+
export ANSIBLE_ROLES_PATH="$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles"
2222
set +x
2323
fi
2424

2525
set -x
2626

27-
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=noble --limit seed
27+
kayobe playbook run "$KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml" \
28+
-e os_release=noble --limit seed
2829

2930
kayobe seed host configure -e os_release=noble

0 commit comments

Comments
 (0)