From 64bb6fb4e1d17b74f02f99bfa5393a6488acdb74 Mon Sep 17 00:00:00 2001 From: David Murphy < dmurphy@saltstack.com> Date: Fri, 22 Nov 2019 12:52:08 -0700 Subject: [PATCH] Initial support for Amazon Linux 2 and Python3 plus other fixes --- bootstrap-salt.sh | 68 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 0d703c9..3103d7b 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1,5 +1,7 @@ #!/bin/sh - +set -o functrace + # WARNING: Changes to this file in the salt repo will be overwritten! # Please submit pull requests against the salt-bootstrap repo: # https://github.com/saltstack/salt-bootstrap @@ -4830,15 +4832,23 @@ install_amazon_linux_ami_2_git_deps() { yum -y install ca-certificates || return 1 fi - PIP_EXE='pip' - if __check_command_exists python2.7; then - if ! __check_command_exists pip2.7; then - __yum_install_noinput python2-pip + if __check_command_exists python3; then + if ! __check_command_exists pip3; then + __yum_install_noinput python3-pip + fi + PIP_EXE='/bin/pip3' + _PY_EXE='python3' + fi + else + PIP_EXE='pip' + if __check_command_exists python2.7; then + if ! __check_command_exists pip2.7; then + __yum_install_noinput python2-pip + fi + PIP_EXE='/bin/pip' + _PY_EXE='python2.7' fi - PIP_EXE='/bin/pip' - _PY_EXE='python2.7' fi - install_amazon_linux_ami_2_deps || return 1 if ! __check_command_exists git; then @@ -4852,7 +4862,15 @@ install_amazon_linux_ami_2_git_deps() { if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - __PACKAGES="${__PACKAGES} python27-pip" + if [ $PARSED_VERSION -eq 2 ]; then + if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then + __PACKAGES="${__PACKAGES} python3-pip" + else + __PACKAGES="${__PACKAGES} python2-pip" + fi + else + __PACKAGES="${__PACKAGES} python27-pip" + fi __PIP_PACKAGES="${__PIP_PACKAGES} apache-libcloud>=$_LIBCLOUD_MIN_VERSION" fi @@ -4918,10 +4936,20 @@ install_amazon_linux_ami_2_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then __REPO_FILENAME="saltstack-repo.repo" - base_url="$HTTP_VAL://${_REPO_URL}/yum/amazon/2/\$basearch/$repo_rev/" - gpg_key="${base_url}SALTSTACK-GPG-KEY.pub - ${base_url}base/RPM-GPG-KEY-CentOS-7" + __PY_VERSION_REPO="yum" + PY_PKG_VER="" repo_name="SaltStack repo for Amazon Linux 2.0" + if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then + __PY_VERSION_REPO="py3" + PY_PKG_VER=3 + repo_name="SaltStack Python 3 repo for Amazon Linux 2.0" + fi + + base_url="$HTTP_VAL://${_REPO_URL}/${__PY_VERSION_REPO}/amazon/2/\$basearch/$repo_rev/" + gpg_key="${base_url}SALTSTACK-GPG-KEY.pub + if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -ne 3 ]; then + ${base_url}base/RPM-GPG-KEY-CentOS-7" + fi # This should prob be refactored to use __install_saltstack_rhel_repository() # With args passed in to do the right thing. Reformatted to be more like the @@ -4942,9 +4970,15 @@ _eof # Package python-ordereddict-1.1-2.el6.noarch is obsoleted by python26-2.6.9-2.88.amzn1.x86_64 # which is already installed - __PACKAGES="m2crypto ${pkg_append}-crypto ${pkg_append}-jinja2 PyYAML procps-ng" - __PACKAGES="${__PACKAGES} ${pkg_append}-msgpack ${pkg_append}-requests ${pkg_append}-zmq" - __PACKAGES="${__PACKAGES} ${pkg_append}-futures" + if [ "${PY_PKG_VER}" -eq 3 ]; then + __PACKAGES="${pkg_append}${PY_PKG_VER}-m2crypto ${pkg_append}${PY_PKG_VER}-pyyaml" + + else + __PACKAGES="m2crypto PyYAML ${pkg_append}-futures" + fi + + __PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-crypto ${pkg_append}${PY_PKG_VER}-jinja2 procps-ng" + __PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-msgpack ${pkg_append}${PY_PKG_VER}-requests ${pkg_append}${PY_PKG_VER}-zmq" # shellcheck disable=SC2086 __yum_install_noinput ${__PACKAGES} || return 1 @@ -5025,6 +5059,12 @@ install_amazon_linux_ami_2_testing_post() { install_centos_testing_post || return 1 return 0 } + +install_amazon_linux_ami_2_check_services() { + install_centos_check_services || return 1 + return 0 +} + # # Ended Amazon Linux AMI Install Functions #