Merge lp:~jjo/charms/precise/apache2/support-apache24-sites-conf-files into lp:charms/apache2

Proposed by JuanJo Ciarlante on 2014-01-20
Status: Merged
Merged at revision: 53
Proposed branch: lp:~jjo/charms/precise/apache2/support-apache24-sites-conf-files
Merge into: lp:charms/apache2
Diff against target: 67 lines (+19/-5)
1 file modified
hooks/hooks.py (+19/-5)
To merge this branch: bzr merge lp:~jjo/charms/precise/apache2/support-apache24-sites-conf-files
Reviewer Review Type Date Requested Status
Marco Ceppi 2014-01-20 Approve on 2014-02-08
Review via email: mp+202340@code.launchpad.net

Commit message

[jjo] support apache 2.4 site setup
- 2.4 requires sites-available/foo.conf filenames
- cleanup a couple bits

To post a comment you must log in.
JuanJo Ciarlante (jjo) wrote :

FYI merged from canonical-is repository - passes CID testing for precise, trusty.

Charles Butler (lazypower) wrote :

Greetings JuanJo,

I've reviewed these changes and they look good to me. I've pulled the source and deployed the charm with your patches, everything passes my initial testing.

+1 vote on this MP

Another charmer should be by shortly to perform another review, and put you that much closer to having this patch accepted into the charm store.

Thanks for the patch!

Marco Ceppi (marcoceppi) wrote :

LGTM, thanks!

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 2014-01-16 12:33:28 +0000
3+++ hooks/hooks.py 2014-01-20 16:44:14 +0000
4@@ -26,7 +26,6 @@
5 # Global variables
6 ###############################################################################
7 default_apache2_service_config_dir = "/var/run/apache2"
8-test_apache2_vhost = "/etc/apache2/sites-available/testvhost"
9 service_affecting_packages = ['apache2']
10 default_apache22_config_dir = "/etc/apache2/conf.d"
11 default_apache24_config_dir = "/etc/apache2/conf-available"
12@@ -139,12 +138,23 @@
13 return os.path.exists("/usr/sbin/a2enconf")
14
15
16+def site_filename(name, enabled=False):
17+ if enabled:
18+ sites_dir = "/etc/apache2/sites-enabled"
19+ else:
20+ sites_dir = "/etc/apache2/sites-available"
21+
22+ if is_apache24():
23+ return "{}/{}.conf".format(sites_dir, name)
24+ else:
25+ return "{}/{}".format(sites_dir, name)
26+
27+
28 def conf_filename(name):
29 """Return an apache2 config filename path, as:
30 2.4: /etc/apache2/conf-available/foo.conf
31 2.2: /etc/apache2/conf.d/foo
32 """
33- # Check for conf.d presence (instead of parsing apache2ctl -V, etc)
34 if is_apache24():
35 return "{}/{}.conf".format(default_apache24_config_dir, name)
36 else:
37@@ -402,7 +412,11 @@
38
39 relationship_data.update(get_reverseproxy_data(relation='reverseproxy'))
40 relationship_data.update(get_reverseproxy_data(relation='website-cache'))
41- update_balancers()
42+ if update_balancers():
43+ # apache 2.4 has lbmethods split, needs to enable specific module(s)
44+ if is_apache24():
45+ enable_module('lbmethod_byrequests')
46+
47 if config_data['enable_modules']:
48 module_list = config_data['enable_modules'].split()
49 for module in module_list:
50@@ -428,7 +442,7 @@
51 close_port(ports[proto])
52 if template_var in config_data:
53 vhost_name = '%s_%s' % (config_data['servername'], proto)
54- vhost_file = '/etc/apache2/sites-available/%s' % (vhost_name)
55+ vhost_file = site_filename(vhost_name)
56 from jinja2 import Template
57 template = Template(
58 str(base64.b64decode(config_data[template_var])))
59@@ -539,7 +553,7 @@
60 # Disable the default website because we don't want people to see the
61 # "It works!" page on production services and remove the
62 # conf.d/other-vhosts-access-log conf.
63- if os.path.exists("/etc/apache2/sites-enabled/000-default"):
64+ if os.path.exists(site_filename("000-default", True)):
65 run(["/usr/sbin/a2dissite", "000-default"])
66 conf_disable("other-vhosts-access-log")
67 if os.path.exists(conf_filename("other-vhosts-access-log")):

Subscribers

People subscribed via source and target branches