Merge lp:~jamesbeedy/charm-elasticsearch/fixes_for_xenial_5_x into lp:charm-elasticsearch

Proposed by james beedy
Status: Merged
Merged at revision: 60
Proposed branch: lp:~jamesbeedy/charm-elasticsearch/fixes_for_xenial_5_x
Merge into: lp:charm-elasticsearch
Diff against target: 246 lines (+56/-39)
7 files modified
hooks/hooks.py (+2/-17)
hooks/install (+18/-0)
playbook.yaml (+1/-2)
tasks/install-elasticsearch.yml (+18/-10)
tasks/setup-ufw.yml (+4/-4)
templates/elasticsearch.yml (+8/-1)
unit_tests/test_hooks.py (+5/-5)
To merge this branch: bzr merge lp:~jamesbeedy/charm-elasticsearch/fixes_for_xenial_5_x
Reviewer Review Type Date Requested Status
Thomas Cuthbert (community) Approve
Review via email: mp+330793@code.launchpad.net

Description of the change

Updates for 5.x + xenial

To post a comment you must log in.
Revision history for this message
Thomas Cuthbert (tcuthbert) wrote :

+1 LGTM

review: Approve

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 2017-03-29 09:59:19 +0000
3+++ hooks/hooks.py 2017-09-15 00:48:54 +0000
4@@ -8,10 +8,8 @@
5 from charmhelpers.core import hookenv
6 import os
7 import shutil
8-import subprocess as sp
9
10 mountpoint = '/srv/elasticsearch'
11-config = hookenv.config()
12
13 hooks = charmhelpers.contrib.ansible.AnsibleHooks(
14 playbook_path='playbook.yaml',
15@@ -36,14 +34,10 @@
16 ])
17
18
19-@hooks.hook('install', 'upgrade-charm')
20-def install():
21+@hooks.hook('install.real', 'upgrade-charm')
22+def install_real():
23 """Install ansible before running the tasks tagged with 'install'."""
24 # Allow charm users to run preinstall setup.
25- if is_container:
26- config["env-vars"] = {"ES_SKIP_SET_KERNEL_PARAMETERS": "true"}
27- else:
28- config["env-vars"] = {}
29 charmhelpers.payload.execd.execd_preinstall()
30 charmhelpers.contrib.ansible.install_ansible_support(
31 from_ppa=False)
32@@ -103,14 +97,5 @@
33 charmhelpers.core.host.service_start('elasticsearch')
34
35
36-def is_container():
37- """Return True if system is running inside a container"""
38- virt_type = sp.check_output('systemd-detect-virt').decode().strip()
39- if virt_type == 'lxc':
40- return True
41- else:
42- return False
43-
44-
45 if __name__ == "__main__":
46 hooks.execute(sys.argv)
47
48=== modified symlink 'hooks/install' (properties changed: -x to +x)
49=== target was u'hooks.py'
50--- hooks/install 1970-01-01 00:00:00 +0000
51+++ hooks/install 2017-09-15 00:48:54 +0000
52@@ -0,0 +1,18 @@
53+#!/bin/bash
54+# Wrapper to deal with older Ubuntu versions that don't have py3 installed
55+# by default.
56+
57+declare -a DEPS=('python3' 'python3-dnspython' 'python3-netifaces' 'python-dnspython')
58+
59+check_and_install() {
60+ pkg="${1}"
61+ if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
62+ apt-get -y install ${pkg}
63+ fi
64+}
65+
66+for dep in ${DEPS[@]}; do
67+ check_and_install ${dep}
68+done
69+
70+exec ./hooks/install.real
71
72=== added symlink 'hooks/install.real'
73=== target is u'hooks.py'
74=== modified file 'playbook.yaml'
75--- playbook.yaml 2016-09-02 18:52:15 +0000
76+++ playbook.yaml 2017-09-15 00:48:54 +0000
77@@ -19,7 +19,7 @@
78 - include: tasks/peer-relations.yml
79 - include: tasks/setup-ufw.yml
80 tags:
81- - install
82+ - install.real
83 - upgrade-charm
84 - config-changed
85 - client-relation-joined
86@@ -92,4 +92,3 @@
87 - peer-relation-joined
88 - peer-relation-departed
89 - start
90-
91
92=== modified file 'tasks/install-elasticsearch.yml'
93--- tasks/install-elasticsearch.yml 2017-03-29 09:59:19 +0000
94+++ tasks/install-elasticsearch.yml 2017-09-15 00:48:54 +0000
95@@ -1,14 +1,14 @@
96 - name: Add apt key.
97 tags:
98- - install
99+ - install.real
100 - upgrade-charm
101 - config-changed
102- apt_key: url={{ apt_key_url }} state=present id={{gpg_key_id}}
103+ apt_key: url={{ apt_key_url }} state=present id={{gpg_key_id}} validate_certs=no
104 when: apt_key_url != ""
105
106 - name: Add apt archive.
107 tags:
108- - install
109+ - install.real
110 - upgrade-charm
111 - config-changed
112 apt_repository:
113@@ -16,34 +16,42 @@
114 state: present
115 when: apt_repository != ""
116
117+- name: Add java apt archive for trusty only.
118+ tags:
119+ - install.real
120+ - upgrade-charm
121+ - config-changed
122+ apt_repository:
123+ repo: "ppa:openjdk-r/ppa"
124+ state: present
125+ when: ansible_distribution_release == 'trusty'
126+
127 - name: Install dependent packages.
128 apt: pkg={{ item }} state=latest update_cache=yes
129 tags:
130- - install
131+ - install.real
132 - upgrade-charm
133 with_items:
134- - default-jre-headless
135+ - openjdk-8-jre-headless
136 - ufw
137
138 - name: Check for local elasticsearch.deb in payload.
139 stat: path=files/elasticsearch.deb
140 register: stat_elasticsearch_deb
141 tags:
142- - install
143+ - install.real
144 - upgrade-charm
145
146 - name: Install elasticsearch from repository
147 apt: pkg=elasticsearch state=latest update_cache=yes
148- environment: "{{ env_vars }}"
149 tags:
150- - install
151+ - install.real
152 - upgrade-charm
153 when: stat_elasticsearch_deb.stat.exists == false and apt_repository != ""
154
155 - name: Install ElasticSearch from payload
156 command: dpkg -i {{ charm_dir }}/files/elasticsearch.deb
157- environment: "{{ env_vars }}"
158 tags:
159- - install
160+ - install.real
161 - upgrade-charm
162 when: stat_elasticsearch_deb.stat.exists == true
163
164=== modified file 'tasks/setup-ufw.yml'
165--- tasks/setup-ufw.yml 2014-10-31 03:43:31 +0000
166+++ tasks/setup-ufw.yml 2017-09-15 00:48:54 +0000
167@@ -27,8 +27,8 @@
168 when: firewall_enabled
169
170 - name: Open the firewall for all clients
171- ufw: rule=allow src={{ lookup('dns', item['private-address']) }} port=9200 proto=tcp
172- with_items: relations["client"]
173+ ufw: rule=allow src="{{lookup('dig', item.get('address', ''))}}" port=9200 proto=tcp
174+ with_items: "{{relations['client']}}"
175 when: firewall_enabled
176
177 - name: Deny all other requests on 9200
178@@ -36,8 +36,8 @@
179 when: firewall_enabled
180
181 - name: Open the firewall for all peers
182- ufw: rule=allow src={{ lookup('dns', item['private-address']) }} port=9300 proto=tcp
183- with_items: relations["peer"]
184+ ufw: rule=allow src="{{lookup('dig', item.get('address', ''))}}" port=9300 proto=tcp
185+ with_items: "{{relations['peer']}}"
186 when: firewall_enabled
187
188 # Only deny incoming on 9300 once the unit is part of a cluster.
189
190=== modified file 'templates/elasticsearch.yml'
191--- templates/elasticsearch.yml 2017-07-26 03:30:57 +0000
192+++ templates/elasticsearch.yml 2017-09-15 00:48:54 +0000
193@@ -4,9 +4,16 @@
194 cluster.name: {{ cluster_name }}
195 http.port: 9200
196 network.host: ["_site_", "_local_"]
197-{% if (relations.peer is defined) and relations.peer %}
198+{% if not '5' in apt_repository %}
199+discovery.zen.ping.multicast.enabled: false
200+{% endif %}
201+{% if relations.peer is defined and relations.peer|length > 0 %}
202 discovery.zen.ping.unicast.hosts:
203 {% for reln in relations.peer %}
204 - {{ reln['private-address'] }}
205 {% endfor %}
206 {% endif %}
207+{% if not '5' in apt_repository %}
208+# workaround for Kibana4 Export Everything bug https://github.com/elastic/kibana/issues/5524
209+index.max_result_window: 2147483647
210+{% endif %}
211
212=== modified file 'unit_tests/test_hooks.py'
213--- unit_tests/test_hooks.py 2017-03-29 01:20:22 +0000
214+++ unit_tests/test_hooks.py 2017-09-15 00:48:54 +0000
215@@ -56,26 +56,26 @@
216 self.addCleanup(patcher.stop)
217
218 def test_installs_ansible_support(self):
219- hooks.execute(['install'])
220+ hooks.execute(['install.real'])
221
222 ansible = self.mock_ansible
223 ansible.install_ansible_support.assert_called_once_with(
224 from_ppa=False)
225
226 def test_applies_install_playbook(self):
227- hooks.execute(['install'])
228+ hooks.execute(['install.real'])
229
230 self.assertEqual([
231- mock.call('playbook.yaml', tags=['install'], extra_vars=None)
232+ mock.call('playbook.yaml', tags=['install.real'], extra_vars=None)
233 ], self.mock_ansible.apply_playbook.call_args_list)
234
235 def test_executes_preinstall(self):
236- hooks.execute(['install'])
237+ hooks.execute(['install.real'])
238
239 self.mock_preinstall.assert_called_once_with()
240
241 def test_copys_backported_ansible_modules(self):
242- hooks.execute(['install'])
243+ hooks.execute(['install.real'])
244
245 self.mock_rsync.assert_called_once_with(
246 'ansible_module_backports',

Subscribers

People subscribed via source and target branches