From 1b6b4d151fbb359e001c06707af7a323ed8bff26 Mon Sep 17 00:00:00 2001 From: Nayeem Syed Date: Fri, 29 Apr 2016 17:18:53 +0100 Subject: [PATCH] Added ANSIBLE=1 flag for pre-installing ansible --- README.md | 5 +++-- debian/install-ansible.sh | 7 +++++++ debian/install-extras.sh | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 debian/install-ansible.sh diff --git a/README.md b/README.md index 5626542..e5186e8 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,14 @@ By default no provisioning tools will be included but you can pick the ones you want by providing some environmental variables. For example: ```sh -PUPPET=1 CHEF=1 SALT=1 BABUSHKA=1 \ +ANSIBLE=1 PUPPET=1 CHEF=1 SALT=1 BABUSHKA=1 \ make precise ``` -Will build a Ubuntu Precise x86_64 box with latest Puppet, Chef, Salt and +Will build a Ubuntu Precise x86_64 box with latest Ansible, Puppet, Chef, Salt and Babushka pre-installed. +When using ANSIBLE=1, an optional ANSIBLE_VERSION parameter may be passed that will specify which version of ansible to install. By default it will install the latest Ansible. ## Pre built base boxes diff --git a/debian/install-ansible.sh b/debian/install-ansible.sh new file mode 100755 index 0000000..1be198e --- /dev/null +++ b/debian/install-ansible.sh @@ -0,0 +1,7 @@ +#!/bin/bash +ANSIBLE_VERSION=${ANSIBLE_VERSION:-latest} + +apt-get install -y build-essential python-setuptools python-jinja2 python-yaml python-paramiko python-httplib2 python-crypto sshpass +wget https://releases.ansible.com/ansible/ansible-$ANSIBLE_VERSION.tar.gz -O /tmp//ansible.tar.gz +tar -zxvf /tmp/ansible.tar.gz -C /tmp/ && rm -r /tmp/ansible.tar.gz +cd /tmp/ansible-* && make && make install diff --git a/debian/install-extras.sh b/debian/install-extras.sh index 88f9a8d..2f36c1c 100755 --- a/debian/install-extras.sh +++ b/debian/install-extras.sh @@ -26,6 +26,7 @@ utils.lxc.attach apt-get update utils.lxc.attach apt-get install ${PACKAGES[*]} -y --force-yes utils.lxc.attach apt-get upgrade -y --force-yes +ANSIBLE=${ANSIBLE:-0} CHEF=${CHEF:-0} PUPPET=${PUPPET:-0} SALT=${SALT:-0} @@ -37,6 +38,18 @@ if [ $DISTRIBUTION = 'debian' ]; then -i ${ROOTFS}/etc/bash.bashrc fi +if [ $ANSIBLE = 1 ]; then + if $(lxc-attach -n ${CONTAINER} -- which ansible &>/dev/null); then + log "Ansible has been installed on container, skipping" + else + info "Installing Ansible" + cp debian/install-ansible.sh ${ROOTFS}/tmp/ && chmod +x ${ROOTFS}/tmp/install-ansible.sh + utils.lxc.attach /tmp/install-ansible.sh &>>${LOG} + fi +else + log "Skipping Ansible installation" +fi + if [ $CHEF = 1 ]; then if $(lxc-attach -n ${CONTAINER} -- which chef-solo &>/dev/null); then log "Chef has been installed on container, skipping"