Merge lp:~michael.nelson/charms/trusty/elasticsearch/elasticsearch2-with-xenial-support into lp:~onlineservices-charmers/charms/trusty/elasticsearch/elasticsearch2

Proposed by Michael Nelson
Status: Needs review
Proposed branch: lp:~michael.nelson/charms/trusty/elasticsearch/elasticsearch2-with-xenial-support
Merge into: lp:~onlineservices-charmers/charms/trusty/elasticsearch/elasticsearch2
Diff against target: 73 lines (+28/-1)
4 files modified
hooks/hooks.py (+5/-0)
hooks/install (+8/-0)
tasks/install-elasticsearch.yml (+12/-1)
tasks/setup-ufw.yml (+3/-0)
To merge this branch: bzr merge lp:~michael.nelson/charms/trusty/elasticsearch/elasticsearch2-with-xenial-support
Reviewer Review Type Date Requested Status
Canonical Onlineservices charmers Pending
Review via email: mp+315196@code.launchpad.net

Commit message

Update to support Xenial (where python2 is not installed by default)

Description of the change

Two changes to enable xenial deploys (without breaking trusty deploys):
 * Ensure python-minimal and python-yaml are installed *before* the install hook is run
 * Ensure openjdk-8-jre is used on xenial (trusty has 7)

When testing I also saw that the firewall setup, run during install, was sometimes curling localhost:9200 before it was available - so I added a wait there too.

I've not yet had a chance to test this on anything other than a local provider, but will do so next week.

If this passes tests etc., I'd also like to push this to:

https://code.launchpad.net/~onlineservices-charmers/charms/xenial/elasticsearch/trunk

as well (and not diverge the charm for the trusty/xenial versions - at least not yet as it's not necessary).

Historical note: online-services initially maintained the elasticsearch branch, but when ES 2.0 was released, there were backwards incompatible changes, so we created and additionally maintained the elasticsearch2 branch which is targeted in the MP. Independently, Charles and Marco then landed ES2.0 support to the original elasticsearch branch (breaking 1.0 support), so the two have diverged slightly.

To post a comment you must log in.

Unmerged revisions

46. By Michael Nelson

Support xenial as well as trusty installations

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2015-10-27 22:30:30 +0000
3+++ hooks/hooks.py 2017-01-20 07:02:23 +0000
4@@ -97,4 +97,9 @@
5
6
7 if __name__ == "__main__":
8+ # Ensure if the hooks/hooks.py has been called directly that we treat
9+ # it as an install hook.
10+ if sys.argv[0] == 'hooks/hooks.py':
11+ sys.argv[0] = 'hooks/install'
12+
13 hooks.execute(sys.argv)
14
15=== added file 'hooks/install'
16--- hooks/install 1970-01-01 00:00:00 +0000
17+++ hooks/install 2017-01-20 07:02:23 +0000
18@@ -0,0 +1,8 @@
19+#!/bin/bash
20+set -o errexit
21+set -o nounset
22+
23+# Ensure /usr/bin/python is available (for xenial support with current
24+# python2 charm).
25+apt-get install --assume-yes python-minimal python-yaml
26+hooks/hooks.py
27
28=== removed symlink 'hooks/install'
29=== target was u'hooks.py'
30=== modified file 'tasks/install-elasticsearch.yml'
31--- tasks/install-elasticsearch.yml 2015-11-20 03:06:23 +0000
32+++ tasks/install-elasticsearch.yml 2017-01-20 07:02:23 +0000
33@@ -16,7 +16,7 @@
34 state: present
35 when: apt_repository != ""
36
37-- name: Install dependent packages.
38+- name: Install dependent packages for trusty or other non-xenial.
39 apt: pkg={{ item }} state=latest update_cache=yes
40 tags:
41 - install
42@@ -24,6 +24,17 @@
43 with_items:
44 - openjdk-7-jre-headless
45 - ufw
46+ when: ansible_distribution_major_version != "16"
47+
48+- name: Install dependent packages for xenial.
49+ apt: pkg={{ item }} state=latest update_cache=yes
50+ tags:
51+ - install
52+ - upgrade-charm
53+ with_items:
54+ - openjdk-8-jre-headless
55+ - ufw
56+ when: ansible_distribution_major_version == "16"
57
58 - name: Check for local elasticsearch.deb in payload.
59 stat: path=files/elasticsearch.deb
60
61=== modified file 'tasks/setup-ufw.yml'
62--- tasks/setup-ufw.yml 2014-10-31 03:43:31 +0000
63+++ tasks/setup-ufw.yml 2017-01-20 07:02:23 +0000
64@@ -40,6 +40,9 @@
65 with_items: relations["peer"]
66 when: firewall_enabled
67
68+- name: Wait until the local service is available
69+ wait_for: port=9200
70+
71 # Only deny incoming on 9300 once the unit is part of a cluster.
72 - name: Record current cluster health
73 uri: url=http://localhost:9200/_cluster/health return_content=yes

Subscribers

People subscribed via source and target branches