Add deploy.apache_conf() for fablib

This commit is contained in:
Lance Edgar 2016-10-19 16:53:13 -05:00
parent e83f87afdc
commit d48e145a91
2 changed files with 30 additions and 13 deletions

View file

@ -64,19 +64,6 @@ def install_wsgi(python_home=None):
enable_conf('wsgi') enable_conf('wsgi')
def deploy_site(deployer, local_path, name, enable=False):
"""
Deploy a file to Apache sites-available
"""
if get_apache_version() == 2.2:
path = '/etc/apache2/sites-available/{}'.format(name)
else:
path = '/etc/apache2/sites-available/{}.conf'.format(name)
deployer(local_path, path)
if enable:
enable_site(name)
def enable_conf(*names): def enable_conf(*names):
""" """
Enable the given Apache configurations Enable the given Apache configurations
@ -101,6 +88,32 @@ def enable_site(*names):
sudo('a2ensite {}'.format(name)) sudo('a2ensite {}'.format(name))
def deploy_conf(deployer, local_path, name, enable=False):
"""
Deploy a config snippet file to Apache
"""
version = get_apache_version()
if version == 2.2:
deployer(local_path, '/etc/apache2/conf.d/{}.conf'.format(name))
else:
deployer(local_path, '/etc/apache2/conf-available/{}.conf'.format(name))
if enable:
enable_conf(name)
def deploy_site(deployer, local_path, name, enable=False):
"""
Deploy a file to Apache sites-available
"""
if get_apache_version() == 2.2:
path = '/etc/apache2/sites-available/{}'.format(name)
else:
path = '/etc/apache2/sites-available/{}.conf'.format(name)
deployer(local_path, path)
if enable:
enable_site(name)
def restart(): def restart():
""" """
Restart the Apache web service Restart the Apache web service

View file

@ -168,6 +168,10 @@ class Deployer(object):
from rattail.fablib.apache import deploy_site from rattail.fablib.apache import deploy_site
deploy_site(self, local_path, name, **kwargs) deploy_site(self, local_path, name, **kwargs)
def apache_conf(self, local_path, name, **kwargs):
from rattail.fablib.apache import deploy_conf
deploy_conf(self, local_path, name, **kwargs)
def certbot_account(self, uuid, localdir='certbot/account'): def certbot_account(self, uuid, localdir='certbot/account'):
""" """
Deploy files to establish a certbot account on target server Deploy files to establish a certbot account on target server