Bogdan Dobrelya 467d84c620 Add centos7 docker support
* Separate OSTYPE specific tasks/files.
* Keep only common tasks and files in the
playbooks dir.

TODO pxe case to be working for centos as well
note, the cmtools.sh installs ansible 2.0.1.0
  in centos7, while we have 2.0.0.2 for ubuntu trusty
note, the base.yaml installs python-keystoneclient
  1:1.3.0-1.el7 from kilo-2 (no juno for centos7),
  while for ubuntu we have one from juno
note, there is no pygraphviz for centos7, see also
  https://bugs.launchpad.net/fuel/+bug/1510884

Closes-bug: #1548851

Change-Id: Icec5637f9242104322d1104725f9f132d1ca16f0
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
2016-03-02 11:16:23 +01:00

127 lines
3.4 KiB
Bash

#!/bin/bash -eux
# CM and CM_VERSION variables should be set inside of the Packer template:
#
# Values for CM can be:
# 'nocm' -- build a box without a configuration management tool
# 'chef' -- build a box with Chef
# 'chefdk' -- build a box with Chef Development Kit
# 'salt' -- build a box with Salt
# 'puppet' -- build a box with Puppet
#
# Values for CM_VERSION can be (when CM is chef|chefdk|salt|puppet):
# 'x.y.z' -- build a box with version x.y.z of Chef
# 'x.y' -- build a box with version x.y of Salt
# 'x.y.z-apuppetlabsb' -- build a box with package version of Puppet
# 'latest' -- build a box with the latest version
#
# Set CM_VERSION to 'latest' if unset because it can be problematic
# to set variables in pairs with Packer (and Packer does not support
# multi-value variables).
CM_VERSION=${CM_VERSION:-latest}
#
# Provisioner installs.
#
install_chef()
{
echo "==> Installing Chef"
if [[ ${CM_VERSION} == 'latest' ]]; then
echo "Installing latest Chef version"
curl -Lk https://www.getchef.com/chef/install.sh | bash
else
echo "Installing Chef version ${CM_VERSION}"
curl -Lk https://www.getchef.com/chef/install.sh | bash -s -- -v $CM_VERSION
fi
}
install_chef_dk()
{
echo "==> Installing Chef Development Kit"
if [[ ${CM_VERSION:-} == 'latest' ]]; then
echo "==> Installing latest Chef Development Kit version"
curl -Lk https://www.getchef.com/chef/install.sh | sh -s -- -P chefdk
else
echo "==> Installing Chef Development Kit ${CM_VERSION}"
curl -Lk https://www.getchef.com/chef/install.sh | sh -s -- -P chefdk -v ${CM_VERSION}
fi
echo "==> Adding Chef Development Kit and Ruby to PATH"
echo 'eval "$(chef shell-init bash)"' >> /home/vagrant/.bash_profile
chown vagrant /home/vagrant/.bash_profile
}
install_salt()
{
echo "==> Installing Salt"
if [[ ${CM_VERSION:-} == 'latest' ]]; then
echo "Installing latest Salt version"
wget -O - http://bootstrap.saltstack.org | sudo sh
else
echo "Installing Salt version $CM_VERSION"
curl -L http://bootstrap.saltstack.org | sudo sh -s -- git $CM_VERSION
fi
}
install_puppet()
{
echo "==> Installing Puppet"
. /etc/lsb-release
DEB_NAME=puppetlabs-release-${DISTRIB_CODENAME}.deb
wget http://apt.puppetlabs.com/${DEB_NAME}
dpkg -i ${DEB_NAME}
apt-get update
if [[ ${CM_VERSION:-} == 'latest' ]]; then
echo "Installing latest Puppet version"
apt-get install -y puppet
else
echo "Installing Puppet version $CM_VERSION"
apt-get install -y puppet-common=$CM_VERSION puppet=$CM_VERSION
fi
rm -f ${DEB_NAME}
}
install_ansible()
{
echo "==> Installing Ansible python egg"
# TODO(bogdando): maybe this is better:
# http://docs.ansible.com/ansible/intro_installation.html#latest-releases-via-apt-ubuntu
apt-get remove -f python-pip
sudo apt-get install -y python-setuptools
sudo easy_install pip
sudo pip install -U pip
sudo pip install ansible
}
#
# Main script
#
case "${CM}" in
'chef')
install_chef
;;
'chefdk')
install_chef_dk
;;
'salt')
install_salt
;;
'puppet')
install_puppet
;;
'ansible')
install_ansible
;;
*)
echo "==> Building box without baking in a configuration management tool"
;;
esac