Skip to content

Latest commit

 

History

History
1209 lines (682 loc) · 27.3 KB

REFERENCE.md

File metadata and controls

1209 lines (682 loc) · 27.3 KB

Reference

Table of Contents

Classes

Public Classes

  • python: Installs and manages python, python-dev and gunicorn.
  • python::pip::bootstrap: allow to bootstrap pip when python is managed from other module

Private Classes

  • python::config: Optionally installs the gunicorn service
  • python::install: Installs core python packages
  • python::params: The python Module default configuration settings.

Defined types

Data types

Classes

python

Installs and manages python, python-dev and gunicorn.

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

The following parameters are available in the python class:

ensure

Data type: Python::Package::Ensure

Desired installation state for the Python package.

Default value: 'present'

version

Data type: Python::Version

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.

Default value: $facts['os']['family'] ? { 'Archlinux' => 'system', default => '3'

pip

Data type: Python::Package::Ensure

Desired installation state for the python-pip package.

Default value: 'present'

dev

Data type: Python::Package::Ensure

Desired installation state for the python-dev package.

Default value: 'absent'

gunicorn

Data type: Python::Package::Ensure

Desired installation state for Gunicorn.

Default value: 'absent'

manage_gunicorn

Data type: Boolean

Allow Installation / Removal of Gunicorn.

Default value: true

provider

Data type: Optional[Python::Provider]

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

Default value: undef

use_epel

Data type: Boolean

to determine if the epel class is used.

Default value: $python::params::use_epel

manage_scl

Data type: Boolean

Whether to manage core SCL packages or not.

Default value: true

umask

Data type: Optional[Python::Umask]

The default umask for invoked exec calls.

Default value: undef

manage_gunicorn

manage the state for package gunicorn

Default value: true

manage_python_package

Data type: Boolean

manage the state for package python

Default value: true

manage_dev_package

Data type: Boolean

manage the state of the python development package

Default value: true

manage_venv_package

Data type: Boolean

manage the state for package venv

Default value: $python::params::manage_venv_package

manage_pip_package

Data type: Boolean

manage the state for package pip

Default value: $python::params::manage_pip_package

venv

Data type: Python::Package::Ensure

Default value: 'absent'

gunicorn_package_name

Data type: String[1]

Default value: $python::params::gunicorn_package_name

python_pips

Data type: Hash

Default value: {}

python_pyvenvs

Data type: Hash

Default value: {}

python_requirements

Data type: Hash

Default value: {}

python_dotfiles

Data type: Hash

Default value: {}

rhscl_use_public_repository

Data type: Boolean

Default value: true

anaconda_installer_url

Data type: Stdlib::Httpurl

Default value: 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh'

anaconda_install_path

Data type: Stdlib::Absolutepath

Default value: '/opt/python'

python::pip::bootstrap

allow to bootstrap pip when python is managed from other module

Examples

class { 'python::pip::bootstrap':
  version => 'pip',
}

Parameters

The following parameters are available in the python::pip::bootstrap class:

version

Data type: Enum['pip', 'pip3']

should be pip or pip3

Default value: 'pip'

manage_python

Data type: Variant[Boolean, String]

if python module will manage deps

Default value: false

http_proxy

Data type: Optional[Stdlib::HTTPUrl]

Proxy server to use for outbound connections.

Default value: undef

exec_provider

Data type: String[1]

Default value: 'shell'

Defined types

python::dotfile

Manages any python dotfiles with a simple config hash.

Examples

Create a pip config in /var/lib/jenkins/.pip/
python::dotfile { '/var/lib/jenkins/.pip/pip.conf':
  ensure => present,
  owner  => 'jenkins',
  group  => 'jenkins',
  config => {
    'global' => {
      'index-url'       => 'https://mypypi.acme.com/simple/'
      'extra-index-url' => 'https://pypi.risedev.at/simple/'
    }
  }
}

Parameters

The following parameters are available in the python::dotfile defined type:

ensure

Data type: Enum['absent', 'present']

Default value: 'present'

filename

Data type: Stdlib::Absolutepath

Filename.

Default value: $title

mode

Data type: Stdlib::Filemode

File mode.

Default value: '0644'

owner

Data type: String[1]

user owner of dotfile

Default value: 'root'

group

Data type: String[1]

group owner of dotfile

Default value: 'root'

config

Data type: Hash

Config hash. This will be expanded to an ini-file.

Default value: {}

python::gunicorn

Manages Gunicorn virtual hosts.

Examples

run gunicorn on vhost in virtualenv /var/www/project1
python::gunicorn { 'vhost':
  ensure      => present,
  virtualenv  => '/var/www/project1',
  mode        => 'wsgi',
  dir         => '/var/www/project1/current',
  bind        => 'unix:/tmp/gunicorn.socket',
  environment => 'prod',
  owner       => 'www-data',
  group       => 'www-data',
  appmodule   => 'app:app',
  osenv       => { 'DBHOST' => 'dbserver.example.com' },
  timeout     => 30,
  template    => 'python/gunicorn.erb',
}

Parameters

The following parameters are available in the python::gunicorn defined type:

ensure

Data type: Enum['present', 'absent']

Default value: present

config_dir

Data type: Stdlib::Absolutepath

Configure the gunicorn config directory path.

Default value: '/etc/gunicorn.d'

manage_config_dir

Data type: Boolean

Set if the gunicorn config directory should be created.

Default value: false

virtualenv

Data type: Variant[Boolean,Stdlib::Absolutepath]

Run in virtualenv, specify directory.

Default value: false

mode

Data type: Enum['wsgi', 'django']

Gunicorn mode.

Default value: 'wsgi'

dir

Data type: Stdlib::Absolutepath

Application directory.

bind

Data type: Variant[String[1],Boolean]

Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. Default: system-wide: unix:/tmp/gunicorn-$name.socket virtualenv: unix:${virtualenv}/${name}.socket

Default value: false

environment

Data type: Variant[String[1],Boolean]

Set ENVIRONMENT variable.

Default value: false

appmodule

Data type: String[1]

Set the application module name for gunicorn to load when not using Django.

Default value: 'app:app'

osenv

Data type: Variant[Boolean,Hash]

Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs.

Default value: false

timeout

Data type: Integer

Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds.

Default value: 30

template

Data type: String[1]

Which ERB template to use.

Default value: 'python/gunicorn.erb'

args

Data type: Array

Custom arguments to add in gunicorn config file.

Default value: []

owner

Data type: String[1]

Default value: 'www-data'

group

Data type: String[1]

Default value: 'www-data'

workers

Data type: Variant[Boolean,Integer]

Default value: false

access_log_format

Data type: Variant[Boolean,String[1]]

Default value: false

accesslog

Data type: Variant[Boolean,Stdlib::Absolutepath]

Default value: false

errorlog

Data type: Variant[Boolean,Stdlib::Absolutepath]

Default value: false

log_level

Data type: Python::Loglevel

Default value: 'error'

python::pip

Installs and manages packages from pip.

Examples

Install Flask to /var/www/project1 using a proxy
python::pip { 'flask':
  virtualenv => '/var/www/project1',
  proxy      => 'http://proxy.domain.com:3128',
  index      => 'http://www.example.com/simple/',
}
Install cx_Oracle with pip
python::pip { 'cx_Oracle' :
  pkgname       => 'cx_Oracle',
  ensure        => '5.1.2',
  virtualenv    => '/var/www/project1',
  owner         => 'appuser',
  proxy         => 'http://proxy.domain.com:3128',
  environment   => ['ORACLE_HOME=/usr/lib/oracle/11.2/client64'],
  install_args  => '-e',
  timeout       => 1800,
}
Install Requests with pip3
python::pip { 'requests' :
  ensure        => 'present',
  pkgname       => 'requests',
  pip_provider  => 'pip3',
  virtualenv    => '/var/www/project1',
  owner         => 'root',
  timeout       => 1800
}

Parameters

The following parameters are available in the python::pip defined type:

name

must be unique

pkgname

Data type: String[1]

the name of the package.

Default value: $name

ensure

Data type: Variant[Enum[present, absent, latest], String[1]]

Require pip to be available.

Default value: present

virtualenv

Data type: Variant[Enum['system'], Stdlib::Absolutepath]

virtualenv to run pip in.

Default value: 'system'

pip_provider

Data type: String[1]

version of pip you wish to use.

Default value: 'pip'

url

Data type: Variant[Boolean, String]

URL to install from.

Default value: false

owner

Data type: String[1]

The owner of the virtualenv being manipulated.

Default value: 'root'

group

Data type: Optional[String[1]]

The group of the virtualenv being manipulated.

Default value: getvar('python::params::group')

index

Data type: Variant[Boolean,String[1]]

Base URL of Python package index.

Default value: false

extra_index

Data type: Variant[Boolean,String[1]]

Base URL of extra Python package index.

Default value: false

proxy

Data type: Optional[Stdlib::HTTPUrl]

Proxy server to use for outbound connections.

Default value: undef

editable

Data type: Boolean

If true the package is installed as an editable resource.

Default value: false

environment

Data type: Array

Additional environment variables required to install the packages.

Default value: []

extras

Data type: Array

Extra features provided by the package which should be installed.

Default value: []

timeout

Data type: Numeric

The maximum time in seconds the "pip install" command should take.

Default value: 1800

install_args

Data type: Optional[String[1]]

Any additional installation arguments that will be supplied when running pip install.

Default value: undef

uninstall_args

Data type: Optional[String[1]]

Any additional arguments that will be supplied when running pip uninstall.

Default value: undef

log_dir

Data type: String[1]

Log directory

Default value: '/tmp'

egg

Data type: Any

The egg name to use

Default value: false

umask

Data type: Optional[Python::Umask]

Default value: undef

path

Data type: Array[String]

Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin']

exec_provider

Data type: String[1]

Default value: 'shell'

python::pyvenv

Create a Python3 virtualenv using pyvenv.

Examples

python::pyvenv { '/var/www/project1' :
  ensure       => present,
  version      => 'system',
  systempkgs   => true,
  venv_dir     => '/home/appuser/virtualenvs',
  owner        => 'appuser',
  group        => 'apps',
}

Parameters

The following parameters are available in the python::pyvenv defined type:

ensure

Data type: Python::Package::Ensure

Default value: present

version

Data type: Python::Version

Python version to use.

Default value: 'system'

systempkgs

Data type: Boolean

Copy system site-packages into virtualenv

Default value: false

venv_dir

Data type: Stdlib::Absolutepath

Directory to install virtualenv to

Default value: $name

owner

Data type: String[1]

The owner of the virtualenv being manipulated

Default value: 'root'

group

Data type: String[1]

The group relating to the virtualenv being manipulated

Default value: 'root'

mode

Data type: Stdlib::Filemode

Optionally specify directory mode

Default value: '0755'

path

Data type: Array[Stdlib::Absolutepath]

Specifies the PATH variable.

Default value: ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin',]

environment

Data type: Array

Optionally specify environment variables for pyvenv

Default value: []

prompt

Data type: Optional[String[1]]

Optionally specify the virtualenv prompt (python >= 3.6)

Default value: undef

python_path

Data type: Optional[Stdlib::Absolutepath]

Optionally specify python path for creation of virtualenv

Default value: undef

pip_version

Data type: Python::Venv::PipVersion

Default value: 'latest'

python::requirements

Installs and manages Python packages from requirements file.

Examples

install pip requirements from /var/www/project1/requirements.txt
python::requirements { '/var/www/project1/requirements.txt' :
  virtualenv => '/var/www/project1',
  proxy      => 'http://proxy.domain.com:3128',
  owner      => 'appuser',
  group      => 'apps',
}

Parameters

The following parameters are available in the python::requirements defined type:

requirements

Data type: Stdlib::Absolutepath

Path to the requirements file.

Default value: $name

virtualenv

Data type: Variant[Enum['system'],Stdlib::Absolutepath]

virtualenv to run pip in.

Default value: 'system'

pip_provider

Data type: Enum['pip', 'pip3']

version of pip you wish to use.

Default value: 'pip'

owner

Data type: String[1]

The owner of the virtualenv being manipulated.

Default value: 'root'

group

Data type: String[1]

The group relating to the virtualenv being manipulated.

Default value: 'root'

proxy

Data type: Optional[Stdlib::HTTPUrl]

Proxy server to use for outbound connections.

Default value: undef

src

Data type: Any

Pip --src parameter to; if the requirements file contains --editable resources, this parameter specifies where they will be installed. See the pip documentation for more.

Default value: false

environment

Data type: Array

Additional environment variables required to install the packages.

Default value: []

forceupdate

Data type: Boolean

Run a pip install requirements even if we don't receive an event from the requirements file - Useful for when the requirements file is written as part of a resource other than file (E.g vcsrepo)

Default value: false

cwd

Data type: Optional[Stdlib::Absolutepath]

The directory from which to run the "pip install" command.

Default value: undef

extra_pip_args

Data type: Optional[String[1]]

Extra arguments to pass to pip after the requirements file

Default value: undef

manage_requirements

Data type: Boolean

Create the requirements file if it doesn't exist.

Default value: true

fix_requirements_owner

Data type: Boolean

Change owner and group of requirements file.

Default value: true

log_dir

Data type: Stdlib::Absolutepath

Log directory.

Default value: '/tmp'

timeout

Data type: Integer

The maximum time in seconds the "pip install" command should take.

Default value: 1800

Data types

Python::Loglevel

Match all valid loglevels for python

Alias of Enum['debug', 'info', 'warning', 'error', 'critical']

Python::Package::Ensure

Match all valid package ensures for python

Alias of Enum['absent', 'present', 'installed', 'latest']

Python::Provider

Match all valid provider for python

Alias of Enum['pip', 'scl', 'rhscl', 'anaconda', '']

Python::Umask

Match valid umask for python

Alias of Pattern[/[0-7]{1,4}/]

Python::Venv::PipVersion

A version type to ensure a specific Pip version in a virtual env.

Alias of Pattern[/^(<|>|<=|>=|==) [0-9]*(\.[0-9]+)*$/, /\Alatest\Z/]

Python::Version

Match all valid versions for python

Alias of Pattern[/\A(python)?[0-9](\.?[0-9])*/, /\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/]