diff options
author | sharath reddy <bs.reddy@huawei.com> | 2022-05-05 16:17:00 +0530 |
---|---|---|
committer | Michael Pedersen <michaelx.pedersen@intel.com> | 2022-05-25 07:31:03 +0000 |
commit | 3c59b039817a4f87e081f7d968c2172cd8d00bf8 (patch) | |
tree | 3ca7bd8c96fa7b7f9b644fd41329f6e22a9cbf97 | |
parent | e1fe6a366e8cdca3d490befd0d381efe3f1921af (diff) |
automated few manual steps
Issue-ID: KUB-64
Signed-off-by: sharath reddy <bs.reddy@huawei.com>
Change-Id: I3ad2c50d7ad84a04f5a7270238f14111e58fc20a
Signed-off-by: sharath reddy <bs.reddy@huawei.com>
Reviewed-on: https://gerrit.opnfv.org/gerrit/c/kuberef/+/73339
Tested-by: jenkins-ci <jenkins-opnfv-ci@opnfv.org>
Reviewed-by: Michael Pedersen <michaelx.pedersen@intel.com>
-rwxr-xr-x | functions.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh index 0213829..63f1490 100755 --- a/functions.sh +++ b/functions.sh @@ -4,6 +4,8 @@ # # SPDX-License-Identifier: Apache-2.0 +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + info() { _print_msg "INFO" "$1" } @@ -63,6 +65,90 @@ check_prerequisites() { sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers #------------------------------------------------------------------------------- + # Installing prerequisites + #------------------------------------------------------------------------------- + if [ "$OS_ID" == "ubuntu" ]; then + + apt update + ansible --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo apt-add-repository --yes --update ppa:ansible/ansible + sudo apt-get install -y ansible + fi + + yq --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 -O /usr/bin/yq + sudo chmod +x /usr/bin/yq + fi + + virsh --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo apt-get install -y virsh + fi + + jq --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo apt-get install -y jq + fi + + virtualenv --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo apt-get install -y virtualenv + fi + + pip --version + if [ $RESULT -ne 0 ]; then + sudo apt-get install -y pip + fi + + elif [ "$OS_ID" == "centos" ]; then + + yum update + ansible --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo dnf install epel-release + sudo dnf install ansible + fi + + yq --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 -O /usr/bin/yq + sudo chmod +x /usr/bin/yq + fi + + virsh --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo yum install -y virsh + fi + + jq --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo yum install -y jq + fi + + virtualenv --version + RESULT=$? + if [ $RESULT -ne 0 ]; then + sudo yum install -y virtualenv + fi + + pip --version + if [ $RESULT -ne 0 ]; then + sudo yum install -y pip + fi + fi + + #------------------------------------------------------------------------------- # Check if necessary tools are installed #------------------------------------------------------------------------------- for tool in ansible yq virsh jq docker virtualenv pip; do |