Puppet Class: python

Inherits:
python::params
Defined in:
manifests/init.pp

Summary

Installs and manages python, python-dev and gunicorn.

Overview

Examples:

install python from system python

class { 'python':
  version    => 'system',
  pip        => 'present',
  dev        => 'present',
  gunicorn   => 'present',
}

install python3 from scl repo

class { 'python' :
  ensure      => 'present',
  version     => 'rh-python36-python',
  dev         => 'present',
}

Parameters:

  • ensure (Python::Package::Ensure) (defaults to: 'present')

    Desired installation state for the Python package.

  • version (Python::Version) (defaults to: $facts['os']['family'] ? { 'Archlinux' => 'system', default => '3')

    Python version to install. Beware that valid values for this differ a) by the provider you choose and b) by the osfamily/operatingsystem you are using. Allowed values:

    - provider == pip: everything pip allows as a version after the 'python=='
    - else: 'system', 'pypy', 3/3.3/...
       - Be aware that 'system' usually means python 2.X.
       - 'pypy' actually lets us use pypy as python.
       - 3/3.3/... means you are going to install the python3/python3.3/...
         package, if available on your osfamily.
    
  • pip (Python::Package::Ensure) (defaults to: 'present')

    Desired installation state for the python-pip package.

  • dev (Python::Package::Ensure) (defaults to: 'absent')

    Desired installation state for the python-dev package.

  • gunicorn (Python::Package::Ensure) (defaults to: 'absent')

    Desired installation state for Gunicorn.

  • manage_gunicorn (Boolean) (defaults to: true)

    Allow Installation / Removal of Gunicorn.

  • provider (Optional[Python::Provider]) (defaults to: undef)

    What provider to use for installation of the packages, except gunicorn and Python itself.

  • use_epel (Boolean) (defaults to: $python::params::use_epel)

    to determine if the epel class is used.

  • manage_scl (Boolean) (defaults to: true)

    Whether to manage core SCL packages or not.

  • umask (Optional[Python::Umask]) (defaults to: undef)

    The default umask for invoked exec calls.

  • manage_gunicorn (defaults to: true)

    manage the state for package gunicorn

  • manage_python_package (Boolean) (defaults to: true)

    manage the state for package python

  • manage_dev_package (Boolean) (defaults to: true)

    manage the state of the python development package

  • manage_venv_package (Boolean) (defaults to: $python::params::manage_venv_package)

    manage the state for package venv

  • manage_pip_package (Boolean) (defaults to: $python::params::manage_pip_package)

    manage the state for package pip

  • venv (Python::Package::Ensure) (defaults to: 'absent')
  • gunicorn_package_name (String[1]) (defaults to: $python::params::gunicorn_package_name)
  • python_pips (Hash) (defaults to: {})
  • python_pyvenvs (Hash) (defaults to: {})
  • python_requirements (Hash) (defaults to: {})
  • python_dotfiles (Hash) (defaults to: {})
  • rhscl_use_public_repository (Boolean) (defaults to: true)
  • anaconda_installer_url (Stdlib::Httpurl) (defaults to: 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh')
  • anaconda_install_path (Stdlib::Absolutepath) (defaults to: '/opt/python')


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'manifests/init.pp', line 40

class python (
  Python::Package::Ensure    $ensure                      = 'present',
  Python::Version            $version                     = $facts['os']['family'] ? { 'Archlinux' => 'system', default => '3' },
  Python::Package::Ensure    $pip                         = 'present',
  Python::Package::Ensure    $dev                         = 'absent',
  Python::Package::Ensure    $venv                        = 'absent',
  Python::Package::Ensure    $gunicorn                    = 'absent',
  Boolean                    $manage_gunicorn             = true,
  Boolean                    $manage_python_package       = true,
  Boolean                    $manage_dev_package          = true,
  Boolean                    $manage_venv_package         = $python::params::manage_venv_package,
  Boolean                    $manage_pip_package          = $python::params::manage_pip_package,
  String[1]                  $gunicorn_package_name       = $python::params::gunicorn_package_name,
  Optional[Python::Provider] $provider                    = undef,
  Hash                       $python_pips                 = {},
  Hash                       $python_pyvenvs              = {},
  Hash                       $python_requirements         = {},
  Hash                       $python_dotfiles             = {},
  Boolean                    $use_epel                    = $python::params::use_epel,
  Boolean                    $rhscl_use_public_repository = true,
  Stdlib::Httpurl            $anaconda_installer_url      = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh',
  Stdlib::Absolutepath       $anaconda_install_path       = '/opt/python',
  Boolean                    $manage_scl                  = true,
  Optional[Python::Umask]    $umask                       = undef,
) inherits python::params {
  $exec_prefix = $provider ? {
    'scl'   => "/usr/bin/scl enable ${version} -- ",
    'rhscl' => "/usr/bin/scl enable ${version} -- ",
    default => '',
  }

  contain python::install
  contain python::config

  Class['python::install']
  -> Class['python::config']

  # Set default umask.
  exec { default:
    umask => $umask,
  }

  # Allow hiera configuration of python resources
  create_resources('python::pip', $python_pips)
  create_resources('python::pyvenv', $python_pyvenvs)
  create_resources('python::requirements', $python_requirements)
  create_resources('python::dotfile', $python_dotfiles)
}