Fix distribution detection in bootstrap
The bootstrap-ansible script is responsible for installing many base packages. It attempts to detect the host distribution by checking for various operating system identification files (such as /etc/os-release). As per the freedesktop.org spec, all complying distributions ship the /etc/os-release file, just with different content. The script incorrectly assumes that if this file is present it represents an apt based distribution, such as Ubuntu, and proceeds to install base packages. As all distributions ship this file, the bootstrap process fails on non-apt systems, such as Fedora (the subsequent checks for distribution-specific files, such as /etc/fedora-release, are skipped). This patch adds a function to the scripts-library which will read the /etc/os-release file and export various DISTRO_ prefixed variables which identify the distribution and version. These can be used wherever the scripts-library is sourced. The package installation check inside bootstrap-ansible.sh is updated to make use of these new variables by checking the value of DISTRO_ID. Related to commits: d9b9a427aa03 "Add reliable OS detection for ansible bootstrap" 68d68c27dd80 "Remove os-detection script" Implements: blueprint multi-platform-host Change-Id: I07c8a7a7f8d4cf56cf125fcef18e6cf4f473e39e
This commit is contained in:
parent
79bcc91587
commit
e3526a88c9
@ -43,14 +43,21 @@ ANSIBLE_ROLE_FILE="$(readlink -f ${ANSIBLE_ROLE_FILE})"
|
||||
# Create the ssh dir if needed
|
||||
ssh_key_create
|
||||
|
||||
# Determine the distribution which the host is running on
|
||||
determine_distro
|
||||
|
||||
# Install the base packages
|
||||
if [[ -f "/etc/os-release" ]]; then
|
||||
apt-get update && apt-get -y install git python-all python-dev curl python2.7-dev build-essential libssl-dev libffi-dev python-requests < /dev/null
|
||||
elif [[ -f "/etc/redhat-release" ]]; then
|
||||
yum check-update && yum -y install git python2 curl autoconf gcc-c++ python2-devel gcc libffi-devel openssl-devel python-requests
|
||||
elif [[ -f "/etc/fedora-release" ]]; then
|
||||
dnf -y install git python curl autoconf gcc-c++ python-devel gcc libffi-devel openssl-devel python-requests
|
||||
fi
|
||||
case ${DISTRO_ID} in
|
||||
centos|rhel)
|
||||
yum check-update && yum -y install git python2 curl autoconf gcc-c++ python2-devel gcc libffi-devel openssl-devel python-requests
|
||||
;;
|
||||
fedora)
|
||||
dnf --refresh -y install git python curl autoconf gcc-c++ python-devel gcc libffi-devel openssl-devel python-requests
|
||||
;;
|
||||
ubuntu)
|
||||
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git python-all python-dev curl python2.7-dev build-essential libssl-dev libffi-dev python-requests
|
||||
;;
|
||||
esac
|
||||
|
||||
# Install pip
|
||||
get_pip
|
||||
|
@ -41,6 +41,15 @@ fi
|
||||
|
||||
|
||||
## Functions -----------------------------------------------------------------
|
||||
# Determine the distribution we are running on, so that we can configure it
|
||||
# appropriately.
|
||||
function determine_distro {
|
||||
source /etc/os-release 2>/dev/null
|
||||
export DISTRO_ID="${ID}"
|
||||
export DISTRO_NAME="${NAME}"
|
||||
export DISTRO_VERSION_ID="${VERSION_ID}"
|
||||
}
|
||||
|
||||
# Used to retry a process that may fail due to random issues.
|
||||
function successerator {
|
||||
set +e
|
||||
|
Loading…
x
Reference in New Issue
Block a user