~canonical-sysadmins/charm-elasticsearch/elasticsearch

« back to all changes in this revision

Viewing changes to hooks/hooks.py

  • Committer: Thomas Cuthbert
  • Date: 2018-01-24 05:24:55 UTC
  • mfrom: (59.1.3 elasticsearch-charm)
  • Revision ID: thomas.cuthbert@canonical.com-20180124052455-nzpf19deqel0cuf8
[jamesbeedy,r=tcuthbert] update template to render correctly compatible for all elasticsearch

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
from charmhelpers.core import hookenv
9
9
import os
10
10
import shutil
11
 
import subprocess as sp
12
11
 
13
12
mountpoint = '/srv/elasticsearch'
14
 
config = hookenv.config()
15
13
 
16
14
hooks = charmhelpers.contrib.ansible.AnsibleHooks(
17
15
    playbook_path='playbook.yaml',
36
34
    ])
37
35
 
38
36
 
39
 
@hooks.hook('install', 'upgrade-charm')
40
 
def install():
 
37
@hooks.hook('install.real', 'upgrade-charm')
 
38
def install_real():
41
39
    """Install ansible before running the tasks tagged with 'install'."""
42
40
    # Allow charm users to run preinstall setup.
43
 
    if is_container:
44
 
        config["env-vars"] = {"ES_SKIP_SET_KERNEL_PARAMETERS": "true"}
45
 
    else:
46
 
        config["env-vars"] = {}
47
41
    charmhelpers.payload.execd.execd_preinstall()
48
42
    charmhelpers.contrib.ansible.install_ansible_support(
49
43
        from_ppa=False)
103
97
    charmhelpers.core.host.service_start('elasticsearch')
104
98
 
105
99
 
106
 
def is_container():
107
 
    """Return True if system is running inside a container"""
108
 
    virt_type = sp.check_output('systemd-detect-virt').decode().strip()
109
 
    if virt_type == 'lxc':
110
 
        return True
111
 
    else:
112
 
        return False
113
 
 
114
 
 
115
100
if __name__ == "__main__":
116
101
    hooks.execute(sys.argv)