2
# Deploy langpack-o-matic charm
3
# Author: Martin Pitt <martin.pitt@ubuntu.com>
4
# Usage: charms/deploy.sh <credentials-dir>
5
# The credentials-dir is a directory with:
6
# - langpack.asc: Public GPG key of the Launchpad user that uploads langpacks
8
# - langpack.priv.asc: Corresponding private key
9
# - launchpad-export-settings.credentials: Launchpad token for a
10
# ~ubuntu-langpack team user that can manipulate
11
# https://translations.launchpad.net/ubuntu/xenial/+language-packs, i. e.
12
# request a full export
14
# For local deployment into LXD it's fine for these to be empty, as you most
15
# probably don't want to actually upload packages to Ubuntu:
17
# touch /tmp/creds/{langpack.asc,langpack.priv.asc,launchpad-export-settings.credentials}
19
# For Ubuntu's production deployment, these files are on
20
# wendigo.canonical.com:~prod-ues-langpack/credentials/
26
# settings for deployment in private Canonistack or juju-local
28
# settings for Canonical ProdStack 4.5
29
if [ "$OS_USERNAME" = "prod-ues-langpack" ]; then
33
CHARMDIR=$(dirname $(readlink -f $0))
36
# Juju 1 vs. 2 abstractions
39
if juju --version 2>&1 | grep -q '^2'; then
42
elif type juju-1 >/dev/null 2>&1; then
50
if [ -n "$JUJU1" ]; then
53
JUJU_SET="$JUJU set-config"
59
if [ -n "$JUJU1" ]; then
60
$JUJU deploy --repository "$CHARMDIR" "$@" local:$CHARM_RELEASE/$charm $APPNAME
62
$JUJU deploy --series $CHARM_RELEASE "$@" "$CHARMDIR/$CHARM_RELEASE/$charm" $APPNAME
71
echo "waiting for $1 to get deployed..."
72
while ! $JUJU status --format=short $1 | egrep 'active|started|idle'; do
77
subordinate_charms() {
78
if [ -n "$LANDSCAPE" ]; then
79
echo 'deploying subordinate charms to $1'
80
$JUJU add-relation ksplice "$1"
81
$JUJU add-relation landscape-client "$1"
87
if [ -z "$1" ] || [ -n "$2" ]; then
88
echo "Usage: $0 <credentials dir>" >&2
92
if [ ! -d "$CREDENTIALS_DIR" ]; then
93
echo "ERROR: $CREDENTIALS_DIR does not exist" >&2
100
trap "rm $config_yaml" EXIT INT QUIT PIPE
103
# deploy subordinate charms for automatic machine management (only if
104
# $LANDSCAPE is set, i. e. for the production environment in ProdStack)
107
if [ -n "$LANDSCAPE" ]; then
108
[ -d "$CHARMDIR/$CHARM_RELEASE/landscape-client" ] || bzr checkout --lightweight lp:charms/trusty/landscape-client "$CHARMDIR/$CHARM_RELEASE/landscape-client"
109
[ -d "$CHARMDIR/$CHARM_RELEASE/ksplice" ] || { echo "Please check out ksplice charm to $CHARMDIR/$CHARM_RELEASE"; exit 1; }
112
# install/update basenode into charms
114
[ -d "$CHARMDIR/basenode" ] || { echo "Please check out basenode into $CHARMDIR"; exit 1; }
115
for charmdir in $CHARMDIR/$CHARM_RELEASE/*; do
116
# ignore subordinate charms
117
if grep -q 'subordinate:.*true' $charmdir/metadata.yaml; then
120
echo "Installing basenode into $charmdir"
121
rm -rf "$charmdir/exec.d/basenode"
122
mkdir -p "$charmdir/exec.d"
123
cp -r "$CHARMDIR/basenode" "$charmdir/exec.d"
126
if ! $JUJU status | grep -q ksplice; then
128
$JUJU_SET ksplice accesskey=$(cat /srv/mojo/LOCAL/${MOJO_PROJECT}/canonical-is-ksplice.key)
129
$JUJU_SET ksplice source=""
131
if ! $JUJU status | grep -q landscape-client; then
132
cat <<EOF >> "$config_yaml"
134
url: https://landscape.is.canonical.com/message-system
135
ping-url: http://landscape.is.canonical.com/ping
136
account-name: standalone
137
registration-key: $(cat /srv/mojo/LOCAL/${MOJO_PROJECT}/canonical-is-landscape.key)
138
tags: juju-managed, devops-instance, devops-production
140
deploy_charm landscape-client --config $config_yaml
145
# deploy langpack-o-matic charm
148
if $JUJU status | grep -q langpack-o-matic; then
149
echo 'WARNING: langpack-o-matic already deployed, skipping' >&2
151
cat <<EOF >> "$config_yaml"
154
$(cat "$CREDENTIALS_DIR/langpack.asc" | sed 's/^/ /')
156
$(cat "$CREDENTIALS_DIR/langpack.priv.asc" | sed 's/^/ /')
158
$(cat "$CREDENTIALS_DIR/launchpad-export-settings.credentials" | sed 's/^/ /')
161
deploy_charm langpack-o-matic --config "$config_yaml" --constraints 'root-disk=40G'
162
wait_deployed langpack-o-matic
163
subordinate_charms langpack-o-matic