~ce-infrastructure/capomastro/deploy-mojo-jumpstart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash -xev
                
echo "Deploying into Juju environment..."
export JUJU_REPOSITORY=${PWD}/charms

# Deploy the charms from the store with our config files, if needed
juju deploy --config=config/apache.yaml cs:apache2
juju deploy cs:rabbitmq-server
juju deploy cs:postgresql

# Deploy our own stuff
juju deploy --config=config/jenkins.yaml local:trusty/jenkins --constraints="mem=10G root-disk=100G cpu-cores=10"
juju deploy --config=config/apache-openid.yaml local:trusty/apache-openid
juju deploy --config=config/capomastro.yaml local:trusty/capomastro

while juju status | grep pending 2>&1> /dev/null; do
	echo "Waiting pending deployments to finish, sleeping..."
	sleep 60
done

# Mandatory relations between the service charms

# FIXME: these sleep commands are possibly a bad idea but we will
# need to check this with IS first because we don't quite get how
# sequential interdependent relations can be set safely...
# e.g. capomastro needs pgsql and rabbit but each relation
# needs to restart the service after config-changed is called
# and if they both do that at the same time there is a race here

juju add-relation postgresql:db capomastro && sleep 30
juju add-relation rabbitmq-server capomastro && sleep 30
juju add-relation jenkins capomastro && sleep 30
juju add-relation apache2 apache-openid && sleep 30

# FIXME: not in the trusty series, really?
# juju deploy cs:precise/nrpe-external-master

# FIXME: principal and subordinate services' series must match
# juju add-relation nrpe-external-master capomastro && sleep 30

# FIXME: how could this be inside the config.yaml for Apache instead?
juju set apache2 vhost_http_template="$(base64 < ${JUJU_REPOSITORY}/trusty/capomastro/templates/http_virtualhost.tmpl)"
juju add-relation apache2:reverseproxy capomastro:website && sleep 30

# Expose web services
juju expose jenkins
juju expose apache2