From 1075382732509f9c83eda18e59d3c6c6a834c41b Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 24 Jun 2015 12:18:46 -0400 Subject: [PATCH] initial take on supporting declarative requirements per job Signed-off-by: Alfredo Deza --- ceph-deploy-pull-requests/build/build | 35 +++++++++++++++++++ .../setup/playbooks/setup.yml | 11 ++++++ .../setup/playbooks/tasks/ubuntu.yml | 18 ++++++++++ 3 files changed, 64 insertions(+) create mode 100644 ceph-deploy-pull-requests/build/build create mode 100644 ceph-deploy-pull-requests/setup/playbooks/setup.yml create mode 100644 ceph-deploy-pull-requests/setup/playbooks/tasks/ubuntu.yml diff --git a/ceph-deploy-pull-requests/build/build b/ceph-deploy-pull-requests/build/build new file mode 100644 index 00000000..dd345e4e --- /dev/null +++ b/ceph-deploy-pull-requests/build/build @@ -0,0 +1,35 @@ +#!/bin/bash + +set -ex + +# Create the virtualenv +virtualenv venv +. venv/bin/activate + +# Define and ensure the PIP cache +PIP_SDIST_INDEX="$HOME/.cache/pip" +mkdir -p $PIP_SDIST_INDEX + +# Define and ensure a GIT Ansible cache +REPO_CACHE="$HOME/.cache/git/ceph-build" +mkdir -p $REPO_CACHE + +# Clone the ceph-build repo or pull if it exists +if [ -d "$REPO_CACHE/.git" ]; then + cd "$REPO_CACHE" && git pull + cd - +else + git clone https://github.com/ceph/ceph-build.git "$REPO_CACHE" +fi + +# Install the package by trying with the cache first, otherwise doing a download only, and then +# trying to install from the cache again. +if ! venv/bin/pip install --find-links="file://$PIP_SDIST_INDEX" --no-index ansible; then + venv/bin/pip install --download-directory="$PIP_SDIST_INDEX" ansible + venv/bin/pip install --find-links="file://$PIP_SDIST_INDEX" --no-index ansible +fi + +# run ansible to get this current host to meet our requirements, specifying +# a local connection and 'localhost' as the host where to execute +cd "$REPO_CACHE/ceph-deploy-pull-requests/setup/playbooks" +ansible-playbook -i "localhost," -c local setup.yml diff --git a/ceph-deploy-pull-requests/setup/playbooks/setup.yml b/ceph-deploy-pull-requests/setup/playbooks/setup.yml new file mode 100644 index 00000000..f45d5f90 --- /dev/null +++ b/ceph-deploy-pull-requests/setup/playbooks/setup.yml @@ -0,0 +1,11 @@ +--- + +- hosts: localhost + user: jenkins-build + sudo: True + + tasks: + - include: tasks/ubuntu.yml + when: ansible_distribution == "Ubuntu" + + # TODO: maybe add RPM or Debian handling? diff --git a/ceph-deploy-pull-requests/setup/playbooks/tasks/ubuntu.yml b/ceph-deploy-pull-requests/setup/playbooks/tasks/ubuntu.yml new file mode 100644 index 00000000..cfcebbb3 --- /dev/null +++ b/ceph-deploy-pull-requests/setup/playbooks/tasks/ubuntu.yml @@ -0,0 +1,18 @@ +--- + - name: add deadsnakes ppa + action: apt_repository repo=ppa:fkrull/deadsnakes state=present + + - name: "update apt repo" + action: apt update-cache=yes + + - name: install python requirements + action: apt pkg=$item state=installed + with_items: + - python-software-properties + - python-dev + - python-setuptools + - python2.6 + - python2.7 + + - name: install pip + action: easy_install name=pip -- 2.39.5