Merge lp:~yellow/charms/trusty/kibana/trunk into lp:charms/trusty/kibana

Proposed by Jay R. Wren
Status: Merged
Merged at revision: 18
Proposed branch: lp:~yellow/charms/trusty/kibana/trunk
Merge into: lp:charms/trusty/kibana
Diff against target: 153 lines (+72/-9)
8 files modified
config.yaml (+9/-0)
hooks/config-changed (+18/-0)
hooks/install (+5/-2)
hooks/start (+1/-3)
hooks/stop (+3/-2)
hooks/web-relation-joined (+3/-1)
metadata.yaml (+1/-1)
tests/12-port-change.py (+32/-0)
To merge this branch: bzr merge lp:~yellow/charms/trusty/kibana/trunk
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Review via email: mp+262373@code.launchpad.net

Description of the change

Adds nginx tcp port configuration option and a path option for configuring it to be proxy fronted with a path. e.g. /kibana and not at the root of a url.

To post a comment you must log in.
Revision history for this message
Jay R. Wren (evarlast) wrote :
24. By Jay R. Wren

close port only if previously opened

25. By Jay R. Wren

fix idempotency problems

26. By Jay R. Wren

explicitly define empty env var

Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM, I've left a comment on how you could simplify some of the logic, but otherwise +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2014-11-05 05:21:37 +0000
+++ config.yaml 2015-06-18 20:53:52 +0000
@@ -11,3 +11,12 @@
11 type: string11 type: string
12 default: '74c6b8b79d1bfc7e4d5376e3c9ecb0fa1e79c986'12 default: '74c6b8b79d1bfc7e4d5376e3c9ecb0fa1e79c986'
13 description: the sha1sum of the kibana_source13 description: the sha1sum of the kibana_source
14 port:
15 type: int
16 default: 80
17 description: The tcp port on which nginx will listen.
18 path:
19 type: string
20 default: ''
21 description: 'The url path of kibana. This is required if kibana is
22 proxied at a non root path. e.g. http://example.com/kibana/'
1423
=== added file 'hooks/config-changed'
--- hooks/config-changed 1970-01-01 00:00:00 +0000
+++ hooks/config-changed 2015-06-18 20:53:52 +0000
@@ -0,0 +1,18 @@
1#!/bin/bash
2set -eux
3
4PORT=$(config-get port)
5KIBANA_PATH=$(config-get path)
6
7sed -i "s/listen.*/listen *:$PORT;/" /etc/nginx/sites-available/kibana
8
9sed -i "s@elasticsearch: .*@elasticsearch: '//'+window.location.hostname+'$KIBANA_PATH',@" /srv/kibana3/config.js
10
11service nginx reload
12
13[[ -r .PREVOPENPORT ]] && PREVOPENPORT=$(cat .PREVOPENPORT) || PREVOPENPORT=''
14[[ -z "$PREVOPENPORT" ]] || close-port $PREVOPENPORT/tcp
15
16open-port $PORT/tcp
17echo $PORT > .PREVOPENPORT
18
019
=== modified file 'hooks/install'
--- hooks/install 2015-04-01 19:38:58 +0000
+++ hooks/install 2015-06-18 20:53:52 +0000
@@ -26,8 +26,10 @@
2626
27pushd /srv27pushd /srv
2828
29tar xzvf /tmp/kibana.tgz29if [[ ! -d kibana3 ]]; then
30mv ${KIBANA_SOURCE_UNPACK_DIRECTORY} kibana330 tar xzvf /tmp/kibana.tgz
31 mv ${KIBANA_SOURCE_UNPACK_DIRECTORY} kibana3
32fi
3133
32rm -f /etc/nginx/sites-enabled/default34rm -f /etc/nginx/sites-enabled/default
3335
@@ -36,6 +38,7 @@
36rm -f /srv/kibana3/config.js38rm -f /srv/kibana3/config.js
37install -o root -g root -m 0644 files/charm/config.js /srv/kibana3/config.js39install -o root -g root -m 0644 files/charm/config.js /srv/kibana3/config.js
3840
41hooks/config-changed
3942
40ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/kibana43ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/kibana
41ln -s /etc/nginx/sites-available/es_cluster /etc/nginx/sites-enabled/es_cluster44ln -s /etc/nginx/sites-available/es_cluster /etc/nginx/sites-enabled/es_cluster
4245
=== modified file 'hooks/start' (properties changed: +x to -x)
--- hooks/start 2013-09-29 21:58:50 +0000
+++ hooks/start 2015-06-18 20:53:52 +0000
@@ -3,6 +3,4 @@
3# Note that currently this is run directly after install3# Note that currently this is run directly after install
4# i.e. 'service apache2 start'4# i.e. 'service apache2 start'
55
6initctl start nginx6service nginx start
7#open-port 5601/tcp
8open-port 80/tcp
97
=== modified file 'hooks/stop'
--- hooks/stop 2013-09-29 21:58:50 +0000
+++ hooks/stop 2015-06-18 20:53:52 +0000
@@ -6,5 +6,6 @@
6# balancer to stop sending traffic.6# balancer to stop sending traffic.
7# rm /srv/webroot/server-live.txt && sleep 307# rm /srv/webroot/server-live.txt && sleep 30
88
9initctl stop nginx9service nginx stop
10close-port 80/tcp10[[ -r .PREVOPENPORT ]] && PREVOPENPORT=$(cat .PREVOPENPORT) || PREVOPENPORT=''
11[[ -z "$PREVOPENPORT" ]] || close-port $PREVOPENPORT/tcp
1112
=== modified file 'hooks/web-relation-joined'
--- hooks/web-relation-joined 2013-11-26 08:51:58 +0000
+++ hooks/web-relation-joined 2015-06-18 20:53:52 +0000
@@ -2,6 +2,8 @@
2set -eux2set -eux
3juju-log $JUJU_REMOTE_UNIT joined3juju-log $JUJU_REMOTE_UNIT joined
44
5PORT=$(config-get port)
6
5# Set ip/port for web relation7# Set ip/port for web relation
6relation-set port="80"8relation-set port="$PORT"
7relation-set host=`unit-get private-address`9relation-set host=`unit-get private-address`
810
=== modified file 'metadata.yaml'
--- metadata.yaml 2014-10-29 15:52:18 +0000
+++ metadata.yaml 2015-06-18 20:53:52 +0000
@@ -7,7 +7,7 @@
7 - applications 7 - applications
8provides:8provides:
9 web:9 web:
10 interface: kibana10 interface: http
11requires:11requires:
12 rest:12 rest:
13 interface: elasticsearch13 interface: elasticsearch
1414
=== added file 'tests/12-port-change.py'
--- tests/12-port-change.py 1970-01-01 00:00:00 +0000
+++ tests/12-port-change.py 2015-06-18 20:53:52 +0000
@@ -0,0 +1,32 @@
1#!/usr/bin/python3
2
3import amulet
4import requests
5
6seconds = 20000
7
8d = amulet.Deployment(series='trusty')
9
10d.add('kibana')
11d.configure('kibana', {'port': 81})
12
13d.expose('kibana')
14
15try:
16 d.setup(timeout=seconds)
17except amulet.helpers.TimeoutError:
18 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
19except:
20 raise
21
22
23def test_web_interface():
24 kibana_unit = d.sentry.unit['kibana/0']
25 url = 'http://%s:81/' % kibana_unit.info['public-address']
26 r = requests.get(url)
27 if not r.ok:
28 amulet.raise_status(amulet.FAIL,
29 msg="Error getting kibana page.")
30
31
32test_web_interface()

Subscribers

People subscribed via source and target branches