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

Proposed by JuanJo Ciarlante
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 (community) Approve
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.
Revision history for this message
JuanJo Ciarlante (jjo) wrote :

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

Revision history for this message
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!

Revision history for this message
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
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-01-16 12:33:28 +0000
+++ hooks/hooks.py 2014-01-20 16:44:14 +0000
@@ -26,7 +26,6 @@
26# Global variables26# Global variables
27###############################################################################27###############################################################################
28default_apache2_service_config_dir = "/var/run/apache2"28default_apache2_service_config_dir = "/var/run/apache2"
29test_apache2_vhost = "/etc/apache2/sites-available/testvhost"
30service_affecting_packages = ['apache2']29service_affecting_packages = ['apache2']
31default_apache22_config_dir = "/etc/apache2/conf.d"30default_apache22_config_dir = "/etc/apache2/conf.d"
32default_apache24_config_dir = "/etc/apache2/conf-available"31default_apache24_config_dir = "/etc/apache2/conf-available"
@@ -139,12 +138,23 @@
139 return os.path.exists("/usr/sbin/a2enconf")138 return os.path.exists("/usr/sbin/a2enconf")
140139
141140
141def site_filename(name, enabled=False):
142 if enabled:
143 sites_dir = "/etc/apache2/sites-enabled"
144 else:
145 sites_dir = "/etc/apache2/sites-available"
146
147 if is_apache24():
148 return "{}/{}.conf".format(sites_dir, name)
149 else:
150 return "{}/{}".format(sites_dir, name)
151
152
142def conf_filename(name):153def conf_filename(name):
143 """Return an apache2 config filename path, as:154 """Return an apache2 config filename path, as:
144 2.4: /etc/apache2/conf-available/foo.conf155 2.4: /etc/apache2/conf-available/foo.conf
145 2.2: /etc/apache2/conf.d/foo156 2.2: /etc/apache2/conf.d/foo
146 """157 """
147 # Check for conf.d presence (instead of parsing apache2ctl -V, etc)
148 if is_apache24():158 if is_apache24():
149 return "{}/{}.conf".format(default_apache24_config_dir, name)159 return "{}/{}.conf".format(default_apache24_config_dir, name)
150 else:160 else:
@@ -402,7 +412,11 @@
402412
403 relationship_data.update(get_reverseproxy_data(relation='reverseproxy'))413 relationship_data.update(get_reverseproxy_data(relation='reverseproxy'))
404 relationship_data.update(get_reverseproxy_data(relation='website-cache'))414 relationship_data.update(get_reverseproxy_data(relation='website-cache'))
405 update_balancers()415 if update_balancers():
416 # apache 2.4 has lbmethods split, needs to enable specific module(s)
417 if is_apache24():
418 enable_module('lbmethod_byrequests')
419
406 if config_data['enable_modules']:420 if config_data['enable_modules']:
407 module_list = config_data['enable_modules'].split()421 module_list = config_data['enable_modules'].split()
408 for module in module_list:422 for module in module_list:
@@ -428,7 +442,7 @@
428 close_port(ports[proto])442 close_port(ports[proto])
429 if template_var in config_data:443 if template_var in config_data:
430 vhost_name = '%s_%s' % (config_data['servername'], proto)444 vhost_name = '%s_%s' % (config_data['servername'], proto)
431 vhost_file = '/etc/apache2/sites-available/%s' % (vhost_name)445 vhost_file = site_filename(vhost_name)
432 from jinja2 import Template446 from jinja2 import Template
433 template = Template(447 template = Template(
434 str(base64.b64decode(config_data[template_var])))448 str(base64.b64decode(config_data[template_var])))
@@ -539,7 +553,7 @@
539 # Disable the default website because we don't want people to see the553 # Disable the default website because we don't want people to see the
540 # "It works!" page on production services and remove the554 # "It works!" page on production services and remove the
541 # conf.d/other-vhosts-access-log conf.555 # conf.d/other-vhosts-access-log conf.
542 if os.path.exists("/etc/apache2/sites-enabled/000-default"):556 if os.path.exists(site_filename("000-default", True)):
543 run(["/usr/sbin/a2dissite", "000-default"])557 run(["/usr/sbin/a2dissite", "000-default"])
544 conf_disable("other-vhosts-access-log")558 conf_disable("other-vhosts-access-log")
545 if os.path.exists(conf_filename("other-vhosts-access-log")):559 if os.path.exists(conf_filename("other-vhosts-access-log")):

Subscribers

People subscribed via source and target branches