Skip to content

Commit cc4b004

Browse files
authored
Minor fixes for Ubuntu 20.04, and then Python3 AND Rocky9 support (#277)
Adds python3, ubuntu 20.04 and Rocky 9 support. Adds `--debug` flag. Signed-off-by: Jeremy J. Miller <[email protected]>
1 parent 7f7e0c2 commit cc4b004

File tree

30 files changed

+301
-110
lines changed

30 files changed

+301
-110
lines changed

group_vars/glance.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
glance_filesystem_store_datadir: /var/opt/pf9/imagelibrary/data
55
glance_public_endpoint: False
66
glance_images:
7-
- https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
8-
- https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img
9-
#- https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img
10-
- http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
7+
- http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img

inventory/pf9.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self):
2929
else:
3030
self.inventory = self.empty_inventory()
3131

32-
print json.dumps(self.inventory)
32+
print(json.dumps(self.inventory))
3333

3434
def get_du_inventory(self):
3535
"""
@@ -46,7 +46,7 @@ def get_du_inventory(self):
4646
try:
4747
os_token_file = open(self.pf9_keystone_file)
4848
os_token = os_token_file.read().strip()
49-
except Exception, err:
49+
except Exception(err):
5050
raise err
5151
else:
5252
return self.empty_inventory()
@@ -62,7 +62,7 @@ def get_du_inventory(self):
6262
response = requests.get(url, headers=headers)
6363
except requests.exceptions.MissingSchema as err:
6464
response = requests.get("https://%s" % url, headers=headers)
65-
except Exception, err:
65+
except Exception(err):
6666
return self.empty_inventory()
6767

6868
# Return empty inventory if token is not good

pf9-express

+75-50
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# initialize variables
88
basedir=$(dirname $0)
9-
min_ansible_version="2.2"
9+
min_ansible_version="2.02"
1010
oscli_version=pike
1111
oscli_rc_file=${basedir}/pf9-openstack.rc
1212
inventory=${basedir}/inventory/hosts
@@ -38,6 +38,7 @@ flag_csvImport=0
3838
flag_deauth=0
3939
flag_k8s_upgrade=0
4040
flag_pmk_only=0
41+
verbosity=""
4142
extra_vars=""
4243
awx_pf9_user="pf9"
4344
awx_pf9_password="Pl@tform9"
@@ -61,6 +62,7 @@ usage() {
6162
echo "-l|--log : Log output file. Assumes parent directory already exists."
6263
echo "-u|--upgradeK8s : upgrade Kubernetes nodes"
6364
echo "-v|--inventory <file> : use alternate inventory file for Ansible"
65+
echo "-g|--debug : use extra ansible verbosity for debugging"
6466
echo "-f|--csvFile <file> : import CSV file"
6567
echo "-t|--tag <tag[,<tag>]> : available tags = [live-migration, image-import]"
6668
echo -e "-h|--help : display this message\n"
@@ -195,13 +197,19 @@ validate_platform() {
195197
host_os_info=$(cat /etc/centos-release)
196198
elif [ -r /etc/lsb-release ]; then
197199
release=$(cat /etc/lsb-release | grep ^DISTRIB_RELEASE= /etc/lsb-release | cut -d '=' -f2)
198-
if [[ ! "${release}" == 16.04* ]] && [[ ! "${release}" == 18.04* ]]; then assert "unsupported Ubuntu release: ${release}"; fi
200+
if [[ ! "${release}" == 16.04* ]] && [[ ! "${release}" == 18.04* ]] && [[ ! "${release}" == 20.04* ]] ; then assert "unsupported Ubuntu release: ${release}"; fi
199201
platform="ubuntu"
200202
ubuntu_release=$(cat /etc/lsb-release | grep ^DISTRIB_RELEASE | cut -d = -f2)
201203
host_os_info="${platform} ${ubuntu_release}"
204+
elif [ -r /etc/rocky-release ]; then
205+
release=$(cat /etc/rocky-release | cut -d ' ' -f 4)
206+
if [[ ! "${release}" == 9.* ]]; then assert "unsupported Rocky release: ${release}"; fi
207+
platform="rocky"
208+
host_os_info=$(cat /etc/rocky-release)
202209
else
203210
assert "unsupported platform"
204211
fi
212+
echo "Found release $release on platform $platform"
205213
}
206214

207215
banner() {
@@ -328,10 +336,20 @@ install_oscli() {
328336
# source rc file
329337
source ${oscli_rc_file}
330338

331-
# install openstack cli packages (CentOS)
339+
pip install python-openstackclient> ${log} 2>&1
340+
echo "You may need to add /usr/local/bin to your \$PATH"
341+
echo "export PATH=\$PATH:/usr/local/bin"
342+
}
343+
344+
install_prereqs() {
345+
echo "--> Installing Prerequisites"
346+
# display log
347+
echo "--> Installation Log: ${install_log}"
348+
349+
# install Ansible (and dependencies)
350+
echo -n "--> Validating package dependencies: "
332351
if [ "${platform}" == "centos" ]; then
333-
echo -n "--> Installing Package Dependencies: "
334-
for pkg in gcc openssl-devel python-pip python-wheel python-virtualenv python-virtualenvwrapper; do
352+
for pkg in epel-release ntp nginx gcc python-devel python3-pip jq bc; do
335353
echo -n "${pkg} "
336354
rpm -q ${pkg} > /dev/null 2>&1
337355
if [ $? -ne 0 ]; then
@@ -342,46 +360,50 @@ install_oscli() {
342360
fi
343361
fi
344362
done
345-
echo
346-
347-
echo "--> Configuring Python Virtual Environment"
348-
if [ ! -r /usr/bin/virtualenvwrapper.sh ]; then assert "missing script: /usr/bin/virtualenvwrapper.sh"; fi
349-
source /usr/bin/virtualenvwrapper.sh
350-
export WORKON_HOME=$HOME/.virtenvs
351-
mkvirtualenv os_cli > ${log} 2>&1
352-
353-
echo "--> Upgrading PIP"
354-
pip install pip==20.3.4 --upgrade > ${log} 2>&1
355-
356-
echo "--> Installing OpenStack CLI"
357-
pip install --upgrade --requirement \
358-
https://raw.githubusercontent.com/platform9/support-locker/master/openstack-clients/requirements.txt \
359-
--constraint http://raw.githubusercontent.com/openstack/requirements/stable/${oscli_version}/upper-constraints.txt > ${log} 2>&1
360363

361-
# tracking alternate method of installation
362-
# echo "--> Installing OpenStack CLI"
363-
# pip install python-openstackclient> ${log} 2>&1
364-
fi
365-
366-
# install openstack cli packages (Ubuntu)
367-
if [ "${platform}" == "ubuntu" ]; then
368-
assert "Not Implemented (for platform = ${platform})"
369-
fi
364+
## upgrade pip
365+
sudo pip install --upgrade pip > ${log} 2>&1
366+
if [ $? -ne 0 ]; then
367+
echo -e "\nERROR: failed to upgrade pip - here's the last 10 lines of the log:\n"
368+
tail -10 ${log}; exit 1
369+
fi
370370

371-
}
371+
# Install pbr
372+
for pkg in pbr; do
373+
echo -n "${pkg} "
374+
sudo pip install ${pkg} --ignore-installed > ${log} 2>&1
375+
if [ $? -ne 0 ]; then
376+
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
377+
tail -10 ${log}; exit 1
378+
fi
379+
done
372380

373-
install_prereqs() {
374-
# display log
375-
echo "--> Installation Log: ${install_log}"
381+
## install additional pip-based packages
382+
for pkg in 'openstacksdk==0.62.0' docker-py pyopenssl; do
383+
echo -n "${pkg} "
384+
sudo pip install ${pkg} --upgrade > ${log} 2>&1
385+
if [ $? -ne 0 ]; then
386+
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
387+
tail -10 ${log}; exit 1
388+
fi
389+
done
376390

377-
# install Ansible (and dependencies)
378-
echo -n "--> Validating package dependencies: "
379-
if [ "${platform}" == "centos" ]; then
380-
for pkg in epel-release ntp nginx gcc python-devel python2-pip jq bc; do
391+
## install additional yum-based packages
392+
for pkg in ansible; do
381393
echo -n "${pkg} "
382-
rpm -q ${pkg} > /dev/null 2>&1
394+
sudo yum -y install ${pkg} > ${log} 2>&1
383395
if [ $? -ne 0 ]; then
384-
sudo yum -y install ${pkg} > ${log} 2>&1
396+
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
397+
tail -10 ${log}; exit 1
398+
fi
399+
done
400+
echo
401+
elif [ "${platform}" == "rocky" ]; then
402+
for pkg in epel-release chrony nginx gcc python3-devel python3-pip jq bc; do
403+
echo -n "${pkg} "
404+
dnf list installed | grep "^${pkg}\." > /dev/null 2>&1
405+
if [ $? -ne 0 ]; then
406+
sudo dnf -y install ${pkg} > ${log} 2>&1
385407
if [ $? -ne 0 ]; then
386408
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
387409
tail -10 ${log}; exit 1
@@ -390,14 +412,14 @@ install_prereqs() {
390412
done
391413

392414
## upgrade pip
393-
sudo pip install --upgrade pip==20.3.4 > ${log} 2>&1
415+
sudo pip install --upgrade pip > ${log} 2>&1
394416
if [ $? -ne 0 ]; then
395417
echo -e "\nERROR: failed to upgrade pip - here's the last 10 lines of the log:\n"
396418
tail -10 ${log}; exit 1
397419
fi
398420

399421
# Install pbr
400-
for pkg in 'pbr==5.6.0'; do
422+
for pkg in pbr; do
401423
echo -n "${pkg} "
402424
sudo pip install ${pkg} --ignore-installed > ${log} 2>&1
403425
if [ $? -ne 0 ]; then
@@ -407,19 +429,19 @@ install_prereqs() {
407429
done
408430

409431
## install additional pip-based packages
410-
for pkg in 'openstacksdk==0.39.0' docker-py; do
432+
for pkg in 'openstacksdk==0.62.0' docker-py pyopenssl; do
411433
echo -n "${pkg} "
412-
sudo pip install ${pkg} --ignore-installed > ${log} 2>&1
434+
sudo pip install ${pkg} --upgrade > ${log} 2>&1
413435
if [ $? -ne 0 ]; then
414436
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
415437
tail -10 ${log}; exit 1
416438
fi
417439
done
418440

419-
## install additional yum-based packages
441+
## install additional dnf-based packages
420442
for pkg in ansible; do
421443
echo -n "${pkg} "
422-
sudo yum -y install ${pkg} > ${log} 2>&1
444+
sudo dnf -y install ${pkg} > ${log} 2>&1
423445
if [ $? -ne 0 ]; then
424446
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
425447
tail -10 ${log}; exit 1
@@ -439,7 +461,7 @@ install_prereqs() {
439461
fi
440462
fi
441463

442-
for pkg in ansible jq bc python-pip; do
464+
for pkg in ansible jq bc python3-pip; do
443465
echo -n "${pkg} "
444466
dpkg-query -f '${binary:Package}\n' -W | grep ^${pkg}$ > /dev/null 2>&1
445467
if [ $? -ne 0 ]; then
@@ -459,9 +481,9 @@ install_prereqs() {
459481
fi
460482

461483
## install additional pip-based packages
462-
for pkg in 'openstacksdk==0.39.0' docker-py; do
484+
for pkg in 'openstacksdk==0.62.0' docker-py pyopenssl; do
463485
echo -n "${pkg} "
464-
sudo pip install ${pkg} --ignore-installed > ${log} 2>&1
486+
sudo pip install ${pkg} --upgrade > ${log} 2>&1
465487
if [ $? -ne 0 ]; then
466488
echo -e "\nERROR: failed to install ${pkg} - here's the last 10 lines of the log:\n"
467489
tail -10 ${log}; exit 1
@@ -513,6 +535,9 @@ while [ $# -gt 0 ]; do
513535
-d|--deauth)
514536
flag_deauth=1
515537
;;
538+
-g|--debug)
539+
verbosity="-vvv"
540+
;;
516541
-l|--log)
517542
if [ $# -lt 2 ]; then usage; fi
518543
install_log=${2}
@@ -667,7 +692,7 @@ if [ ${flag_oscli} -eq 1 ]; then
667692
fi
668693

669694
## validate minimum Ansible version
670-
ansible_version=$(ansible --version | head -1 | cut -d ' ' -f2 | cut -d . -f1-2)
695+
ansible_version=$(ansible --version| head -1| grep core|awk -F ']' '{print $1}'|awk '{print $3}'|cut -d . -f1-2)
671696
echo "--> ansible_version = ${ansible_version}"
672697
if (( ! $(bc <<< "$ansible_version >= $min_ansible_version") )); then assert "Ansible ${min_ansible_version} or greater is required"; fi
673698

@@ -722,7 +747,7 @@ else
722747
fi
723748

724749
## call pf9-express
725-
sudo ansible-playbook -i ${inventory} -l ${target} ${role_tags} -e "skip_prereq=${flag_skip_prereqs} autoreg=${autoreg} du_fqdn=${ctrl_hostname} ctrl_ip=${ctrl_ip} du_username=${du_username} du_password=${du_password} ${extra_vars}" ${express_script} 2>&1 | tee ${install_log}
750+
sudo ansible-playbook -i ${inventory} -l ${target} ${role_tags} -e "skip_prereq=${flag_skip_prereqs} autoreg=${autoreg} du_fqdn=${ctrl_hostname} ctrl_ip=${ctrl_ip} du_username=${du_username} du_password=${du_password} ${extra_vars}" ${express_script} ${verbosity} 2>&1 | tee ${install_log}
726751

727752
## display log path
728753
echo -e "Installation Log: ${install_log}\n"

pf9-express.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@
5757
gather_facts: False
5858
pre_tasks:
5959
- debug: var=autoreg
60-
- name: install python2 on Ubuntu to enable running Ansible on Ubuntu hosts
61-
raw: if [ -e /etc/lsb-release -a ! -e /usr/bin/python ]; then (apt-get -y update && apt-get install -y python-minimal); fi
60+
- name: install python3 on Ubuntu hosts
61+
raw: if [ -e /etc/lsb-release -a ! -e /usr/bin/python3 ]; then (apt-get -y update && apt-get install -y python3); fi
62+
- name: install python3 on Rocky hosts
63+
raw: if [ -e /etc/rocky-release -a ! -e /bin/python3 ]; then (dnf -y update && dnf install -y python3); fi
6264

6365
# Run pre_flight_checks
6466
- hosts:

roles/bond-config/tasks/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Configure the physical and sub-interfaces behind the bond
66
##########################################################################################################
77
- include: redhat.yml
8-
when: ansible_os_family == "RedHat"
8+
when: '"RedHat" in ansible_distribution or ansible_distribution == "CentOS" or ansible_distribution == "Rocky"'
99

1010
- include: ubuntu.yml
1111
when: ansible_distribution == "Ubuntu"

roles/common/tasks/main.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@
8888
when: pf9_account_status is defined and pf9_account_status.stdout.strip() == "not-exist"
8989

9090
- include: redhat.yml
91-
when: ansible_os_family == "RedHat"
91+
when: '"RedHat" in ansible_distribution or ansible_distribution == "CentOS"'
92+
93+
- include: rocky.yml
94+
when: ansible_distribution == "Rocky"
9295

9396
- include: ubuntu.yml
9497
when: ansible_distribution == "Ubuntu"

roles/common/tasks/rocky.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
- name: Install libselinux-python
3+
dnf:
4+
state: present
5+
name: python3-libselinux
6+
7+
- name: Install the latest version ca-certificates
8+
dnf:
9+
name: ca-certificates
10+
state: latest
11+
12+
- name: Modify devpts mount point
13+
mount:
14+
state: present
15+
name: /dev/pts
16+
src: devpts
17+
fstype: devpts
18+
opts: gid=5,mode=620
19+
dump: 0
20+
passno: 0
21+
register: devpts_result
22+
23+
- name: Remount devpts mount point
24+
command: mount -o remount devpts
25+
when: devpts_result is changed

roles/customize-ceilometer/tasks/main.yml

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
- ansible_os_family == "RedHat"
1414
- ansible_pkg_mgr == "yum"
1515

16+
- name: Check if pf9-ceilometer is installed (Rocky)
17+
shell: "`which dnf` list installed | grep \"^pf9-ceilometer\\.\" > /dev/null 2>&1; if [ $? -ne 0 ]; then echo 'not-installed'; fi"
18+
register: pkg_state_ceilometer_redhat
19+
when:
20+
- ansible_distribution == "Rocky"
21+
- ansible_pkg_mgr == "dnf"
22+
1623
- name: Configure Ceilometer pipeline.yaml
1724
template:
1825
src: pipeline.yaml.j2

roles/enable-ksm/tasks/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
name: ksmtuned
1212
state: restarted
1313
enabled: yes
14-
when: ansible_os_family == "RedHat"
14+
when: '"RedHat" in ansible_distribution or ansible_distribution == "CentOS" or ansible_distribution == "Rocky"'
1515

1616
- block:
1717
- name: Install Kernel Same-Page Merging (Ubuntu)

roles/enable-nested-virt/tasks/main.yml

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
- ansible_os_family == "RedHat"
1414
- ansible_pkg_mgr == "yum"
1515

16+
- name: Check if pf9-ostackhost is installed (Rocky)
17+
shell: "`which dnf` list installed | grep \"^pf9-ostackhost\\.\" > /dev/null 2>&1; if [ $? -ne 0 ]; then echo 'not-installed'; fi"
18+
register: pkg_state_ostackhost_redhat
19+
when:
20+
- ansible_distributiong == "Rocky"
21+
- ansible_pkg_mgr == "dnf"
22+
1623
- name: update Nova to support nested virtualization
1724
script: files/update-nova.sh
1825
when: (pkg_state_ostackhost_ubuntu.stdout is defined and pkg_state_ostackhost_ubuntu.stdout.strip() != "not-installed") or

0 commit comments

Comments
 (0)