Don't clear-out all repos in puppet cleanup

dib 1.17.0 includes fixes for debian-minimal to work with the
apt-sources element in I69dbaa34be3db3d667e6bd8450ef4ce04a751c70

This moved to having the base repos split out from the usual
/etc/apt/sources.list into separate files in /etc/apt/sources.list.d

Unfortunately, this puppet module does the cleanup by glob removal of
everything in that directory, which is a bit unsafe.

I've refactored this slightly so that, like the RedHat path, we only
remove the puppetlabs repos files.

Change-Id: I5bcd8880a90d238b77aaacfd1eaf0a720552c7ee
This commit is contained in:
Ian Wienand 2016-06-09 10:17:53 +10:00
parent 8365913c73
commit 8154680e6a

View File

@ -27,15 +27,24 @@ fi
set -e
OS_FAMILY=$(facter osfamily)
if [ "$OS_FAMILY" == "Debian" ] ; then
rm -f /etc/apt/sources.list.d/*
apt-get update
elif [ "$OS_FAMILY" == "RedHat" ] ; then
# Can't delete * in yum.repos.d since all of the repos are listed there.
# Be specific instead.
if [ -f /etc/yum.repos.d/puppetlabs.repo ] ; then
sudo rm -f /etc/yum.repos.d/puppetlabs.repo
fi
fi
case $OS_FAMILY in
"Debian")
repo=/etc/apt/sources.list.d/puppetlabs.list
update="apt-get update"
;;
"RedHat")
repo=/etc/yum.repos.d/puppetlabs.repo
# yum/dnf will notice this is gone, so don't need to spend
# time updating.
update=""
;;
*)
die "Don't know how to cleanup!"
;;
esac
rm -f $repo
$update
rm /usr/local/bin/prepare-node