Mercurial > repos > other > Puppet
view modules/python/REFERENCE.md @ 432:d05e9281909c
Remove now abandoned Strike Creations website
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 21 Feb 2023 15:54:18 +0000 |
parents | 66c075c5f54a |
children | adf6fe9bbc17 |
line wrap: on
line source
# Reference <!-- DO NOT EDIT: This document was generated by Puppet Strings --> ## Table of Contents ### Classes #### Public Classes * [`python`](#python): Installs and manages python, python-dev and gunicorn. * [`python::pip::bootstrap`](#pythonpipbootstrap): 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 * [`python::dotfile`](#pythondotfile): Manages any python dotfiles with a simple config hash. * [`python::gunicorn`](#pythongunicorn): Manages Gunicorn virtual hosts. * [`python::pip`](#pythonpip): Installs and manages packages from pip. * [`python::pyvenv`](#pythonpyvenv): Create a Python3 virtualenv using pyvenv. * [`python::requirements`](#pythonrequirements): Installs and manages Python packages from requirements file. ### Data types * [`Python::Loglevel`](#pythonloglevel): A version type to match all valid loglevels for python * [`Python::Package::Ensure`](#pythonpackageensure): A version type to match all valid package ensures for python * [`Python::Provider`](#pythonprovider): A version type to match all valid provider for python * [`Python::Umask`](#pythonumask): A version type to match valid umask for python * [`Python::Venv::PipVersion`](#pythonvenvpipversion): A version type to ensure a specific Pip version in a virtual env. * [`Python::Version`](#pythonversion): A version type to match all valid versions for python ## Classes ### <a name="python"></a>`python` Installs and manages python, python-dev and gunicorn. #### Examples ##### install python from system python ```puppet class { 'python': version => 'system', pip => 'present', dev => 'present', gunicorn => 'present', } ``` ##### install python3 from scl repo ```puppet class { 'python' : ensure => 'present', version => 'rh-python36-python', dev => 'present', } ``` #### Parameters The following parameters are available in the `python` class: * [`ensure`](#ensure) * [`version`](#version) * [`pip`](#pip) * [`dev`](#dev) * [`gunicorn`](#gunicorn) * [`manage_gunicorn`](#manage_gunicorn) * [`provider`](#provider) * [`use_epel`](#use_epel) * [`manage_scl`](#manage_scl) * [`umask`](#umask) * [`manage_python_package`](#manage_python_package) * [`manage_pip_package`](#manage_pip_package) * [`gunicorn_package_name`](#gunicorn_package_name) * [`python_pips`](#python_pips) * [`python_pyvenvs`](#python_pyvenvs) * [`python_requirements`](#python_requirements) * [`python_dotfiles`](#python_dotfiles) * [`rhscl_use_public_repository`](#rhscl_use_public_repository) * [`anaconda_installer_url`](#anaconda_installer_url) * [`anaconda_install_path`](#anaconda_install_path) ##### <a name="ensure"></a>`ensure` Data type: `Python::Package::Ensure` Desired installation state for the Python package. Default value: `$python::params::ensure` ##### <a name="version"></a>`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: `'3'` ##### <a name="pip"></a>`pip` Data type: `Python::Package::Ensure` Desired installation state for the python-pip package. Default value: `$python::params::pip` ##### <a name="dev"></a>`dev` Data type: `Python::Package::Ensure` Desired installation state for the python-dev package. Default value: `$python::params::dev` ##### <a name="gunicorn"></a>`gunicorn` Data type: `Python::Package::Ensure` Desired installation state for Gunicorn. Default value: `$python::params::gunicorn` ##### <a name="manage_gunicorn"></a>`manage_gunicorn` Data type: `Boolean` Allow Installation / Removal of Gunicorn. Default value: `$python::params::manage_gunicorn` ##### <a name="provider"></a>`provider` Data type: `Optional[Python::Provider]` What provider to use for installation of the packages, except gunicorn and Python itself. Default value: `$python::params::provider` ##### <a name="use_epel"></a>`use_epel` Data type: `Boolean` to determine if the epel class is used. Default value: `$python::params::use_epel` ##### <a name="manage_scl"></a>`manage_scl` Data type: `Boolean` Whether to manage core SCL packages or not. Default value: `$python::params::manage_scl` ##### <a name="umask"></a>`umask` Data type: `Optional[Python::Umask]` The default umask for invoked exec calls. Default value: ``undef`` ##### <a name="manage_python_package"></a>`manage_python_package` Data type: `Boolean` Default value: `$python::params::manage_python_package` ##### <a name="manage_pip_package"></a>`manage_pip_package` Data type: `Boolean` Default value: `$python::params::manage_pip_package` ##### <a name="gunicorn_package_name"></a>`gunicorn_package_name` Data type: `String[1]` Default value: `$python::params::gunicorn_package_name` ##### <a name="python_pips"></a>`python_pips` Data type: `Hash` Default value: `{}` ##### <a name="python_pyvenvs"></a>`python_pyvenvs` Data type: `Hash` Default value: `{}` ##### <a name="python_requirements"></a>`python_requirements` Data type: `Hash` Default value: `{}` ##### <a name="python_dotfiles"></a>`python_dotfiles` Data type: `Hash` Default value: `{}` ##### <a name="rhscl_use_public_repository"></a>`rhscl_use_public_repository` Data type: `Boolean` Default value: `$python::params::rhscl_use_public_repository` ##### <a name="anaconda_installer_url"></a>`anaconda_installer_url` Data type: `Stdlib::Httpurl` Default value: `$python::params::anaconda_installer_url` ##### <a name="anaconda_install_path"></a>`anaconda_install_path` Data type: `Stdlib::Absolutepath` Default value: `$python::params::anaconda_install_path` ### <a name="pythonpipbootstrap"></a>`python::pip::bootstrap` allow to bootstrap pip when python is managed from other module #### Examples ##### ```puppet class { 'python::pip::bootstrap': version => 'pip', } ``` #### Parameters The following parameters are available in the `python::pip::bootstrap` class: * [`version`](#version) * [`manage_python`](#manage_python) * [`http_proxy`](#http_proxy) * [`exec_provider`](#exec_provider) ##### <a name="version"></a>`version` Data type: `Enum['pip', 'pip3']` should be pip or pip3 Default value: `'pip'` ##### <a name="manage_python"></a>`manage_python` Data type: `Variant[Boolean, String]` if python module will manage deps Default value: ``false`` ##### <a name="http_proxy"></a>`http_proxy` Data type: `Optional[Stdlib::HTTPUrl]` Proxy server to use for outbound connections. Default value: ``undef`` ##### <a name="exec_provider"></a>`exec_provider` Data type: `String[1]` Default value: `'shell'` ## Defined types ### <a name="pythondotfile"></a>`python::dotfile` Manages any python dotfiles with a simple config hash. #### Examples ##### Create a pip config in /var/lib/jenkins/.pip/ ```puppet 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`](#ensure) * [`filename`](#filename) * [`mode`](#mode) * [`owner`](#owner) * [`group`](#group) * [`config`](#config) ##### <a name="ensure"></a>`ensure` Data type: `Enum['absent', 'present']` Default value: `'present'` ##### <a name="filename"></a>`filename` Data type: `Stdlib::Absolutepath` Filename. Default value: `$title` ##### <a name="mode"></a>`mode` Data type: `Stdlib::Filemode` File mode. Default value: `'0644'` ##### <a name="owner"></a>`owner` Data type: `String[1]` user owner of dotfile Default value: `'root'` ##### <a name="group"></a>`group` Data type: `String[1]` group owner of dotfile Default value: `'root'` ##### <a name="config"></a>`config` Data type: `Hash` Config hash. This will be expanded to an ini-file. Default value: `{}` ### <a name="pythongunicorn"></a>`python::gunicorn` Manages Gunicorn virtual hosts. #### Examples ##### run gunicorn on vhost in virtualenv /var/www/project1 ```puppet 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`](#ensure) * [`config_dir`](#config_dir) * [`manage_config_dir`](#manage_config_dir) * [`virtualenv`](#virtualenv) * [`mode`](#mode) * [`dir`](#dir) * [`bind`](#bind) * [`environment`](#environment) * [`appmodule`](#appmodule) * [`osenv`](#osenv) * [`timeout`](#timeout) * [`template`](#template) * [`args`](#args) * [`owner`](#owner) * [`group`](#group) * [`workers`](#workers) * [`access_log_format`](#access_log_format) * [`accesslog`](#accesslog) * [`errorlog`](#errorlog) * [`log_level`](#log_level) ##### <a name="ensure"></a>`ensure` Data type: `Enum['present', 'absent']` Default value: `present` ##### <a name="config_dir"></a>`config_dir` Data type: `Stdlib::Absolutepath` Configure the gunicorn config directory path. Default value: `'/etc/gunicorn.d'` ##### <a name="manage_config_dir"></a>`manage_config_dir` Data type: `Boolean` Set if the gunicorn config directory should be created. Default value: ``false`` ##### <a name="virtualenv"></a>`virtualenv` Data type: `Variant[Boolean,Stdlib::Absolutepath]` Run in virtualenv, specify directory. Default value: ``false`` ##### <a name="mode"></a>`mode` Data type: `Enum['wsgi', 'django']` Gunicorn mode. Default value: `'wsgi'` ##### <a name="dir"></a>`dir` Data type: `Stdlib::Absolutepath` Application directory. ##### <a name="bind"></a>`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`` ##### <a name="environment"></a>`environment` Data type: `Variant[String[1],Boolean]` Set ENVIRONMENT variable. Default value: ``false`` ##### <a name="appmodule"></a>`appmodule` Data type: `String[1]` Set the application module name for gunicorn to load when not using Django. Default value: `'app:app'` ##### <a name="osenv"></a>`osenv` Data type: `Variant[Boolean,Hash]` Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default value: ``false`` ##### <a name="timeout"></a>`timeout` Data type: `Integer` Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. Default value: `30` ##### <a name="template"></a>`template` Data type: `String[1]` Which ERB template to use. Default value: `'python/gunicorn.erb'` ##### <a name="args"></a>`args` Data type: `Array` Custom arguments to add in gunicorn config file. Default value: `[]` ##### <a name="owner"></a>`owner` Data type: `String[1]` Default value: `'www-data'` ##### <a name="group"></a>`group` Data type: `String[1]` Default value: `'www-data'` ##### <a name="workers"></a>`workers` Data type: `Variant[Boolean,Integer]` Default value: ``false`` ##### <a name="access_log_format"></a>`access_log_format` Data type: `Variant[Boolean,String[1]]` Default value: ``false`` ##### <a name="accesslog"></a>`accesslog` Data type: `Variant[Boolean,Stdlib::Absolutepath]` Default value: ``false`` ##### <a name="errorlog"></a>`errorlog` Data type: `Variant[Boolean,Stdlib::Absolutepath]` Default value: ``false`` ##### <a name="log_level"></a>`log_level` Data type: `Python::Loglevel` Default value: `'error'` ### <a name="pythonpip"></a>`python::pip` Installs and manages packages from pip. #### Examples ##### Install Flask to /var/www/project1 using a proxy ```puppet python::pip { 'flask': virtualenv => '/var/www/project1', proxy => 'http://proxy.domain.com:3128', index => 'http://www.example.com/simple/', } ``` ##### Install cx_Oracle with pip ```puppet 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 ```puppet 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`](#name) * [`pkgname`](#pkgname) * [`ensure`](#ensure) * [`virtualenv`](#virtualenv) * [`pip_provider`](#pip_provider) * [`url`](#url) * [`owner`](#owner) * [`group`](#group) * [`index`](#index) * [`proxy`](#proxy) * [`editable`](#editable) * [`environment`](#environment) * [`extras`](#extras) * [`timeout`](#timeout) * [`install_args`](#install_args) * [`uninstall_args`](#uninstall_args) * [`log_dir`](#log_dir) * [`egg`](#egg) * [`umask`](#umask) * [`path`](#path) * [`exec_provider`](#exec_provider) ##### <a name="name"></a>`name` must be unique ##### <a name="pkgname"></a>`pkgname` Data type: `String[1]` the name of the package. Default value: `$name` ##### <a name="ensure"></a>`ensure` Data type: `Variant[Enum[present, absent, latest], String[1]]` Require pip to be available. Default value: `present` ##### <a name="virtualenv"></a>`virtualenv` Data type: `Variant[Enum['system'], Stdlib::Absolutepath]` virtualenv to run pip in. Default value: `'system'` ##### <a name="pip_provider"></a>`pip_provider` Data type: `String[1]` version of pip you wish to use. Default value: `'pip'` ##### <a name="url"></a>`url` Data type: `Variant[Boolean, String]` URL to install from. Default value: ``false`` ##### <a name="owner"></a>`owner` Data type: `String[1]` The owner of the virtualenv being manipulated. Default value: `'root'` ##### <a name="group"></a>`group` Data type: `Optional[String[1]]` The group of the virtualenv being manipulated. Default value: `getvar('python::params::group')` ##### <a name="index"></a>`index` Data type: `Variant[Boolean,String[1]]` Base URL of Python package index. Default value: ``false`` ##### <a name="proxy"></a>`proxy` Data type: `Optional[Stdlib::HTTPUrl]` Proxy server to use for outbound connections. Default value: ``undef`` ##### <a name="editable"></a>`editable` Data type: `Boolean` If true the package is installed as an editable resource. Default value: ``false`` ##### <a name="environment"></a>`environment` Data type: `Array` Additional environment variables required to install the packages. Default value: `[]` ##### <a name="extras"></a>`extras` Data type: `Array` Extra features provided by the package which should be installed. Default value: `[]` ##### <a name="timeout"></a>`timeout` Data type: `Numeric` The maximum time in seconds the "pip install" command should take. Default value: `1800` ##### <a name="install_args"></a>`install_args` Data type: `Optional[String[1]]` Any additional installation arguments that will be supplied when running pip install. Default value: ``undef`` ##### <a name="uninstall_args"></a>`uninstall_args` Data type: `Optional[String[1]]` Any additional arguments that will be supplied when running pip uninstall. Default value: ``undef`` ##### <a name="log_dir"></a>`log_dir` Data type: `String[1]` Log directory Default value: `'/tmp'` ##### <a name="egg"></a>`egg` Data type: `Any` The egg name to use Default value: ``false`` ##### <a name="umask"></a>`umask` Data type: `Optional[Python::Umask]` Default value: ``undef`` ##### <a name="path"></a>`path` Data type: `Array[String]` Default value: `['/usr/local/bin','/usr/bin','/bin', '/usr/sbin']` ##### <a name="exec_provider"></a>`exec_provider` Data type: `String[1]` Default value: `'shell'` ### <a name="pythonpyvenv"></a>`python::pyvenv` Create a Python3 virtualenv using pyvenv. #### Examples ##### ```puppet 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`](#ensure) * [`version`](#version) * [`systempkgs`](#systempkgs) * [`venv_dir`](#venv_dir) * [`owner`](#owner) * [`group`](#group) * [`mode`](#mode) * [`path`](#path) * [`environment`](#environment) * [`pip_version`](#pip_version) ##### <a name="ensure"></a>`ensure` Data type: `Python::Package::Ensure` Default value: `present` ##### <a name="version"></a>`version` Data type: `Python::Version` Python version to use. Default value: `'system'` ##### <a name="systempkgs"></a>`systempkgs` Data type: `Boolean` Copy system site-packages into virtualenv Default value: ``false`` ##### <a name="venv_dir"></a>`venv_dir` Data type: `Stdlib::Absolutepath` Directory to install virtualenv to Default value: `$name` ##### <a name="owner"></a>`owner` Data type: `String[1]` The owner of the virtualenv being manipulated Default value: `'root'` ##### <a name="group"></a>`group` Data type: `String[1]` The group relating to the virtualenv being manipulated Default value: `'root'` ##### <a name="mode"></a>`mode` Data type: `Stdlib::Filemode` Optionally specify directory mode Default value: `'0755'` ##### <a name="path"></a>`path` Data type: `Array[Stdlib::Absolutepath]` Specifies the PATH variable. Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin',]` ##### <a name="environment"></a>`environment` Data type: `Array` Optionally specify environment variables for pyvenv Default value: `[]` ##### <a name="pip_version"></a>`pip_version` Data type: `Python::Venv::PipVersion` Default value: `'latest'` ### <a name="pythonrequirements"></a>`python::requirements` Installs and manages Python packages from requirements file. #### Examples ##### install pip requirements from /var/www/project1/requirements.txt ```puppet 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`](#requirements) * [`virtualenv`](#virtualenv) * [`pip_provider`](#pip_provider) * [`owner`](#owner) * [`group`](#group) * [`proxy`](#proxy) * [`src`](#src) * [`environment`](#environment) * [`forceupdate`](#forceupdate) * [`cwd`](#cwd) * [`extra_pip_args`](#extra_pip_args) * [`manage_requirements`](#manage_requirements) * [`fix_requirements_owner`](#fix_requirements_owner) * [`log_dir`](#log_dir) * [`timeout`](#timeout) ##### <a name="requirements"></a>`requirements` Data type: `Stdlib::Absolutepath` Path to the requirements file. Default value: `$name` ##### <a name="virtualenv"></a>`virtualenv` Data type: `Variant[Enum['system'],Stdlib::Absolutepath]` virtualenv to run pip in. Default value: `'system'` ##### <a name="pip_provider"></a>`pip_provider` Data type: `Enum['pip', 'pip3']` version of pip you wish to use. Default value: `'pip'` ##### <a name="owner"></a>`owner` Data type: `String[1]` The owner of the virtualenv being manipulated. Default value: `'root'` ##### <a name="group"></a>`group` Data type: `String[1]` The group relating to the virtualenv being manipulated. Default value: `'root'` ##### <a name="proxy"></a>`proxy` Data type: `Optional[Stdlib::HTTPUrl]` Proxy server to use for outbound connections. Default value: ``undef`` ##### <a name="src"></a>`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`` ##### <a name="environment"></a>`environment` Data type: `Array` Additional environment variables required to install the packages. Default value: `[]` ##### <a name="forceupdate"></a>`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`` ##### <a name="cwd"></a>`cwd` Data type: `Optional[Stdlib::Absolutepath]` The directory from which to run the "pip install" command. Default value: ``undef`` ##### <a name="extra_pip_args"></a>`extra_pip_args` Data type: `Optional[String[1]]` Extra arguments to pass to pip after the requirements file Default value: ``undef`` ##### <a name="manage_requirements"></a>`manage_requirements` Data type: `Boolean` Create the requirements file if it doesn't exist. Default value: ``true`` ##### <a name="fix_requirements_owner"></a>`fix_requirements_owner` Data type: `Boolean` Change owner and group of requirements file. Default value: ``true`` ##### <a name="log_dir"></a>`log_dir` Data type: `Stdlib::Absolutepath` Log directory. Default value: `'/tmp'` ##### <a name="timeout"></a>`timeout` Data type: `Integer` The maximum time in seconds the "pip install" command should take. Default value: `1800` ## Data types ### <a name="pythonloglevel"></a>`Python::Loglevel` A version type to match all valid loglevels for python Alias of ```puppet Enum['debug', 'info', 'warning', 'error', 'critical'] ``` ### <a name="pythonpackageensure"></a>`Python::Package::Ensure` A version type to match all valid package ensures for python Alias of ```puppet Enum['absent', 'present', 'latest'] ``` ### <a name="pythonprovider"></a>`Python::Provider` A version type to match all valid provider for python Alias of ```puppet Enum['pip', 'scl', 'rhscl', 'anaconda', ''] ``` ### <a name="pythonumask"></a>`Python::Umask` A version type to match valid umask for python Alias of ```puppet Pattern[/[0-7]{1,4}/] ``` ### <a name="pythonvenvpipversion"></a>`Python::Venv::PipVersion` A version type to ensure a specific Pip version in a virtual env. Alias of ```puppet Pattern[/^(<|>|<=|>=|==) [0-9]*(\.[0-9]+)*$/, /\Alatest\Z/] ``` ### <a name="pythonversion"></a>`Python::Version` A version type to match all valid versions for python Alias of ```puppet Pattern[/\A(python)?[0-9](\.?[0-9])*/, /\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] ```