Add bootstrap_rattail_base()
and related tweaks
the idea here is to have a "one stop shop" for base requirements, we'll see how useful it is in practice i guess
This commit is contained in:
parent
506b88d3e2
commit
1fd9ad48d6
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -34,7 +34,7 @@ def install(c):
|
||||||
"""
|
"""
|
||||||
Install the PostgreSQL database service
|
Install the PostgreSQL database service
|
||||||
"""
|
"""
|
||||||
apt.install(c, 'postgresql')
|
apt.install(c, 'postgresql', 'libpq-dev')
|
||||||
|
|
||||||
|
|
||||||
def get_version(c):
|
def get_version(c):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -29,16 +29,19 @@ from contextlib import contextmanager
|
||||||
from rattail_fabric2 import apt, append, exists, make_deploy, mkdir
|
from rattail_fabric2 import apt, append, exists, make_deploy, mkdir
|
||||||
|
|
||||||
|
|
||||||
deploy = make_deploy(__file__)
|
deploy_common = make_deploy(__file__)
|
||||||
|
|
||||||
|
|
||||||
def bootstrap_python(c, pip_from_apt=True, pip_eager=True,
|
def bootstrap_python(c, deploy=None,
|
||||||
|
pip_from_apt=True,
|
||||||
|
pip_eager=True,
|
||||||
pip_method=None,
|
pip_method=None,
|
||||||
pip_auto=False,
|
pip_auto=False,
|
||||||
pip_package_name=None,
|
pip_package_name=None,
|
||||||
virtualenvwrapper_from_apt=False,
|
virtualenvwrapper_from_apt=False,
|
||||||
upgrade_virtualenvwrapper=True,
|
upgrade_virtualenvwrapper=True,
|
||||||
workon_home='/srv/envs', user='rattail',
|
workon_home='/srv/envs',
|
||||||
|
user='rattail',
|
||||||
python3=False):
|
python3=False):
|
||||||
"""
|
"""
|
||||||
Bootstrap a "complete" Python install.
|
Bootstrap a "complete" Python install.
|
||||||
|
@ -67,7 +70,8 @@ def bootstrap_python(c, pip_from_apt=True, pip_eager=True,
|
||||||
use_apt=virtualenvwrapper_from_apt,
|
use_apt=virtualenvwrapper_from_apt,
|
||||||
upgrade=upgrade_virtualenvwrapper,
|
upgrade=upgrade_virtualenvwrapper,
|
||||||
configure_me=False)
|
configure_me=False)
|
||||||
deploy(c, 'python/premkvirtualenv', '{}/premkvirtualenv'.format(workon_home), owner=user, use_sudo=True)
|
# TODO: let custom deploy override this
|
||||||
|
deploy_common(c, 'python/premkvirtualenv', '{}/premkvirtualenv'.format(workon_home), owner=user, use_sudo=True)
|
||||||
|
|
||||||
|
|
||||||
def install_pythonz(c):
|
def install_pythonz(c):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -28,28 +28,69 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from rattail_fabric2 import postgresql, make_deploy, make_system_user, mkdir
|
from rattail_fabric2 import apache, apt, postfix, postgresql, python, make_deploy, make_system_user, mkdir
|
||||||
|
|
||||||
|
|
||||||
deploy = make_deploy(__file__)
|
deploy_common = make_deploy(__file__)
|
||||||
|
|
||||||
|
|
||||||
def bootstrap_rattail(c, home='/var/lib/rattail', uid=None, shell='/bin/bash'):
|
def bootstrap_rattail_base(c, deploy=None, timezone='America/Chicago',
|
||||||
|
**context):
|
||||||
|
"""
|
||||||
|
Bootstrap the base system requirements, common to all machines
|
||||||
|
running Rattail apps. Note that this includes basic installation
|
||||||
|
of Python, PostgreSQL and Aapche.
|
||||||
|
"""
|
||||||
|
env = context.get('env')
|
||||||
|
context['timezone'] = timezone
|
||||||
|
|
||||||
|
# make system user, install init scripts etc.
|
||||||
|
bootstrap_rattail(c, alias='root')
|
||||||
|
|
||||||
|
# machine-wide config
|
||||||
|
if deploy and deploy.local_exists('rattail/rattail.conf.mako'):
|
||||||
|
deploy(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf',
|
||||||
|
use_sudo=True, context=context)
|
||||||
|
else:
|
||||||
|
deploy_machine_conf(c, timezone=timezone)
|
||||||
|
|
||||||
|
# python
|
||||||
|
python.bootstrap_python(c, deploy,
|
||||||
|
python3=True,
|
||||||
|
virtualenvwrapper_from_apt=True)
|
||||||
|
|
||||||
|
# postgres
|
||||||
|
postgresql.install(c)
|
||||||
|
if env and hasattr(env, 'password_postgresql_rattail'):
|
||||||
|
postgresql.create_user(c, 'rattail', password=env.password_postgresql_rattail)
|
||||||
|
|
||||||
|
# apache
|
||||||
|
apache.install(c)
|
||||||
|
apache.enable_mod(c, 'proxy_http')
|
||||||
|
|
||||||
|
# supervisor
|
||||||
|
apt.install(c, 'supervisor')
|
||||||
|
|
||||||
|
|
||||||
|
def bootstrap_rattail(c, home='/var/lib/rattail', uid=None, shell='/bin/bash',
|
||||||
|
alias=None):
|
||||||
"""
|
"""
|
||||||
Bootstrap a basic Rattail software environment.
|
Bootstrap a basic Rattail software environment.
|
||||||
"""
|
"""
|
||||||
make_system_user(c, 'rattail', home=home, uid=uid, shell=shell)
|
make_system_user(c, 'rattail', home=home, uid=uid, shell=shell)
|
||||||
mkdir(c, os.path.join(home, '.ssh'), owner='rattail:', mode='0700', use_sudo=True)
|
mkdir(c, os.path.join(home, '.ssh'), owner='rattail:', mode='0700', use_sudo=True)
|
||||||
|
if alias:
|
||||||
|
postfix.alias(c, 'rattail', alias)
|
||||||
|
|
||||||
mkdir(c, '/etc/rattail', use_sudo=True)
|
mkdir(c, '/etc/rattail', use_sudo=True)
|
||||||
mkdir(c, '/srv/rattail', use_sudo=True)
|
mkdir(c, '/srv/rattail', use_sudo=True)
|
||||||
mkdir(c, '/var/log/rattail', owner='rattail:rattail', mode='0775', use_sudo=True)
|
mkdir(c, '/var/log/rattail', owner='rattail:rattail', mode='0775', use_sudo=True)
|
||||||
|
|
||||||
mkdir(c, '/srv/rattail/init', use_sudo=True)
|
mkdir(c, '/srv/rattail/init', use_sudo=True)
|
||||||
deploy(c, 'check-rattail-daemon', '/usr/local/bin/check-rattail-daemon', use_sudo=True)
|
deploy_common(c, 'check-rattail-daemon', '/usr/local/bin/check-rattail-daemon', use_sudo=True)
|
||||||
deploy(c, 'check-supervisor-process', '/usr/local/bin/check-supervisor-process', use_sudo=True)
|
deploy_common(c, 'check-supervisor-process', '/usr/local/bin/check-supervisor-process', use_sudo=True)
|
||||||
deploy(c, 'check-systemd-service', '/usr/local/bin/check-systemd-service', use_sudo=True)
|
deploy_common(c, 'check-systemd-service', '/usr/local/bin/check-systemd-service', use_sudo=True)
|
||||||
deploy(c, 'soffice', '/srv/rattail/init/soffice', use_sudo=True)
|
deploy_common(c, 'soffice', '/srv/rattail/init/soffice', use_sudo=True)
|
||||||
|
|
||||||
|
|
||||||
def deploy_machine_conf(c, timezone='America/Chicago'):
|
def deploy_machine_conf(c, timezone='America/Chicago'):
|
||||||
|
@ -57,8 +98,8 @@ def deploy_machine_conf(c, timezone='America/Chicago'):
|
||||||
Deploy the standard machine-wide ``rattail.conf`` file.
|
Deploy the standard machine-wide ``rattail.conf`` file.
|
||||||
"""
|
"""
|
||||||
mkdir(c, '/etc/rattail', use_sudo=True)
|
mkdir(c, '/etc/rattail', use_sudo=True)
|
||||||
deploy(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf', use_sudo=True,
|
deploy_common(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf', use_sudo=True,
|
||||||
context={'timezone': timezone})
|
context={'timezone': timezone})
|
||||||
|
|
||||||
|
|
||||||
def delete_email_recipients(c, dbname):
|
def delete_email_recipients(c, dbname):
|
||||||
|
@ -84,7 +125,7 @@ def deploy_datasync_checks(c, envroot, **kwargs):
|
||||||
envroot = envroot.rstrip('/')
|
envroot = envroot.rstrip('/')
|
||||||
context = kwargs.pop('context', {})
|
context = kwargs.pop('context', {})
|
||||||
context['envroot'] = envroot
|
context['envroot'] = envroot
|
||||||
deploy(c, 'rattail/check-datasync-queue.mako', '{}/app/check-datasync-queue'.format(envroot),
|
deploy_common(c, 'rattail/check-datasync-queue.mako', '{}/app/check-datasync-queue'.format(envroot),
|
||||||
context=context, **kwargs)
|
context=context, **kwargs)
|
||||||
deploy(c, 'rattail/check-datasync-watchers.mako', '{}/app/check-datasync-watchers'.format(envroot),
|
deploy_common(c, 'rattail/check-datasync-watchers.mako', '{}/app/check-datasync-watchers'.format(envroot),
|
||||||
context=context, **kwargs)
|
context=context, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue