Add functions to deploy, enable apache config files

This commit is contained in:
Lance Edgar 2019-02-16 18:21:40 -06:00
parent 05d6e093a7
commit bc4a8a686e
2 changed files with 26 additions and 0 deletions

View file

@ -92,6 +92,27 @@ def deploy_site(c, deployer, local_path, name, enable=False, **kwargs):
enable_site(c, name) enable_site(c, name)
def deploy_conf(c, deployer, local_path, name, enable=False, **kwargs):
"""
Deploy a config snippet file to Apache
"""
apache_version = get_version(c)
if apache_version == 2.2:
deployer(c, local_path, '/etc/apache2/conf.d/{}.conf'.format(name), **kwargs)
else:
deployer(c, local_path, '/etc/apache2/conf-available/{}.conf'.format(name), **kwargs)
if enable:
enable_conf(c, name)
def enable_conf(c, *names):
"""
Enable the given Apache configurations
"""
for name in names:
c.sudo('a2enconf {}'.format(name))
def restart(c): def restart(c):
""" """
Restart the Apache web service Restart the Apache web service

View file

@ -210,6 +210,11 @@ class Deployer(object):
kwargs['use_sudo'] = True kwargs['use_sudo'] = True
deploy_site(c, self, local_path, name, **kwargs) deploy_site(c, self, local_path, name, **kwargs)
def apache_conf(self, c, local_path, name, **kwargs):
from rattail_fabric2.apache import deploy_conf
kwargs['use_sudo'] = True
deploy_conf(c, self, local_path, name, **kwargs)
def backup_app(self, c, envname='backup', *args, **kwargs): def backup_app(self, c, envname='backup', *args, **kwargs):
from rattail_fabric2.backup import deploy_backup_app from rattail_fabric2.backup import deploy_backup_app
deploy_backup_app(c, self, envname, *args, **kwargs) deploy_backup_app(c, self, envname, *args, **kwargs)