apache-vhost-from-folder

Description

TODO: documentation, examples

Variables

Name Type Default Description

document_root

string /var/www/html

The document root.

hostname

string localhost

The domain name the webserver should listen on.

index

list ['index.html', 'index.htm']

The index file name(s).

server_admin

string --

The server admin email.

use_https

boolean False

Whether to use https (and request a letsencrypt certificate).

Code

doc:
  short_help: Configure an Apache vhost for static site.
  help: |
    TODO: documentation, examples

args:
  hostname:
    doc:
      short_help: The domain name the webserver should listen on.
    type: string
    required: false
    default: localhost
  use_https:
    doc:
      short_help: Whether to use https (and request a letsencrypt certificate).
    type: boolean
    required: false
    default: false
  document_root:
    doc:
      short_help: The document root.
    type: string
    required: false
    default: /var/www/html
  index:
    doc:
      short_help: The index file name(s).
    type: list
    schema:
      type: string
    default:
    - index.html
    - index.htm
    required: false
    cli:
      metavar: FILENAME
      show_default: true
  server_admin:
    doc:
      short_help: The server admin email.
    type: string
    required: false
    cli:
      metavar: EMAIL
frecklets:
- apache-vhost-file:
    path: "/etc/apache2/sites-enabled/{{:: hostname ::}}.{{:: 'https' if use_https\
      \ else 'http' ::}}.conf"
    owner: root
    document_root: '{{:: document_root ::}}'
    server_name: '{{:: hostname ::}}'
    use_https: '{{:: use_https ::}}'
##      listen_ip: "{{:: listen_ip ::}}"
    server_admin: '{{:: server_admin ::}}'
    folder_directives:
    - directive_type: Directory
      path: '{{:: document_root ::}}'
      DirectoryIndex: "{{:: index | join(' ') ::}}"
#  - init-service-reloaded:
#      name: apache # could be apache, apache2 or httpd
frecklecute apache-vhost-from-folder --help

Usage: frecklecute apache-vhost-from-folder [OPTIONS]

  TODO: documentation, examples

Options:
  --document-root DOCUMENT_ROOT  The document root.
  --hostname HOSTNAME            The domain name the webserver should listen
                                 on.
  --index FILENAME               The index file name(s).
  --server-admin EMAIL           The server admin email.
  --use-https / --no-use-https   Whether to use https (and request a
                                 letsencrypt certificate).
  --help                         Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.apache_vhost_from_folder.ApacheVhostFromFolder
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class ApacheVhostFromFolder(AutoPycklet):
    """TODO: documentation, examples

       Args:
         document_root: The document root.
         hostname: The domain name the webserver should listen on.
         index: The index file name(s).
         server_admin: The server admin email.
         use_https: Whether to use https (and request a letsencrypt certificate).

    """

    FRECKLET_ID = "apache-vhost-from-folder"

    document_root: str = None
    hostname: str = None
    index: List = None
    server_admin: str = None
    use_https: bool = None


    def __post_init__(self):
        super(ApacheVhostFromFolder, self).__init__(var_names=["document_root", "hostname", "index", "server_admin", "use_https"])


frecklet_class = ApacheVhostFromFolder
# -*- coding: utf-8 -*-


#
# module path: pycklets.apache_vhost_from_folder.ApacheVhostFromFolder
#


from pyckles import AutoPycklet

class ApacheVhostFromFolder(AutoPycklet):
    """TODO: documentation, examples

       Args:
         document_root: The document root.
         hostname: The domain name the webserver should listen on.
         index: The index file name(s).
         server_admin: The server admin email.
         use_https: Whether to use https (and request a letsencrypt certificate).

    """

    FRECKLET_ID = "apache-vhost-from-folder"

    def __init__(self, document_root="/var/www/html", hostname="localhost", index=['index.html', 'index.htm'], server_admin=None, use_https=None):

        super(ApacheVhostFromFolder, self).__init__(var_names=["document_root", "hostname", "index", "server_admin", "use_https"])
        self._document_root = document_root
        self._hostname = hostname
        self._index = index
        self._server_admin = server_admin
        self._use_https = use_https

    @property
    def document_root(self):
        return self._document_root

    @document_root.setter
    def document_root(self, document_root):
        self._document_root = document_root

    @property
    def hostname(self):
        return self._hostname

    @hostname.setter
    def hostname(self, hostname):
        self._hostname = hostname

    @property
    def index(self):
        return self._index

    @index.setter
    def index(self, index):
        self._index = index

    @property
    def server_admin(self):
        return self._server_admin

    @server_admin.setter
    def server_admin(self, server_admin):
        self._server_admin = server_admin

    @property
    def use_https(self):
        return self._use_https

    @use_https.setter
    def use_https(self, use_https):
        self._use_https = use_https



frecklet_class = ApacheVhostFromFolder