#!/bin/bash # Copyright 2013 OpenStack Foundation. # Copyright 2013 Hewlett-Packard Development Company, L.P. # Copyright 2013 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # Test condition to install puppet 3 PUPPET_VERSION=${PUPPET_VERSION:-3} if [ "$PUPPET_VERSION" = '3' ]; then THREE=yes echo "Running in 3 mode" fi # # Distro identification functions # note, can't rely on lsb_release for these as we're bare-bones and # it may not be installed yet) function is_fedora { [ -f /usr/bin/yum ] && cat /etc/*release | grep -q -e "Fedora" } function is_rhel6 { [ -f /usr/bin/yum ] && \ cat /etc/*release | grep -q -e "Red Hat" -e "CentOS" && \ cat /etc/*release | grep -q 'release 6' } function is_rhel7 { [ -f /usr/bin/yum ] && \ cat /etc/*release | grep -q -e "Red Hat" -e "CentOS" && \ cat /etc/*release | grep -q 'release 7' } function is_ubuntu { [ -f /usr/bin/apt-get ] } function is_opensuse { [ -f /usr/bin/zypper ] && \ cat /etc/os-release | grep -q -e "openSUSE" } # # Distro specific puppet installs # function setup_puppet_fedora { yum update -y # NOTE: we preinstall lsb_release to ensure facter sets # lsbdistcodename yum install -y redhat-lsb-core git puppet mkdir -p /etc/puppet/modules/ if [ "$THREE" != 'yes' ]; then gem install hiera hiera-puppet ln -s /usr/local/share/gems/gems/hiera-puppet-* /etc/puppet/modules/ fi # Puppet expects the pip command named as pip-python on # Fedora, as per the packaged command name. However, we're # installing from get-pip.py so it's just 'pip'. An easy # work-around is to just symlink pip-python to "fool" it. # See upstream issue: # https://tickets.puppetlabs.com/browse/PUP-1082 ln -fs /usr/bin/pip /usr/bin/pip-python } function setup_puppet_rhel7 { local puppet_pkg="https://yum.puppetlabs.com/el/7/products/x86_64/puppetlabs-release-7-10.noarch.rpm" # install a bootstrap epel repo to install latest epel-release # package (which provides correct gpg keys, etc); then remove # boostrap cat > /etc/yum.repos.d/epel-bootstrap.repo < /etc/yum.repos.d/epel-bootstrap.repo < /etc/yum.repos.d/puppetlabs.repo <<"EOF" [puppetlabs-products] name=Puppet Labs Products El 6 - $basearch baseurl=http://yum.puppetlabs.com/el/6/products/$basearch gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs enabled=1 gpgcheck=1 EOF if [ "$THREE" != 'yes' ]; then echo 'exclude=puppet-2.8* puppet-2.9* puppet-3* facter-2*' >> /etc/yum.repos.d/puppetlabs.repo fi yum update -y # see comments in setup_puppet_fedora ln -s /usr/bin/pip /usr/bin/pip-python } function setup_puppet_ubuntu { if ! which lsb_release > /dev/null 2<&1 ; then DEBIAN_FRONTEND=noninteractive apt-get --option 'Dpkg::Options::=--force-confold' \ --assume-yes install -y --force-yes lsb-release fi lsbdistcodename=`lsb_release -c -s` if [ $lsbdistcodename != 'trusty' ] ; then rubypkg=rubygems else rubypkg=ruby THREE=yes fi if [ "$THREE" == 'yes' ]; then PUPPET_VERSION=3.* PUPPETDB_VERSION=2.* FACTER_VERSION=2.* else PUPPET_VERSION=2.7* PUPPETDB_VERSION=1.* FACTER_VERSION=1.* fi cat > /etc/apt/preferences.d/00-puppet.pref <