def site(site_name, template_contents=None, template_source=None, enabled=True, check_config=True, **kwargs):
    """
    Require an Apache site.

    You must provide a template for the site configuration, either as a
    string (*template_contents*) or as the path to a local template
    file (*template_source*).

    ::

        from fabtools import require

        CONFIG_TPL = '''
        <VirtualHost *:%(port)s>
            ServerName %(hostname})s

            DocumentRoot %(document_root)s

            <Directory %(document_root)s>
                Options Indexes FollowSymLinks MultiViews

                AllowOverride All

                Order allow,deny
                allow from all
            </Directory>
        </VirtualHost>
        '''

        require.apache.site(
            'example.com',
            template_contents=CONFIG_TPL,
            port=80,
            hostname='www.example.com',
            document_root='/var/www/mysite',
        )

    .. seealso:: :py:func:`fabtools.require.files.template_file`
    """
    server()

    config_path = _site_config_path(site_name)

    context = {
        'port': 80,
    }
    context.update(kwargs)
    context['config_name'] = site_name

    template_file(config_path, template_contents, template_source, context, use_sudo=True)

    if enabled:
        enable_site(site_name)
    else:
        disable_site(site_name)

    if check_config:
        with settings(hide('running', 'warnings'), warn_only=True):
            if run_as_root('apache2ctl configtest').failed:
                disable_site(site_name)
                message = red(locals() % "Error in %(site_name)s apache site config (disabling for safety)")
                abort(message)

    reload_service('apache2')


# backward compatibility (deprecated)
dataset/ETHPy150Open ronnix/fabtools/fabtools/require/apache.py/site/swapped operands of `%`