diff --git a/rattail_fabric2/apache.py b/rattail_fabric2/apache.py index 1d6073b..95cc259 100644 --- a/rattail_fabric2/apache.py +++ b/rattail_fabric2/apache.py @@ -92,6 +92,27 @@ def deploy_site(c, deployer, local_path, name, enable=False, **kwargs): 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): """ Restart the Apache web service diff --git a/rattail_fabric2/core.py b/rattail_fabric2/core.py index cd98a1f..bcfb895 100644 --- a/rattail_fabric2/core.py +++ b/rattail_fabric2/core.py @@ -210,6 +210,11 @@ class Deployer(object): kwargs['use_sudo'] = True 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): from rattail_fabric2.backup import deploy_backup_app deploy_backup_app(c, self, envname, *args, **kwargs)