Defined Type: python_deploy::venv

Defined in:
modules/python_deploy/manifests/venv.pp

Summary

Deploy Python code in a virtualenv

Overview

SPDX-License-Identifier: Apache-2.0 Deploy the bits needed to be able to deploy Python code in a simple manner, basically mimicking what scap does for the repositories of Python3 software that has frozen wheels and needs to be deployed in a virtualenv. This define was born as a workaround to not be blocked by the migration of Scap to Python 3 and might or might be not used after that.

This define and scap::target are mutually exclusive, including both will results in compilation errors.

Parameters:

  • project_name (String) (defaults to: $title) —

    String The name of the project to deploy. Defaults to the title of the resource.

  • deploy_user (String) (defaults to: "deploy-${title}") —

    String The user that will own the deployment directory. Defaults to "deploy-$title".

  • add_home_dir (Boolean) (defaults to: false) —

    Boolean Whether to create a home directory for the deploy user. Defaults to false.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'modules/python_deploy/manifests/venv.pp', line 16

define python_deploy::venv (
    String $project_name = $title,
    String $deploy_user = "deploy-${title}",
    Boolean $add_home_dir = false,
) {
    include python_deploy
    if $add_home_dir {
        $home_dir = "/var/lib/${deploy_user}"
        wmflib::dir::mkdir_p($home_dir)
        $params = { home_dir => $home_dir }
    } else {
        $params = {}
    }

    ensure_resources('systemd::sysuser', { $deploy_user => $params })

    file { "/srv/deployment/${project_name}":
        ensure => directory,
        owner  => $deploy_user,
        group  => 'root',
        mode   => '0755',
    }
}