From a0e6385d595ddac4ab8941fdf28e82b43d14bf50 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Thu, 4 Jun 2015 14:18:59 +0200 Subject: [PATCH] Add setup_env.sh and requirements.txt to install dependencies Kudos to Julia Kreger, I shamelessly copied the setup_env.sh script from her fantastic bifrost project. --- requirements.txt | 3 +++ setup_env.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 requirements.txt create mode 100755 setup_env.sh diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..951cb0e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +shade +shade-ansible +jinja2 diff --git a/setup_env.sh b/setup_env.sh new file mode 100755 index 0000000..659cd66 --- /dev/null +++ b/setup_env.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -e + +if [ -x '/usr/bin/apt-get' ]; then + if ! $(git --version &>/dev/null) ; then + sudo -H apt-get -y install git + fi + if ! $(pip -v &>/dev/null); then + sudo -H apt-get -y install python-pip + fi +elif [ -x '/usr/bin/yum' ]; then + if ! $(git --version &>/dev/null); then + sudo -H yum -y install git + fi + if ! $(pip -v &>/dev/null); then + sudo -H yum -y install python-pip + fi +else + echo "ERROR: Supported package manager not found. Supported: apt,yum" +fi + +sudo -E pip install -r "$(dirname $0)/requirements.txt" + +u=$(whoami) +g=$(groups | awk '{print $1}') + +if [ ! -d /opt/stack ]; then + mkdir -p /opt/stack || (sudo mkdir -p /opt/stack) +fi +sudo -H chown -R $u:$g /opt/stack +cd /opt/stack + +if [ ! -d ansible ]; then + git clone https://github.com/ansible/ansible.git --recursive +else + cd ansible + git checkout devel + git pull --rebase + git submodule update --init --recursive + git fetch + # Temporary direct checkout of devel due to broken modules until + # the submodules pointers get updated in the core ansible repo. + cd lib/ansible/modules/core + git checkout devel +fi + +echo +echo "If your using this script directly, execute the" +echo "following commands to update your shell." +echo +echo "source env-vars" +echo "source /opt/stack/ansible/hacking/env-setup" +echo