devpi-service

Example:

# Install the devpi service using the devpi system user (which will be created if necessary).
- devpi-service:
    listen_address: dev.frkl.io
    user: devpi
    admin_password: secret password

Description

This frecklet installs devpi, adds a systed unit file. and runs devpi as a service.

If a backup_archive_file is provided, it will be uploaded to the server, unarchived, and the backed-up state will be imported before the server will be started for the first time. Check the frecklet::devpi-create-backup frecklet for details about creating such a backup archive file. The import will take a minute or two, as it also (re-)creates the pypi mirror index.

If the use_https variable is set, a certificate from LetsEncrypt will be requrested and installed, along with a cron job to automatically renew it before it expires. Nginx will be configured to redirect all http traffic to https.

Resources

Variables

Name Type Default Description

admin_password

string --

If a password is already set, this will fail and the error will be ignored.

backup_archive_file

string --

If this is not provided, a normal, 'empty' devpi instance will be created.

listen_address

string localhost

The listen address of the devpi server.

user

string devpi

The user to run devpi as well as nginx.

Examples

Example 1

Install the devpi service using the devpi system user (which will be created if necessary).

Code
- devpi-service:
    listen_address: dev.frkl.io
    user: devpi
    admin_password: secret password

Example 2

Re-create a devpi service instance from a backup, incl. Nginx reverse proxy and https certificate.

Code
- devpi-service:
    listen_address: dev.frkl.io
    user: devpi
    backup_archive_file: ~/backups/devpi_backup.tar.gz

Code

doc:
  short_help: installs a devpi service.
  help: |
    This frecklet installs devpi, adds a systed unit file. and runs devpi as a service.

    If a ``backup_archive_file`` is provided, it will be uploaded to the server, unarchived, and the backed-up
    state will be imported before the server will be started for the first time. Check the frecklet::devpi-create-backup
    *frecklet* for details about creating such a backup archive file. The import will take a minute or two, as it also
    (re-)creates the pypi mirror index.

    If the ``use_https`` variable is set, a certificate from LetsEncrypt will be requrested and installed, along
    with a cron job to automatically renew it before it expires. Nginx will be
    configured to redirect all http traffic to https.

  references:
    freckfrackery.install-devpi Ansible role: https://gitlab.com/freckfrackery/freckfrackery.install-devpi
  examples:
  - title: Install the devpi service using the devpi system user (which will be created
      if necessary).
    vars:
      listen_address: dev.frkl.io
      user: devpi
      admin_password: secret password
  - title: Re-create a devpi service instance from a backup, incl. Nginx reverse proxy
      and https certificate.
    vars:
      listen_address: dev.frkl.io
      user: devpi
      backup_archive_file: ~/backups/devpi_backup.tar.gz

args:
  listen_address:
    type: string
    default: localhost
    required: false
    doc:
      short_help: The listen address of the devpi server.
  user:
    doc:
      short_help: The user to run devpi as well as nginx.
    type: string
    required: false
    default: devpi
    cli:
      show_default: true
  backup_archive_file:
    doc:
      short_help: A file to restore the service from.
      help: |
        If this is not provided, a normal, 'empty' devpi instance will be created.
    type: string
    required: false
  admin_password:
    type: string
    required: false
    doc:
      short_help: The initial admin password.
      help: |
        If a password is already set, this will fail and the error will be ignored.
#  devpi_virtualenv:
#    doc:
#      short_help: The folder for the devpi virtualenv.
#      help: |
#        Only set that if you know what you are doing.
#    type: string
#    required: false
#  devpi_server_base:
#    doc:
#      short_help: The folder for the devpi server folder.
#      help: |
#        Only set that if you know what you are doing.
#    type: string
#    required: false

meta:
  tags:
  - devpi
  - python
  - repository
  - packages
  - service

frecklets:

- devpi-installed:
    user: '{{:: user ::}}'
    port: 3141
    host: '{{:: listen_address ::}}'
    admin_password: '{{:: admin_password ::}}'
#      devpi_virtualenv: "{{:: devpi_virtualenv ::}}"
#      devpi_server_base: "{{:: devpi_server_base ::}}"
- devpi-import-from-backup:
    frecklet::skip: '{{:: backup_archive_file | true_if_empty ::}}'
    backup_archive_file: '{{:: backup_archive_file ::}}'
