diff --git a/ansible_prereqs.sh b/ansible_prereqs.sh index 5e2d617f2..f1a99e24e 100755 --- a/ansible_prereqs.sh +++ b/ansible_prereqs.sh @@ -1,6 +1,11 @@ #!/bin/bash set -e -ANSIBLE_VERSION=5.8.0 +ANSIBLE_VERSION_UBUNTU=5.8.0 +ANSIBLE_VERSION_CENTOS=4.10.0 + +os_release=$(cat /etc/os-release | grep "^ID\=" | cut -d'=' -f 2 | xargs) +os_release=${os_release^^} + THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [[ `pip3 list pypsrp` == *"pypsrp"* ]]; then @@ -36,7 +41,8 @@ fi ansible --version pip3 list | grep ansible version=$(pip3 list | grep ansible | sort | head -n 1 | xargs | cut -d' ' -f 2) -if [ "$version" != $ANSIBLE_VERSION ]; then - echo "Ansible version is $ansible_version. Please run ./toolset/scripts/install.sh to install the correct version of Ansible" +ANSIBLE_VERSION="ANSIBLE_VERSION_$os_release" +if [ "$version" != ${!ANSIBLE_VERSION} ]; then + echo "Ansible version is ${!ANSIBLE_VERSION}. Please run ./toolset/scripts/install.sh to install the correct version of Ansible" exit 1 fi diff --git a/toolset/scripts/install_centos.sh b/toolset/scripts/install_centos.sh new file mode 100755 index 000000000..3b82fe239 --- /dev/null +++ b/toolset/scripts/install_centos.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# Install basic command-line utilities +yum install -y epel-release + +yum install -y \ + curl \ + python3 \ + python3-pip \ + jq \ + wget \ + git \ + yamllint + +# +# Install AzCLI +# +echo "Installing AzCLI ..." +rpm --import https://packages.microsoft.com/keys/microsoft.asc +echo -e "[azure-cli] +name=Azure CLI +baseurl=https://packages.microsoft.com/yumrepos/azure-cli +enabled=1 +gpgcheck=1 +gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | tee /etc/yum.repos.d/azure-cli.repo +yum install -y azure-cli + +# +# Install AzCopy +# +echo "Installing AzCopy ..." +cd /usr/local/bin +wget -q https://aka.ms/downloadazcopy-v10-linux -O - | tar zxf - --strip-components 1 --wildcards '*/azcopy' +chmod 755 /usr/local/bin/azcopy +# +# Install Ansible +# +echo "Installing Ansible ..." +yum remove -y ansible +pip3 install setuptools-rust +pip3 install --upgrade pip +pip3 install ansible==4.10.0 + +echo "Installing Ansible playbooks pre-reqs" +pip3 install pypsrp +pip3 install PySocks + +ansible-galaxy collection install ansible.windows +ansible-galaxy collection install community.windows +ansible-galaxy collection install ansible.posix +ansible-galaxy collection install community.general + +# +# Install Terraform +# +echo "Installing terraform ..." +#apt update -y && \ +#apt install -y software-properties-common && \ +yum -y remove terraform +yum install -y yum-utils +yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo +yum -y install terraform + +# +# Install Packer +# +echo "Installing packer...." +yum remove packer -y +yum install -y packer + +# +# Install yq +# +echo "Installing yq...." +VERSION=v4.13.3 +BINARY=yq_linux_amd64 +wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq && chmod +x /usr/bin/yq + +# Clean-up +rm -f /tmp/*.zip && rm -f /tmp/*.gz && \ + +echo "==============" +echo "Python version" +echo "==============" +python3 --version +echo "===============" +echo "Ansible version" +echo "===============" +ansible --version +echo "=================" +echo "Terraform version" +echo "=================" +terraform --version +echo "==============" +echo "Packer version" +echo "==============" +/usr/bin/packer --version +echo "==========" +echo "AZ version" +echo "==========" +az --version +echo "==========" +echo "AZ Copy version" +echo "==========" +azcopy --version +echo "==========" +echo "yq version" +echo "==========" +yq --version +echo "End" \ No newline at end of file