|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2021 Cloudera, Inc. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# This script sets up and environment suitable for running Ansible playbooks using Centos 7. It is distinct from the docker version of runner. |
| 17 | +# If you set any of the environment variables KUBECTL, AWS, GCLOUD, AZURE it will also install the relevant client libraries and dependencies for those operating modes. |
| 18 | + |
| 19 | +sudo yum install -y python36-devel git curl which bash gcc sshpass |
| 20 | + |
| 21 | +# 21 or later required otherwise ansible fails because of setuptools_rust. Higher than 21.0.1 gives warnings due to https://github.com/pypa/pip/issues/5599 |
| 22 | +sudo python3 -m pip install pip==21.0.1 |
| 23 | + |
| 24 | +pip3 install setuptools |
| 25 | +pip3 install ansible |
| 26 | + |
| 27 | +ansible-galaxy collection install --force git+https://github.com/cloudera-labs/cloudera.cluster.git |
| 28 | +ansible-galaxy collection install --force git+https://github.com/cloudera-labs/cloudera.cloud.git |
| 29 | +ansible-galaxy collection install --force git+https://github.com/cloudera-labs/cloudera.exe.git |
| 30 | + |
| 31 | +git clone https://github.com/cloudera-labs/cldr-runner runner |
| 32 | +if [[ -z "$KUBECTL" ]]; then echo KUBECTL not requested; else sudo yum install -y kubernetes-client; fi |
| 33 | +if [[ -z "$AWS" ]]; then echo AWS not requested; else pip3 install --no-cache-dir -r runner/payload/deps/python_aws.txt; fi |
| 34 | +if [[ -z "$GCLOUD" ]]; then echo GCLOUD not requested; else sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM |
| 35 | +[google-cloud-sdk] |
| 36 | +name=Google Cloud SDK |
| 37 | +baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 |
| 38 | +enabled=1 |
| 39 | +gpgcheck=1 |
| 40 | +repo_gpgcheck=0 |
| 41 | +gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg |
| 42 | + https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg |
| 43 | +EOM |
| 44 | +sudo yum install -y google-cloud-sdk; pip3 install --no-cache-dir -r runner/payload/deps/python_gcp.txt; fi |
| 45 | +if [[ -z "$AZURE" ]]; then echo AZURE not requested; else sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc; echo -e "[azure-cli] |
| 46 | +name=Azure CLI |
| 47 | +baseurl=https://packages.microsoft.com/yumrepos/azure-cli |
| 48 | +enabled=1 |
| 49 | +gpgcheck=1 |
| 50 | +gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo; sudo yum install -y azure-cli; pip3 install --no-cache-dir -r runner/payload/deps/python_azure.txt; fi |
| 51 | +if [[ -z "$CDPY" ]]; then echo CDPY not requested; else pip3 install git+git://github.com/cloudera-labs/cdpy@main#egg=cdpy --upgrade; fi |
| 52 | + |
| 53 | +ansible-galaxy install -r runner/payload/deps/ansible.yml |
| 54 | +pip3 install -r runner/payload/deps/python_base.txt |
| 55 | + |
| 56 | +tee -a ansible.cfg << EOF |
| 57 | +[defaults] |
| 58 | +inventory=inventory |
| 59 | +callback_whitelist = ansible.posix.profile_tasks |
| 60 | +host_key_checking = False |
| 61 | +gathering = smart |
| 62 | +pipelining = True |
| 63 | +deprecation_warnings=False |
| 64 | +[ssh_connection] |
| 65 | +retries = 10 |
| 66 | +EOF |
| 67 | + |
| 68 | +echo "Example command: " |
| 69 | +echo 'export ANSIBLE_LOG_PATH=~/ansible.log; ansible-playbook main.yml -e "definition_path=examples/sandbox" --ask-pass -vv -i examples/sandbox/inventory_static.ini' |
0 commit comments