#      devpi_server_base: "{{:: devpi_server_base ::}}"
frecklecute devpi-service --help

Usage: frecklecute devpi-service [OPTIONS]

  This frecklet installs devpi, adds a systed unit file. and runs devpi as a
  service.

  If a ``backup_archive_file`` is provided, it will be uploaded to the
  server, unarchived, and the backed-up state will be imported before the
  server will be started for the first time. Check the frecklet::devpi-
  create-backup *frecklet* for details about creating such a backup archive
  file. The import will take a minute or two, as it also (re-)creates the
  pypi mirror index.

  If the ``use_https`` variable is set, a certificate from LetsEncrypt will
  be requrested and installed, along with a cron job to automatically renew
  it before it expires. Nginx will be configured to redirect all http
  traffic to https.

Options:
  --admin-password ADMIN_PASSWORD
                                  The initial admin password.
  --backup-archive-file BACKUP_ARCHIVE_FILE
                                  A file to restore the service from.
  --listen-address LISTEN_ADDRESS
                                  The listen address of the devpi server.
  --user USER                     The user to run devpi as well as nginx.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.devpi_service.DevpiService
#


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

@dataclass
class DevpiService(AutoPycklet):
    """This frecklet installs devpi, adds a systed unit file. and runs devpi as a service.

     If a ``backup_archive_file`` is provided, it will be uploaded to the server, unarchived, and the backed-up
     state will be imported before the server will be started for the first time. Check the frecklet::devpi-create-backup
     *frecklet* for details about creating such a backup archive file. The import will take a minute or two, as it also
     (re-)creates the pypi mirror index.

     If the ``use_https`` variable is set, a certificate from LetsEncrypt will be requrested and installed, along
     with a cron job to automatically renew it before it expires. Nginx will be
     configured to redirect all http traffic to https.

       Args:
         admin_password: The initial admin password.
         backup_archive_file: A file to restore the service from.
         listen_address: The listen address of the devpi server.
         user: The user to run devpi as well as nginx.

    """

    FRECKLET_ID = "devpi-service"

    admin_password: str = None
    backup_archive_file: str = None
    listen_address: str = None
    user: str = None


    def __post_init__(self):
        super(DevpiService, self).__init__(var_names=["admin_password", "backup_archive_file", "listen_address", "user"])


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


#
# module path: pycklets.devpi_service.DevpiService
#


from pyckles import AutoPycklet

class DevpiService(AutoPycklet):
    """This frecklet installs devpi, adds a systed unit file. and runs devpi as a service.

     If a ``backup_archive_file`` is provided, it will be uploaded to the server, unarchived, and the backed-up
     state will be imported before the server will be started for the first time. Check the frecklet::devpi-create-backup
     *frecklet* for details about creating such a backup archive file. The import will take a minute or two, as it also
     (re-)creates the pypi mirror index.

     If the ``use_https`` variable is set, a certificate from LetsEncrypt will be requrested and installed, along
     with a cron job to automatically renew it before it expires. Nginx will be
     configured to redirect all http traffic to https.

       Args:
         admin_password: The initial admin password.
         backup_archive_file: A file to restore the service from.
         listen_address: The listen address of the devpi server.
         user: The user to run devpi as well as nginx.

    """

    FRECKLET_ID = "devpi-service"

    def __init__(self, admin_password=None, backup_archive_file=None, listen_address="localhost", user="devpi"):

        super(DevpiService, self).__init__(var_names=["admin_password", "backup_archive_file", "listen_address", "user"])
        self._admin_password = admin_password
        self._backup_archive_file = backup_archive_file
        self._listen_address = listen_address
        self._user = user

    @property
    def admin_password(self):
        return self._admin_password

    @admin_password.setter
    def admin_password(self, admin_password):
        self._admin_password = admin_password

    @property
    def backup_archive_file(self):
        return self._backup_archive_file

    @backup_archive_file.setter
    def backup_archive_file(self, backup_archive_file):
        self._backup_archive_file = backup_archive_file

    @property
    def listen_address(self):
        return self._listen_address

    @listen_address.setter
    def listen_address(self, listen_address):
        self._listen_address = listen_address

    @property
    def user(self):
        return self._user

    @user.setter
    def user(self, user):
        self._user = user



frecklet_class = DevpiService