~gnuoy/charms/precise/apache2/24-auth-format

« back to all changes in this revision

Viewing changes to hooks/hooks.py

  • Committer: David Ames
  • Date: 2013-01-28 19:10:39 UTC
  • Revision ID: david.ames@canonical.com-20130128191039-z7288yhr7xlsjkcl
Added conf.d/security settings

Show diffs side-by-side

added added

removed removed

Lines of Context:
394
394
        mpm_config.write(str(template))
395
395
 
396
396
 
 
397
def create_security():
 
398
    config_data = config_get()
 
399
    securityfile = '/etc/apache2/conf.d/security'
 
400
    from jinja2 import Environment, FileSystemLoader
 
401
    template_env = Environment(loader=FileSystemLoader(os.path.join(os.environ['CHARM_DIR'], 'data')))
 
402
    templ_vars = {
 
403
        'juju_warning_header': juju_warning_header,
 
404
        'server_tokens': config_data['server_tokens'],
 
405
        'server_signature': config_data['server_signature'],
 
406
        'trace_enabled': config_data['trace_enabled'],
 
407
    }
 
408
    template = \
 
409
        template_env.get_template('security.template').render(templ_vars)
 
410
    with open(securityfile, 'w') as security_config:
 
411
        security_config.write(str(template))
 
412
 
 
413
 
397
414
def ship_logrotate_conf():
398
415
    config_data = config_get()
399
416
    logrotate_file = '/etc/logrotate.d/apache2'
434
451
        apt_get_install('apache2-mpm-prefork')
435
452
        apt_get_purge('apache2-mpm-worker')
436
453
    create_mpm_workerfile()
 
454
    create_security()
437
455
    ports = {'http': 80, 'https': 443}
438
456
    for proto in ports.keys():
439
457
        template_var = 'vhost_%s_template' % (proto)