Skip to content

Instantly share code, notes, and snippets.

@gtmanfred
Last active May 15, 2017 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtmanfred/73937f85d57c6a3caacbd6eaaa3de00e to your computer and use it in GitHub Desktop.
Save gtmanfred/73937f85d57c6a3caacbd6eaaa3de00e to your computer and use it in GitHub Desktop.
set -e
PY3=false
usage() {
cat <<EOT
USAGE : $0 [options]
Options:
-h Display this message
-j Jenkins user
-3 python3 tests
-s State to run from salt-jenkins
-b Branch to put in /testing
-n Test to run after setup
-u Github user to clone from
EOT
}
while getopts "h3s:b:u:j:n:" opt; do
case $opt in
s)
STATE="$OPTARG"
;;
b)
BRANCH="$OPTARG"
;;
j)
JENKINS="$OPTARG"
;;
u)
GIT_USER="$OPTARG"
;;
3)
PY3=true
;;
n)
TEST_NAME="$OPTARG"
;;
h)
usage
exit 0
;;
\?)
usage
exit 2
;;
esac
done
if [[ -f /etc/redhat-release ]]; then
if grep -q systemd /proc/1/comm; then
yum install -y https://repo.saltstack.com/yum/redhat/salt-repo-latest-1.el7.noarch.rpm || true
else
yum install -y https://repo.saltstack.com/yum/redhat/salt-repo-latest-1.el6.noarch.rpm || true
fi
if grep -q 'Red Hat' /etc/redhat-release; then
if grep -q systemd /proc/1/comm; then
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm || true
else
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm || true
fi
else
yum install -y epel-release || true
fi
yum upgrade -y || true
yum install -y salt-minion git screen policycoreutils-python GitPython ||true
setenforce 0
elif [[ -f /etc/debian_version ]]; then
export DEBIAN_FRONTEND=noninteractive UCF_FORCE_CONFFOLD=1
if grep -q systemd /proc/1/comm; then
wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main" | tee /etc/apt/sources.list.d/saltstack.list
else
wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
echo "deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main" | tee /etc/apt/sources.list.d/saltstack.list
fi
apt-get update
apt-get upgrade -y
apt-get install -y salt-minion screen git python-git
/etc/init.d/apparmor teardown
/etc/init.d/apparmor stop
elif [[ -f /etc/SuSE-release ]]; then
if [[ ! -f /etc/zypp/repos.d/systemsmanagement_saltstack.repo ]]; then
zypper addrepo http://repo.saltstack.com/opensuse/openSUSE_Leap_42.1/systemsmanagement:saltstack.repo
fi
if [[ ! -f /etc/zypp/repos.d/devel_languages_python.repo ]]; then
zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/openSUSE_Leap_42.1/devel:languages:python.repo
fi
zypper --gpg-auto-import-keys refresh
zypper update -y
zypper install -y salt-minion git screen python-GitPython
elif [[ -f /etc/alpine-release ]]; then
apk update
apk add --upgrade py2-yaml py2-tornado py2-crypto py2-requests py2-msgpack py2-jinja2 py2-futures py2-zmq py2-six py2-pip git
pip install GitPython salt==2016.3.3
fi
mkdir -p /etc/salt/minion.d
cat > /etc/salt/minion.d/conf.conf <<HERE
file_client: local
failhard: true
fileserver_backend:
- roots
- git
gitfs_remotes:
- git://github.com/${JENKINS:-saltstack}/salt-jenkins.git
HERE
salt-call saltutil.sync_all -l debug
salt-call state.apply ${STATE:-git.salt} pillar="{'test_git_url': 'git://github.com/${GIT_USER:-saltstack}/salt.git', 'test_git_commit': '${BRANCH:-develop}', 'py3': ${PY3:-false}}" -l debug
if [[ -n $TEST_NAME ]]; then
if [[ $PY3 == true ]]; then
PYTHON_BIN=python3
else
PYTHON_BIN=python
fi
pushd /testing
"$PYTHON_BIN" -m tests.runtests --run-destructive -vv -n "$TEST_NAME"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment