Merge pull request #2 from Gijutsu/pre_and_post-tasks

Updated pre and post tasks
This commit is contained in:
Fredrik Thulin 2016-09-01 14:17:23 +02:00 committed by GitHub
commit 5294261f2c
5 changed files with 26 additions and 12 deletions

View file

@ -4,11 +4,19 @@ if [ -z "$COSMOS_KEYS" ]; then
COSMOS_KEYS=/etc/cosmos/keys
fi
# Install new keys discovered in the $COSMOS_KEYS directory
for k in $COSMOS_KEYS/*.pub; do
fp=`cosmos gpg --with-colons --with-fingerprint < $k | awk -F: '$1 == "pub" {print $5}'`
cosmos gpg --with-colons --fingerprint | grep -q ":$fp:" || cosmos gpg --import < $k
fp_in_db=`cosmos gpg --with-colons --fingerprint | grep ":$fp:"`
if [ "x`echo $fp_in_db | grep '^pub:e:'`" != "x" ]; then
echo "$0: Key expired, will re-import it from $k"
cosmos gpg --fingerprint $fp
fi
# The removal of any ^pub:e: entrys means to ignore expired keys - thereby importing them again.
echo $fp_in_db | grep -v "^pub:e:" | grep -q ":$fp:" || cosmos gpg --import < $k
done
# Delete keys no longer present in $COSMOS_KEYS directory
for fp in `cosmos gpg --with-colons --fingerprint | awk -F: '$1 == "pub" {print $5}'`; do
seen="no"
for k in $COSMOS_KEYS/*.pub; do

View file

@ -24,8 +24,8 @@ if [ -f $CONFIG ]; then
# First pass to clone any new modules, and update those marked for updating.
grep -E -v "^#" $CONFIG | (
while read module src update pattern; do
# We only support git:// urls atm
if [ "${src:0:6}" = "git://" ]; then
# We only support git:// urls and https:// urls atm
if [ "${src:0:6}" = "git://" -o "${src:0:8}" = "https://" ]; then
if [ ! -d $CACHE_DIR/scm/$module ]; then
git clone -q $src $CACHE_DIR/scm/$module
elif [ -d $CACHE_DIR/scm/$module/.git ]; then
@ -63,7 +63,7 @@ if [ -f $CONFIG ]; then
grep -E -v "^#" $CONFIG | (
while read module src update pattern; do
# We only support git:// urls atm
if [ "${src:0:6}" = "git://" ]; then
if [ "${src:0:6}" = "git://" -o "${src:0:8}" = "https://" ]; then
# Verify git tag
cd $CACHE_DIR/scm/$module
TAG=$(git tag -l "${pattern:-*}" | sort | tail -1)

View file

@ -1,13 +1,13 @@
#!/bin/sh
if [ "x$COSMOS_VERBOSE" = "xy" ]; then
args="--verbose"
args="--verbose --show_diff"
else
args="--logdest=syslog"
fi
if [ -f /usr/bin/puppet -a -d /etc/puppet/manifests ]; then
for m in `find /etc/puppet/manifests -name \*.pp`; do
puppet apply $args < $m
puppet apply $args $m
done
fi

View file

@ -1,4 +1,6 @@
#!/bin/sh
if (( $RANDOM % 20 == 0)); then
apt-get -qq update
apt-get -qq -y autoremove
fi

View file

@ -9,9 +9,13 @@ stamp="$COSMOS_BASE/stamps/puppet-tools-v01.stamp"
if ! test -f $stamp -a -f /usr/bin/puppet; then
codename=`lsb_release -c| awk '{print $2}'`
wget -c http://apt.puppetlabs.com/puppetlabs-release-${codename}.deb
dpkg -i puppetlabs-release-${codename}.deb
rm -f puppetlabs-release-${codename}.deb*
puppetdeb="$COSMOS_REPO/apt/puppetlabs-release-${codename}.deb"
if [ ! -f $puppetdeb ]; then
echo "$0: Puppet deb for release $codename not found in $COSMOS_REPO/apt/"
echo " Get it from https://apt.puppetlabs.com/ and put it in the Cosmos repo."
exit 1
fi
dpkg -i $puppetdeb
apt-get update
apt-get -y install puppet-common