Comment 3 for bug 1073520

Revision history for this message
James Page (james-page) wrote :

Hi Ante

More feedback post updates

1) dovecot-relation-joined

#!/bin/bash
set -eu

myip=`unit-get private-address`

relation-set imap-host=$my_ip pop-host=$myip

Couple of comments here; the remote service will automatically be able to determine the IP address of the mail-stack-delivery service using:

relation-get private-address

This is implicit - so providing it over the relation explicitly is not required; However I would provide the ports for these services as relation data - for example:

relation-set imap-port=143....

2) postfix-relation-joined

#!/bin/bash
set -eu

current_mynetworks=`postconf mynetworks | cut -d' ' -f3-`
my_ip=`unit-get private-address`
client_ip=`relation-get private-address`
mtatype=`config-get mtatype`

postconf mynetworks="$current_mynetworks $client_ip"

case $mtatype in
  3|4)
        juju-log -l INFO "MTA is listening only on localhost interface!"
        ;;
esac

relation-set smtp-host=$my_ip

Same comment re ip/ports as in 1) plus this needs splitting:

client_ip=`relation-get private-address`

This might not work in -joined; but should always work in -changed; I'd recommend you always write code that relies on relation data (implicit or otherwise) in the -changed hook.

3) postfix-relation-broken/departed

These hooks have subtly different behavior; departed fires when a unit leaves a relation (and you can still do 'relation-get private-address' to find out which one I think - I need to check that one) wheres -broken fires when the entire relationship is removed - and you won't be able todo relation-get's in this type of hook.

Other than those 3 looking pretty good.

Cheers

James