Charm: ~clint-fewbar:oneiric/puppet
Revision: 6
Hook: puppetmaster-relation-joined
#!/bin/sh
set -uex
if [ -f /etc/puppet/juju-associated ] ; then
juju-log -l ERROR "Puppet can only have one master (`cat /etc/puppet/juju-associated`)"
exit 99
fi
if [ ! -f data/juju-primary-unit ] ; then
juju-log -l INFO "Primary unit not related yet. Deferring."
mkdir -p data
echo $0,$JUJU_RELATION_ID >> data/deferred
exit 0
fi
primary_unit=`cat data/juju-primary-unit`
primary_service=${primary_unit%%/*}
scripts/update-puppet-server `relation-get private-address`
fingerprint=`puppet agent --fingerprint`
relation-set fingerprint=$fingerprint primary_service=$primary_service
echo $JUJU_REMOTE_UNIT > /etc/puppet/juju-associated