From cd23804046822a32b77d43e5aba97230d82de6bc Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 9 Mar 2014 17:19:57 -0300 Subject: [PATCH] boxes: Prevent puppet and chef from being reinstalled --- boxes/debian/install-extras.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/boxes/debian/install-extras.sh b/boxes/debian/install-extras.sh index a489c46..75a1147 100755 --- a/boxes/debian/install-extras.sh +++ b/boxes/debian/install-extras.sh @@ -21,24 +21,31 @@ SALT=${SALT:-0} BABUSHKA=${BABUSHKA:-0} if [ $CHEF = 1 ]; then - # TODO: Check if Chef has been installed - log "Installing Chef" - cat > ${ROOTFS}/tmp/install-chef.sh << EOF + if $(lxc-attach -n ${CONTAINER} -- which chef-solo &>/dev/null); then + log "Chef has been installed on container, skipping" + else + log "Installing Chef" + cat > ${ROOTFS}/tmp/install-chef.sh << EOF #!/bin/sh curl -L https://www.opscode.com/chef/install.sh -k | sudo bash EOF - chmod +x ${ROOTFS}/tmp/install-chef.sh - lxc-attach -n ${CONTAINER} -- /tmp/install-chef.sh + chmod +x ${ROOTFS}/tmp/install-chef.sh + lxc-attach -n ${CONTAINER} -- /tmp/install-chef.sh + fi else log "Skipping Chef installation" fi if [ $PUPPET = 1 ]; then - log "Installing Puppet" - wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb -O "${ROOTFS}/tmp/puppetlabs-release-stable.deb" - lxc-attach -n ${CONTAINER} -- dpkg -i "/tmp/puppetlabs-release-stable.deb" - lxc-attach -n ${CONTAINER} -- apt-get update - lxc-attach -n ${CONTAINER} -- apt-get install puppet -y --force-yes + if $(lxc-attach -n ${CONTAINER} -- which puppet &>/dev/null); then + log "Puppet has been installed on container, skipping" + else + log "Installing Puppet" + wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb -O "${ROOTFS}/tmp/puppetlabs-release-stable.deb" + lxc-attach -n ${CONTAINER} -- dpkg -i "/tmp/puppetlabs-release-stable.deb" + lxc-attach -n ${CONTAINER} -- apt-get update + lxc-attach -n ${CONTAINER} -- apt-get install puppet -y --force-yes + fi else log "Skipping Puppet installation" fi