Classes
Public Classes
python
: Installs and manages python, python-dev, python-virtualenv and gunicorn.
Private Classes
python::config
: Optionally installs the gunicorn servicepython::install
: Installs core python packagespython::params
: The python Module default configuration settings.
Defined types
python::dotfile
: Manages any python dotfiles with a simple config hash.python::gunicorn
: Manages Gunicorn virtual hosts.python::pip
: Installs and manages packages from pip.python::pyvenv
: Create a Python3 virtualenv using pyvenv.python::requirements
: Installs and manages Python packages from requirements file.python::virtualenv
: Creates Python virtualenv.
Installs and manages python, python-dev, python-virtualenv and gunicorn.
class { 'python':
version => 'system',
pip => 'present',
dev => 'present',
virtualenv => 'present',
gunicorn => 'present',
}
class { 'python' :
ensure => 'present',
version => 'rh-python36-python',
dev => 'present',
virtualenv => 'present',
}
The following parameters are available in the python
class.
Data type: Enum['absent', 'present', 'latest']
Desired installation state for the Python package.
Default value: $python::params::ensure
Data type: Any
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: $python::params::version
Data type: Enum['absent', 'present', 'latest']
Desired installation state for the python-pip package.
Default value: $python::params::pip
Data type: Enum['absent', 'present', 'latest']
Desired installation state for the python-dev package.
Default value: $python::params::dev
Data type: Enum['absent', 'present', 'latest']
Desired installation state for the virtualenv package
Default value: $python::params::virtualenv
Data type: Enum['absent', 'present', 'latest']
Desired installation state for Gunicorn.
Default value: $python::params::gunicorn
Data type: Boolean
Allow Installation / Removal of Gunicorn.
Default value: $python::params::manage_gunicorn
Data type: Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']]
What provider to use for installation of the packages, except gunicorn and Python itself.
Default value: $python::params::provider
Data type: Boolean
to determine if the epel class is used.
Default value: $python::params::use_epel
Data type: Any
Default value: $python::params::gunicorn_package_name
Data type: Any
Default value: $python::params::valid_versions
Data type: Hash
Default value: { }
Data type: Hash
Default value: { }
Data type: Hash
Default value: { }
Data type: Hash
Default value: { }
Data type: Hash
Default value: { }
Data type: Any
Default value: $python::params::rhscl_use_public_repository
Data type: Stdlib::Httpurl
Default value: $python::params::anaconda_installer_url
Data type: Stdlib::Absolutepath
Default value: $python::params::anaconda_install_path
Manages any python dotfiles with a simple config hash.
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/'
}
}
}
The following parameters are available in the python::dotfile
defined type.
Data type: Enum['absent', 'present']
Default value: 'present'
Data type: Stdlib::Filemode
Filename.
Default value: $title
Data type: String[1]
File mode.
Default value: '0644'
Data type: String[1]
user owner of dotfile
Default value: 'root'
Data type: String[1]
group owner of dotfile
Default value: 'root'
Data type: Hash
Config hash. This will be expanded to an ini-file.
Default value: {}
Manages Gunicorn virtual hosts.
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',
}
The following parameters are available in the python::gunicorn
defined type.
Data type: Enum['present', 'absent']
Default value: present
Data type: Any
Configure the gunicorn config directory path.
Default value: '/etc/gunicorn.d'
Data type: Any
Set if the gunicorn config directory should be created.
Default value: false
Data type: Any
Run in virtualenv, specify directory.
Default value: false
Data type: Enum['wsgi', 'django']
Gunicorn mode.
Default value: 'wsgi'
Data type: Any
Application directory.
Default value: false
Data type: Any
Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. Default: system-wide: unix:/tmp/gunicorn-$name.socket virtualenv: unix:${virtualenv}/${name}.socket
Default value: false
Data type: Any
Set ENVIRONMENT variable.
Default value: false
Data type: Any
Set the application module name for gunicorn to load when not using Django.
Default value: 'app:app'
Data type: Any
Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs.
Default value: false
Data type: Any
Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds.
Default value: 30
Data type: Any
Which ERB template to use.
Default value: 'python/gunicorn.erb'
Data type: Any
Custom arguments to add in gunicorn config file.
Default value: []
Data type: Any
Default value: 'www-data'
Data type: Any
Default value: 'www-data'
Data type: Any
Default value: false
Data type: Any
Default value: false
Data type: Any
Default value: false
Data type: Any
Default value: false
Data type: Any
Default value: 'error'
Installs and manages packages from pip.
python::pip { 'flask':
virtualenv => '/var/www/project1',
proxy => 'http://proxy.domain.com:3128',
index => 'http://www.example.com/simple/',
}
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,
}
python::pip { 'requests' :
ensure => 'present',
pkgname => 'requests',
pip_provider => 'pip3',
virtualenv => '/var/www/project1',
owner => 'root',
timeout => 1800
}
The following parameters are available in the python::pip
defined type.
must be unique
Data type: String
the name of the package.
Default value: $name
Data type: Variant[Enum[present, absent, latest], String[1]]
Require pip to be available.
Default value: present
Data type: String
virtualenv to run pip in.
Default value: 'system'
Data type: Enum['pip', 'pip3']
version of pip you wish to use.
Default value: 'pip'
Data type: Variant[Boolean, String]
URL to install from.
Default value: false
Data type: String[1]
The owner of the virtualenv being manipulated.
Default value: 'root'
Data type: String[1]
The group of the virtualenv being manipulated.
Default value: 'root'
Data type: Any
Base URL of Python package index.
Default value: false
Data type: Variant[Boolean, String]
Proxy server to use for outbound connections.
Default value: false
Data type: Boolean
If true the package is installed as an editable resource.
Default value: false
Data type: Any
Additional environment variables required to install the packages.
Default value: []
Data type: Any
Extra features provided by the package which should be installed.
Default value: []
Data type: Numeric
The maximum time in seconds the "pip install" command should take.
Default value: 1800
Data type: String
Any additional installation arguments that will be supplied when running pip install.
Default value: ''
Data type: String
Any additional arguments that will be supplied when running pip uninstall.
Default value: ''
Data type: String[1]
Log directory
Default value: '/tmp'
Data type: Any
The egg name to use
Default value: false
Data type: Any
Default value: undef
Data type: Array[String]
Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin']
Create a Python3 virtualenv using pyvenv.
python::pyvenv { '/var/www/project1' :
ensure => present,
version => 'system',
systempkgs => true,
venv_dir => '/home/appuser/virtualenvs',
owner => 'appuser',
group => 'apps',
}
The following parameters are available in the python::pyvenv
defined type.
Data type: Any
Default value: present
Data type: Any
Python version to use.
Default value: 'system'
Data type: Any
Copy system site-packages into virtualenv
Default value: false
Data type: Any
Directory to install virtualenv to
Default value: $name
Data type: Any
The owner of the virtualenv being manipulated
Default value: 'root'
Data type: Any
The group relating to the virtualenv being manipulated
Default value: 'root'
Data type: Any
Optionally specify directory mode
Default value: '0755'
Data type: Any
Specifies the PATH variable.
Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ]
Data type: Any
Optionally specify environment variables for pyvenv
Default value: []
Installs and manages Python packages from requirements file.
python::requirements { '/var/www/project1/requirements.txt' :
virtualenv => '/var/www/project1',
proxy => 'http://proxy.domain.com:3128',
owner => 'appuser',
group => 'apps',
}
The following parameters are available in the python::requirements
defined type.
Data type: Any
Path to the requirements file.
Default value: $name
Data type: Any
virtualenv to run pip in.
Default value: 'system'
Data type: Enum['pip', 'pip3']
version of pip you wish to use.
Default value: 'pip'
Data type: Any
The owner of the virtualenv being manipulated.
Default value: 'root'
Data type: Any
The group relating to the virtualenv being manipulated.
Default value: 'root'
Data type: Any
Proxy server to use for outbound connections.
Default value: false
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
Data type: Any
Additional environment variables required to install the packages.
Default value: []
Data type: Any
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
Data type: Any
The directory from which to run the "pip install" command.
Default value: undef
Data type: Any
Extra arguments to pass to pip after the requirements file
Default value: ''
Data type: Any
Create the requirements file if it doesn't exist.
Default value: true
Data type: Any
Change owner and group of requirements file.
Default value: true
Data type: Any
Log directory.
Default value: '/tmp'
Data type: Any
The maximum time in seconds the "pip install" command should take.
Default value: 1800
Creates Python virtualenv.
python::virtualenv { '/var/www/project1':
ensure => present,
version => 'system',
requirements => '/var/www/project1/requirements.txt',
proxy => 'http://proxy.domain.com:3128',
systempkgs => true,
index => 'http://www.example.com/simple/',
}
The following parameters are available in the python::virtualenv
defined type.
Data type: Any
Default value: present
Data type: Any
Python version to use.
Default value: 'system'
Data type: Any
Path to pip requirements.txt file
Default value: false
Data type: Any
Copy system site-packages into virtualenv.
Default value: false
Data type: Any
Directory to install virtualenv to
Default value: $name
Data type: Any
Create $venv_dir
Default value: true
Data type: Any
Include distribute in the virtualenv
Default value: true
Data type: Any
Base URL of Python package index
Default value: false
Data type: Any
The owner of the virtualenv being manipulated
Default value: 'root'
Data type: Any
The group relating to the virtualenv being manipulated
Default value: 'root'
Data type: Any
Optionally specify directory mode
Default value: '0755'
Data type: Any
Proxy server to use for outbound connections
Default value: false
Data type: Any
Additional environment variables required to install the packages
Default value: []
Data type: Any
Specifies the PATH variable
Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ]
Data type: Any
The directory from which to run the "pip install" command
Default value: undef
Data type: Any
The maximum time in seconds the "pip install" command should take
Default value: 1800
Data type: Any
Arguments to pass to pip during initialization
Default value: ''
Data type: Any
Extra arguments to pass to pip after requirements file
Default value: ''
Data type: Any
Default value: undef