forked from openshift-metal3/dev-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_install_requirements.sh
executable file
·93 lines (79 loc) · 3.76 KB
/
01_install_requirements.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
set -ex
source logging.sh
source common.sh
source sanitychecks.sh
source utils.sh
source validation.sh
early_deploy_validation true
if [ -z "${METAL3_DEV_ENV}" ]; then
export REPO_PATH=${WORKING_DIR}
sync_repo_and_patch metal3-dev-env https://github.com/metal3-io/metal3-dev-env.git
pushd ${METAL3_DEV_ENV_PATH}
# Pin to a specific metal3-dev-env commit to ensure we catch breaking
# changes before they're used by everyone and CI.
# TODO -- come up with a plan for continuously updating this
# Note we only do this in the case where METAL3_DEV_ENV is
# unset, to enable developer testing of local checkouts
git reset ee1b2fec44e22700c8d250d5e0e371e3fd0aba17 --hard
popd
fi
# This must be aligned with the metal3-dev-env pinned version above, see
# https://github.com/metal3-io/metal3-dev-env/blob/master/lib/common.sh
export ANSIBLE_VERSION=${ANSIBLE_VERSION:-"4.8.0"}
# Update to latest packages first
sudo dnf -y upgrade
# Install additional repos as needed for each OS version
# shellcheck disable=SC1091
source /etc/os-release
export DISTRO="${ID}${VERSION_ID%.*}"
if [[ $DISTRO == "centos8" ]]; then
if [ "$NAME" != "CentOS Stream" -a ! -e /etc/yum.repos.d/centos-vault.repo ] ; then
# Centos8 is EOL
mv /etc/yum.repos.d /etc/yum.repos.d_$(date +%s)
mkdir /etc/yum.repos.d
echo -e '[base]\nname=base\nbaseurl=https://vault.centos.org/8.4.2105/BaseOS/x86_64/os/\ngpgcheck=0\nenabled=1\n[apps]\nname=apps\nbaseurl=https://vault.centos.org/8.4.2105/AppStream/x86_64/os/\ngpgcheck=0\nenabled=1\n[extras]\nname=extras\nbaseurl=https://vault.centos.org/8.4.2105/extras/x86_64/os/\ngpgcheck=0\nenabled=1' > /etc/yum.repos.d/centos-vault.repo
fi
sudo dnf -y install epel-release dnf --enablerepo=extras
elif [[ $DISTRO == "rhel8" ]]; then
# Enable EPEL for python3-passlib and python3-bcrypt required by metal3-dev-env
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
if sudo subscription-manager repos --list-enabled 2>&1 | grep "ansible-2-for-rhel-8-x86_64-rpms"; then
# The packaged 2.x ansible is too old for compatibility with metal3-dev-env
sudo dnf erase -y ansible
sudo subscription-manager repos --disable=ansible-2-for-rhel-8-x86_64-rpms
fi
fi
# Install ansible, other packages are installed via
# vm-setup/install-package-playbook.yml
# Note recent ansible needs python >= 3.8 so we install 3.9 here
sudo dnf -y install python39
sudo alternatives --set python /usr/bin/python3.9
sudo alternatives --set python3 /usr/bin/python3.9
sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.9 1
sudo pip3 install ansible=="${ANSIBLE_VERSION}"
# Also need the 3.9 version of netaddr for ansible.netcommon
# and lxml for the pyxpath script
sudo pip3 install netaddr lxml
pushd ${METAL3_DEV_ENV_PATH}
ansible-galaxy install -r vm-setup/requirements.yml
ansible-galaxy collection install --upgrade ansible.netcommon ansible.posix community.general
ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "working_dir=$WORKING_DIR" \
-e "virthost=$HOSTNAME" \
-e "go_version=1.17.1" \
-i vm-setup/inventory.ini \
-b -vvv vm-setup/install-package-playbook.yml
popd
# We use yq in a few places for processing YAML but it isn't packaged
# for CentOS/RHEL so we have to install from pip.
pip3 install --user 'yq>=2.10.0'
# needed if we are using locally built images
# We stop any systemd service so we can run in a container, since
# there's no RPM/systemd version available for RHEL8
if sudo systemctl is-active docker-distribution.service; then
sudo systemctl disable --now docker-distribution.service
fi
retry_with_timeout 5 60 "curl $OPENSHIFT_CLIENT_TOOLS_URL | sudo tar -U -C /usr/local/bin -xzf -"
sudo chmod +x /usr/local/bin/oc
oc version --client -o json