2
# Deploy langpack-o-matic charm
3
# Author: Martin Pitt <martin.pitt@ubuntu.com>
9
# settings for deployment in private Canonistack or juju-local
11
# settings for Canonical ProdStack 4.5
12
if [ "$OS_USERNAME" = "prod-ues-langpack" ]; then
16
CHARMDIR=$(dirname $(readlink -f $0))
19
# Juju 1 vs. 2 abstractions
22
if juju --version 2>&1 | grep -q '^2'; then
25
elif type juju-1 >/dev/null 2>&1; then
33
if [ -n "$JUJU1" ]; then
36
JUJU_SET="$JUJU set-config"
42
if [ -n "$JUJU1" ]; then
43
$JUJU deploy --repository "$CHARMDIR" "$@" local:$CHARM_RELEASE/$charm $APPNAME
45
$JUJU deploy --series $CHARM_RELEASE "$@" "$CHARMDIR/$CHARM_RELEASE/$charm" $APPNAME
54
echo "waiting for $1 to get deployed..."
55
while ! $JUJU status --format=short $1 | egrep 'active|started|idle'; do
60
subordinate_charms() {
61
if [ -n "$LANDSCAPE" ]; then
62
echo 'deploying subordinate charms to $1'
63
$JUJU add-relation ksplice "$1"
64
$JUJU add-relation landscape-client "$1"
70
if [ -z "$1" ] || [ -n "$2" ]; then
71
echo "Usage: $0 <credentials dir>" >&2
75
if [ ! -d "$CREDENTIALS_DIR" ]; then
76
echo "ERROR: $CREDENTIALS_DIR does not exist" >&2
83
trap "rm $config_yaml" EXIT INT QUIT PIPE
86
# deploy subordinate charms for automatic machine management (only if
87
# $LANDSCAPE is set, i. e. for the production environment in ProdStack)
90
if [ -n "$LANDSCAPE" ]; then
91
[ -d "$CHARMDIR/$CHARM_RELEASE/landscape-client" ] || bzr checkout --lightweight lp:charms/trusty/landscape-client "$CHARMDIR/$CHARM_RELEASE/landscape-client"
92
[ -d "$CHARMDIR/$CHARM_RELEASE/ksplice" ] || { echo "Please check out ksplice charm to $CHARMDIR/$CHARM_RELEASE"; exit 1; }
95
# install/update basenode into charms
97
[ -d "$CHARMDIR/basenode" ] || { echo "Please check out basenode into $CHARMDIR"; exit 1; }
98
for charmdir in $CHARMDIR/$CHARM_RELEASE/*; do
99
# ignore subordinate charms
100
if grep -q 'subordinate:.*true' $charmdir/metadata.yaml; then
103
echo "Installing basenode into $charmdir"
104
rm -rf "$charmdir/exec.d/basenode"
105
mkdir -p "$charmdir/exec.d"
106
cp -r "$CHARMDIR/basenode" "$charmdir/exec.d"
109
if ! $JUJU status | grep -q ksplice; then
111
$JUJU_SET ksplice accesskey=$(cat /srv/mojo/LOCAL/${MOJO_PROJECT}/canonical-is-ksplice.key)
112
$JUJU_SET ksplice source=""
114
if ! $JUJU status | grep -q landscape-client; then
115
cat <<EOF >> "$config_yaml"
117
url: https://landscape.is.canonical.com/message-system
118
ping-url: http://landscape.is.canonical.com/ping
119
account-name: standalone
120
registration-key: $(cat /srv/mojo/LOCAL/${MOJO_PROJECT}/canonical-is-landscape.key)
121
tags: juju-managed, devops-instance, devops-production
123
deploy_charm landscape-client --config $config_yaml
128
# deploy langpack-o-matic charm
131
if $JUJU status | grep -q langpack-o-matic; then
132
echo 'WARNING: langpack-o-matic already deployed, skipping' >&2
134
cat <<EOF >> "$config_yaml"
137
$(cat "$CREDENTIALS_DIR/langpack.asc" | sed 's/^/ /')
139
$(cat "$CREDENTIALS_DIR/langpack.priv.asc" | sed 's/^/ /')
141
$(cat "$CREDENTIALS_DIR/launchpad-export-settings.credentials" | sed 's/^/ /')
144
deploy_charm langpack-o-matic --config "$config_yaml" --constraints 'root-disk=40G'
145
wait_deployed langpack-o-matic
146
subordinate_charms langpack-o-matic