From e0a2a46f4f1cc7b72368010547eddde3177ce581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Fr=C3=B6hner?= Date: Tue, 17 Nov 2020 08:10:25 +0100 Subject: [PATCH] fix parameter lists of manifests --- REFERENCE.md | 378 ++++++++++++++++++++----------------- manifests/dotfile.pp | 10 +- manifests/gunicorn.pp | 40 ++-- manifests/init.pp | 52 +++-- manifests/pip.pp | 40 ++-- manifests/pip/bootstrap.pp | 10 +- manifests/pyvenv.pp | 18 +- manifests/requirements.pp | 30 +-- manifests/virtualenv.pp | 38 ++-- types/loglevel.pp | 3 + types/provider.pp | 3 + types/umask.pp | 3 + types/version.pp | 8 + 13 files changed, 335 insertions(+), 298 deletions(-) create mode 100644 types/loglevel.pp create mode 100644 types/provider.pp create mode 100644 types/umask.pp create mode 100644 types/version.pp diff --git a/REFERENCE.md b/REFERENCE.md index 069496bd..0fbb2e1c 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,22 +1,23 @@ # Reference + ## Table of Contents -**Classes** +### Classes -_Public Classes_ +#### Public Classes * [`python`](#python): Installs and manages python, python-dev, python-virtualenv and gunicorn. * [`python::pip::bootstrap`](#pythonpipbootstrap): allow to bootstrap pip when python is managed from other module -_Private Classes_ +#### 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** +### Defined types * [`python::dotfile`](#pythondotfile): Manages any python dotfiles with a simple config hash. * [`python::gunicorn`](#pythongunicorn): Manages Gunicorn virtual hosts. @@ -25,9 +26,16 @@ _Private Classes_ * [`python::requirements`](#pythonrequirements): Installs and manages Python packages from requirements file. * [`python::virtualenv`](#pythonvirtualenv): Creates Python virtualenv. +### Data types + +* [`Python::Loglevel`](#pythonloglevel): A version type to match all valid versions for python +* [`Python::Provider`](#pythonprovider): A version type to match all valid versions for python +* [`Python::Umask`](#pythonumask): A version type to match all valid versions for python +* [`Python::Version`](#pythonversion): A version type to match all valid versions for python + ## Classes -### python +### `python` Installs and manages python, python-dev, python-virtualenv and gunicorn. @@ -66,11 +74,11 @@ Data type: `Enum['absent', 'present', 'latest']` Desired installation state for the Python package. -Default value: $python::params::ensure +Default value: `$python::params::ensure` ##### `version` -Data type: `Any` +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: @@ -81,7 +89,7 @@ Allowed values: - 3/3.3/... means you are going to install the python3/python3.3/... package, if available on your osfamily. -Default value: $python::params::version +Default value: `$python::params::version` ##### `pip` @@ -89,7 +97,7 @@ Data type: `Enum['absent', 'present', 'latest']` Desired installation state for the python-pip package. -Default value: $python::params::pip +Default value: `$python::params::pip` ##### `dev` @@ -97,7 +105,7 @@ Data type: `Enum['absent', 'present', 'latest']` Desired installation state for the python-dev package. -Default value: $python::params::dev +Default value: `$python::params::dev` ##### `virtualenv` @@ -105,7 +113,7 @@ Data type: `Enum['absent', 'present', 'latest']` Desired installation state for the virtualenv package -Default value: $python::params::virtualenv +Default value: `$python::params::virtualenv` ##### `gunicorn` @@ -113,7 +121,7 @@ Data type: `Enum['absent', 'present', 'latest']` Desired installation state for Gunicorn. -Default value: $python::params::gunicorn +Default value: `$python::params::gunicorn` ##### `manage_gunicorn` @@ -121,15 +129,15 @@ Data type: `Boolean` Allow Installation / Removal of Gunicorn. -Default value: $python::params::manage_gunicorn +Default value: `$python::params::manage_gunicorn` ##### `provider` -Data type: `Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']]` +Data type: `Optional[Python::Provider]` What provider to use for installation of the packages, except gunicorn and Python itself. -Default value: $python::params::provider +Default value: `$python::params::provider` ##### `use_epel` @@ -137,7 +145,7 @@ Data type: `Boolean` to determine if the epel class is used. -Default value: $python::params::use_epel +Default value: `$python::params::use_epel` ##### `manage_scl` @@ -145,15 +153,15 @@ Data type: `Boolean` Whether to manage core SCL packages or not. -Default value: $python::params::manage_scl +Default value: `$python::params::manage_scl` ##### `umask` -Data type: `Optional[Pattern[/[0-7]{1,4}/]]` +Data type: `Optional[Python::Umask]` The default umask for invoked exec calls. -Default value: `undef` +Default value: ``undef`` ##### `manage_python_package` @@ -161,7 +169,7 @@ Data type: `Boolean` -Default value: $python::params::manage_python_package +Default value: `$python::params::manage_python_package` ##### `manage_virtualenv_package` @@ -169,7 +177,7 @@ Data type: `Boolean` -Default value: $python::params::manage_virtualenv_package +Default value: `$python::params::manage_virtualenv_package` ##### `manage_pip_package` @@ -177,23 +185,15 @@ Data type: `Boolean` -Default value: $python::params::manage_pip_package +Default value: `$python::params::manage_pip_package` ##### `gunicorn_package_name` -Data type: `Any` - - - -Default value: $python::params::gunicorn_package_name - -##### `valid_versions` - -Data type: `Any` +Data type: `Strng[1]` -Default value: $python::params::valid_versions +Default value: `$python::params::gunicorn_package_name` ##### `python_pips` @@ -201,7 +201,7 @@ Data type: `Hash` -Default value: { } +Default value: `{}` ##### `python_virtualenvs` @@ -209,7 +209,7 @@ Data type: `Hash` -Default value: { } +Default value: `{}` ##### `python_pyvenvs` @@ -217,7 +217,7 @@ Data type: `Hash` -Default value: { } +Default value: `{}` ##### `python_requirements` @@ -225,7 +225,7 @@ Data type: `Hash` -Default value: { } +Default value: `{}` ##### `python_dotfiles` @@ -233,15 +233,15 @@ Data type: `Hash` -Default value: { } +Default value: `{}` ##### `rhscl_use_public_repository` -Data type: `Any` +Data type: `Boolean` -Default value: $python::params::rhscl_use_public_repository +Default value: `$python::params::rhscl_use_public_repository` ##### `anaconda_installer_url` @@ -249,7 +249,7 @@ Data type: `Stdlib::Httpurl` -Default value: $python::params::anaconda_installer_url +Default value: `$python::params::anaconda_installer_url` ##### `anaconda_install_path` @@ -257,9 +257,9 @@ Data type: `Stdlib::Absolutepath` -Default value: $python::params::anaconda_install_path +Default value: `$python::params::anaconda_install_path` -### python::pip::bootstrap +### `python::pip::bootstrap` allow to bootstrap pip when python is managed from other module @@ -283,7 +283,7 @@ Data type: `Enum['pip', 'pip3']` should be pip or pip3 -Default value: 'pip' +Default value: `'pip'` ##### `manage_python` @@ -291,7 +291,7 @@ Data type: `Variant[Boolean, String]` if python module will manage deps -Default value: `false` +Default value: ``false`` ##### `http_proxy` @@ -299,7 +299,7 @@ Data type: `Optional[Stdlib::HTTPUrl]` Proxy server to use for outbound connections. -Default value: `undef` +Default value: ``undef`` ##### `exec_provider` @@ -307,11 +307,11 @@ Data type: `String[1]` -Default value: 'shell' +Default value: `'shell'` ## Defined types -### python::dotfile +### `python::dotfile` Manages any python dotfiles with a simple config hash. @@ -343,7 +343,7 @@ Data type: `Enum['absent', 'present']` -Default value: 'present' +Default value: `'present'` ##### `filename` @@ -351,7 +351,7 @@ Data type: `String[1]` Filename. -Default value: $title +Default value: `$title` ##### `mode` @@ -359,7 +359,7 @@ Data type: `Stdlib::Filemode` File mode. -Default value: '0644' +Default value: `'0644'` ##### `owner` @@ -367,7 +367,7 @@ Data type: `String[1]` user owner of dotfile -Default value: 'root' +Default value: `'root'` ##### `group` @@ -375,7 +375,7 @@ Data type: `String[1]` group owner of dotfile -Default value: 'root' +Default value: `'root'` ##### `config` @@ -383,9 +383,9 @@ Data type: `Hash` Config hash. This will be expanded to an ini-file. -Default value: {} +Default value: `{}` -### python::gunicorn +### `python::gunicorn` Manages Gunicorn virtual hosts. @@ -420,31 +420,31 @@ Data type: `Enum['present', 'absent']` -Default value: present +Default value: `present` ##### `config_dir` -Data type: `Any` +Data type: `Stdlib::Absolutepath` Configure the gunicorn config directory path. -Default value: '/etc/gunicorn.d' +Default value: `'/etc/gunicorn.d'` ##### `manage_config_dir` -Data type: `Any` +Data type: `Booloean` Set if the gunicorn config directory should be created. -Default value: `false` +Default value: ``false`` ##### `virtualenv` -Data type: `Any` +Data type: `Variant[Boolean,Stdlib::Absolutepath]` Run in virtualenv, specify directory. -Default value: `false` +Default value: ``false`` ##### `mode` @@ -452,7 +452,7 @@ Data type: `Enum['wsgi', 'django']` Gunicorn mode. -Default value: 'wsgi' +Default value: `'wsgi'` ##### `dir` @@ -462,119 +462,119 @@ Application directory. ##### `bind` -Data type: `Any` +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` +Default value: ``false`` ##### `environment` -Data type: `Any` +Data type: `Variant[String[1],Boolean]` Set ENVIRONMENT variable. -Default value: `false` +Default value: ``false`` ##### `appmodule` -Data type: `Any` +Data type: `String[1]` Set the application module name for gunicorn to load when not using Django. -Default value: 'app:app' +Default value: `'app:app'` ##### `osenv` -Data type: `Any` +Data type: `Variant[Boolean,Hash]` Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. -Default value: `false` +Default value: ``false`` ##### `timeout` -Data type: `Any` +Data type: `Integer` Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. -Default value: 30 +Default value: `30` ##### `template` -Data type: `Any` +Data type: `String[1]` Which ERB template to use. -Default value: 'python/gunicorn.erb' +Default value: `'python/gunicorn.erb'` ##### `args` -Data type: `Any` +Data type: `Array` Custom arguments to add in gunicorn config file. -Default value: [] +Default value: `[]` ##### `owner` -Data type: `Any` +Data type: `String[1]` -Default value: 'www-data' +Default value: `'www-data'` ##### `group` -Data type: `Any` +Data type: `String[1]` -Default value: 'www-data' +Default value: `'www-data'` ##### `workers` -Data type: `Any` +Data type: `Variant[Boolean,Integer]` -Default value: `false` +Default value: ``false`` ##### `access_log_format` -Data type: `Any` +Data type: `Variant[Boolean,String[1]]` -Default value: `false` +Default value: ``false`` ##### `accesslog` -Data type: `Any` +Data type: `Variant[Boolean,Stdlib::Absolutepath]` -Default value: `false` +Default value: ``false`` ##### `errorlog` -Data type: `Any` +Data type: `Variant[Boolean,Stdlib::Absolutepath]` -Default value: `false` +Default value: ``false`` ##### `log_level` -Data type: `Enum['debug', 'info', 'warning', 'error', 'critical']` +Data type: `Python::Loglevel` -Default value: 'error' +Default value: `'error'` -### python::pip +### `python::pip` Installs and manages packages from pip. @@ -628,11 +628,11 @@ must be unique ##### `pkgname` -Data type: `String` +Data type: `String[1]` the name of the package. -Default value: $name +Default value: `$name` ##### `ensure` @@ -640,7 +640,7 @@ Data type: `Variant[Enum[present, absent, latest], String[1]]` Require pip to be available. -Default value: present +Default value: `present` ##### `virtualenv` @@ -648,7 +648,7 @@ Data type: `Variant[Enum['system'], Stdlib::Absolutepath]` virtualenv to run pip in. -Default value: 'system' +Default value: `'system'` ##### `pip_provider` @@ -656,7 +656,7 @@ Data type: `String[1]` version of pip you wish to use. -Default value: 'pip' +Default value: `'pip'` ##### `url` @@ -664,7 +664,7 @@ Data type: `Variant[Boolean, String]` URL to install from. -Default value: `false` +Default value: ``false`` ##### `owner` @@ -672,23 +672,23 @@ Data type: `String[1]` The owner of the virtualenv being manipulated. -Default value: 'root' +Default value: `'root'` ##### `group` -Data type: `Any` +Data type: `Optional[String[1]]` The group of the virtualenv being manipulated. -Default value: getvar('python::params::group') +Default value: `getvar('python::params::group')` ##### `index` -Data type: `Any` +Data type: `Variant[Boolean,String[1]]` Base URL of Python package index. -Default value: `false` +Default value: ``false`` ##### `proxy` @@ -696,7 +696,7 @@ Data type: `Optional[Stdlib::HTTPUrl]` Proxy server to use for outbound connections. -Default value: `undef` +Default value: ``undef`` ##### `editable` @@ -704,23 +704,23 @@ Data type: `Boolean` If true the package is installed as an editable resource. -Default value: `false` +Default value: ``false`` ##### `environment` -Data type: `Any` +Data type: `Array` Additional environment variables required to install the packages. -Default value: [] +Default value: `[]` ##### `extras` -Data type: `Any` +Data type: `Array` Extra features provided by the package which should be installed. -Default value: [] +Default value: `[]` ##### `timeout` @@ -728,7 +728,7 @@ Data type: `Numeric` The maximum time in seconds the "pip install" command should take. -Default value: 1800 +Default value: `1800` ##### `install_args` @@ -736,7 +736,7 @@ Data type: `String` Any additional installation arguments that will be supplied when running pip install. -Default value: '' +Default value: `''` ##### `uninstall_args` @@ -744,7 +744,7 @@ Data type: `String` Any additional arguments that will be supplied when running pip uninstall. -Default value: '' +Default value: `''` ##### `log_dir` @@ -752,7 +752,7 @@ Data type: `String[1]` Log directory -Default value: '/tmp' +Default value: `'/tmp'` ##### `egg` @@ -760,15 +760,15 @@ Data type: `Any` The egg name to use -Default value: `false` +Default value: ``false`` ##### `umask` -Data type: `Any` +Data type: `Optional[Python::Umask]` -Default value: `undef` +Default value: ``undef`` ##### `path` @@ -776,7 +776,7 @@ Data type: `Array[String]` -Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'] +Default value: `['/usr/local/bin','/usr/bin','/bin', '/usr/sbin']` ##### `exec_provider` @@ -784,9 +784,9 @@ Data type: `String[1]` -Default value: 'shell' +Default value: `'shell'` -### python::pyvenv +### `python::pyvenv` Create a Python3 virtualenv using pyvenv. @@ -815,7 +815,7 @@ Data type: `Any` -Default value: present +Default value: `present` ##### `version` @@ -823,7 +823,7 @@ Data type: `Any` Python version to use. -Default value: 'system' +Default value: `'system'` ##### `systempkgs` @@ -831,7 +831,7 @@ Data type: `Any` Copy system site-packages into virtualenv -Default value: `false` +Default value: ``false`` ##### `venv_dir` @@ -839,7 +839,7 @@ Data type: `Any` Directory to install virtualenv to -Default value: $name +Default value: `$name` ##### `owner` @@ -847,7 +847,7 @@ Data type: `Any` The owner of the virtualenv being manipulated -Default value: 'root' +Default value: `'root'` ##### `group` @@ -855,7 +855,7 @@ Data type: `Any` The group relating to the virtualenv being manipulated -Default value: 'root' +Default value: `'root'` ##### `mode` @@ -863,7 +863,7 @@ Data type: `Any` Optionally specify directory mode -Default value: '0755' +Default value: `'0755'` ##### `path` @@ -871,7 +871,7 @@ Data type: `Any` Specifies the PATH variable. -Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] +Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin']` ##### `environment` @@ -879,9 +879,9 @@ Data type: `Any` Optionally specify environment variables for pyvenv -Default value: [] +Default value: `[]` -### python::requirements +### `python::requirements` Installs and manages Python packages from requirements file. @@ -904,19 +904,19 @@ The following parameters are available in the `python::requirements` defined typ ##### `requirements` -Data type: `Any` +Data type: `String[1]` Path to the requirements file. -Default value: $name +Default value: `$name` ##### `virtualenv` -Data type: `Any` +Data type: `Variant[Enum['system'],Stdlib::Absolutepath]` virtualenv to run pip in. -Default value: 'system' +Default value: `'system'` ##### `pip_provider` @@ -924,23 +924,23 @@ Data type: `Enum['pip', 'pip3']` version of pip you wish to use. -Default value: 'pip' +Default value: `'pip'` ##### `owner` -Data type: `Any` +Data type: `String[1]` The owner of the virtualenv being manipulated. -Default value: 'root' +Default value: `'root'` ##### `group` -Data type: `Any` +Data type: `String[1]` The group relating to the virtualenv being manipulated. -Default value: 'root' +Default value: `'root'` ##### `proxy` @@ -948,7 +948,7 @@ Data type: `Optional[Stdlib::HTTPUrl]` Proxy server to use for outbound connections. -Default value: `undef` +Default value: ``undef`` ##### `src` @@ -956,73 +956,73 @@ 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` +Default value: ``false`` ##### `environment` -Data type: `Any` +Data type: `Array` Additional environment variables required to install the packages. -Default value: [] +Default value: `[]` ##### `forceupdate` -Data type: `Any` +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` +Default value: ``false`` ##### `cwd` -Data type: `Any` +Data type: `Stdlib::Absolutepath` The directory from which to run the "pip install" command. -Default value: `undef` +Default value: ``undef`` ##### `extra_pip_args` -Data type: `Any` +Data type: `String` Extra arguments to pass to pip after the requirements file -Default value: '' +Default value: `''` ##### `manage_requirements` -Data type: `Any` +Data type: `Boolean` Create the requirements file if it doesn't exist. -Default value: `true` +Default value: ``true`` ##### `fix_requirements_owner` -Data type: `Any` +Data type: `Boolean` Change owner and group of requirements file. -Default value: `true` +Default value: ``true`` ##### `log_dir` -Data type: `Any` +Data type: `Stdlib::Absolutepath` Log directory. -Default value: '/tmp' +Default value: `'/tmp'` ##### `timeout` -Data type: `Any` +Data type: `Integer` The maximum time in seconds the "pip install" command should take. -Default value: 1800 +Default value: `1800` -### python::virtualenv +### `python::virtualenv` Creates Python virtualenv. @@ -1051,7 +1051,7 @@ Data type: `Any` -Default value: 'present' +Default value: `'present'` ##### `version` @@ -1059,7 +1059,7 @@ Data type: `Any` Python version to use. -Default value: 'system' +Default value: `'system'` ##### `requirements` @@ -1067,7 +1067,7 @@ Data type: `Any` Path to pip requirements.txt file -Default value: `false` +Default value: ``false`` ##### `systempkgs` @@ -1075,7 +1075,7 @@ Data type: `Any` Copy system site-packages into virtualenv. -Default value: `false` +Default value: ``false`` ##### `venv_dir` @@ -1083,7 +1083,7 @@ Data type: `Any` Directory to install virtualenv to -Default value: $name +Default value: `$name` ##### `ensure_venv_dir` @@ -1091,7 +1091,7 @@ Data type: `Any` Create $venv_dir -Default value: `true` +Default value: ``true`` ##### `distribute` @@ -1099,7 +1099,7 @@ Data type: `Any` Include distribute in the virtualenv -Default value: `true` +Default value: ``true`` ##### `index` @@ -1107,7 +1107,7 @@ Data type: `Any` Base URL of Python package index -Default value: `false` +Default value: ``false`` ##### `owner` @@ -1115,7 +1115,7 @@ Data type: `Any` The owner of the virtualenv being manipulated -Default value: 'root' +Default value: `'root'` ##### `group` @@ -1123,7 +1123,7 @@ Data type: `Any` The group relating to the virtualenv being manipulated -Default value: 'root' +Default value: `'root'` ##### `mode` @@ -1131,15 +1131,15 @@ Data type: `Any` Optionally specify directory mode -Default value: '0755' +Default value: `'0755'` ##### `proxy` -Data type: `Optional[Stdlib::HTTPUrl]` +Data type: `Any` Proxy server to use for outbound connections -Default value: `undef` +Default value: ``undef`` ##### `environment` @@ -1147,7 +1147,7 @@ Data type: `Any` Additional environment variables required to install the packages -Default value: [] +Default value: `[]` ##### `path` @@ -1155,7 +1155,7 @@ Data type: `Any` Specifies the PATH variable -Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] +Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin']` ##### `cwd` @@ -1163,7 +1163,7 @@ Data type: `Any` The directory from which to run the "pip install" command -Default value: `undef` +Default value: ``undef`` ##### `timeout` @@ -1171,7 +1171,7 @@ Data type: `Any` The maximum time in seconds the "pip install" command should take -Default value: 1800 +Default value: `1800` ##### `pip_args` @@ -1179,7 +1179,7 @@ Data type: `Any` Arguments to pass to pip during initialization -Default value: '' +Default value: `''` ##### `extra_pip_args` @@ -1187,7 +1187,7 @@ Data type: `Any` Extra arguments to pass to pip after requirements file -Default value: '' +Default value: `''` ##### `virtualenv` @@ -1195,5 +1195,31 @@ Data type: `Any` -Default value: `undef` +Default value: ``undef`` + +## Data types + +### `Python::Loglevel` + +A version type to match all valid versions for python + +Alias of `Enum['debug', 'info', 'warning', 'error', 'critical']` + +### `Python::Provider` + +A version type to match all valid versions for python + +Alias of `Enum['pip', 'scl', 'rhscl', 'anaconda', '']` + +### `Python::Umask` + +A version type to match all valid versions for python + +Alias of `Pattern[/[0-7]{1,4}/]` + +### `Python::Version` + +A version type to 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/]` diff --git a/manifests/dotfile.pp b/manifests/dotfile.pp index e42106c1..7fc0e7c3 100644 --- a/manifests/dotfile.pp +++ b/manifests/dotfile.pp @@ -24,11 +24,11 @@ # define python::dotfile ( Enum['absent', 'present'] $ensure = 'present', - String[1] $filename = $title, - String[1] $owner = 'root', - String[1] $group = 'root', - Stdlib::Filemode $mode = '0644', - Hash $config = {}, + String[1] $filename = $title, + String[1] $owner = 'root', + String[1] $group = 'root', + Stdlib::Filemode $mode = '0644', + Hash $config = {}, ) { $parent_dir = dirname($filename) diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index d9625a04..4a817163 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -34,26 +34,26 @@ # } # define python::gunicorn ( - Stdlib::Absolutepath $dir, - Enum['present', 'absent'] $ensure = present, - $config_dir = '/etc/gunicorn.d', - $manage_config_dir = false, - $virtualenv = false, - Enum['wsgi', 'django'] $mode = 'wsgi', - $bind = false, - $environment = false, - $owner = 'www-data', - $group = 'www-data', - $appmodule = 'app:app', - $osenv = false, - $timeout = 30, - $workers = false, - $access_log_format = false, - $accesslog = false, - $errorlog = false, - Enum['debug', 'info', 'warning', 'error', 'critical'] $log_level = 'error', - $template = 'python/gunicorn.erb', - $args = [], + Stdlib::Absolutepath $dir, + Enum['present', 'absent'] $ensure = present, + Stdlib::Absolutepath $config_dir = '/etc/gunicorn.d', + Booloean $manage_config_dir = false, + Variant[Boolean,Stdlib::Absolutepath] $virtualenv = false, + Enum['wsgi', 'django'] $mode = 'wsgi', + Variant[String[1],Boolean] $bind = false, + Variant[String[1],Boolean] $environment = false, + String[1] $owner = 'www-data', + String[1] $group = 'www-data', + String[1] $appmodule = 'app:app', + Variant[Boolean,Hash] $osenv = false, + Integer $timeout = 30, + Variant[Boolean,Integer] $workers = false, + Variant[Boolean,String[1]] $access_log_format = false, + Variant[Boolean,Stdlib::Absolutepath] $accesslog = false, + Variant[Boolean,Stdlib::Absolutepath] $errorlog = false, + Python::Loglevel $log_level = 'error', + String[1] $template = 'python/gunicorn.erb', + Array $args = [], ) { if $manage_config_dir { file { $config_dir: diff --git a/manifests/init.pp b/manifests/init.pp index 468725be..7642eae5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,30 +36,29 @@ # } # class python ( - Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure, - $version = $python::params::version, - Enum['absent', 'present', 'latest'] $pip = $python::params::pip, - Enum['absent', 'present', 'latest'] $dev = $python::params::dev, - Enum['absent', 'present', 'latest'] $virtualenv = $python::params::virtualenv, - Enum['absent', 'present', 'latest'] $gunicorn = $python::params::gunicorn, - Boolean $manage_gunicorn = $python::params::manage_gunicorn, - Boolean $manage_python_package = $python::params::manage_python_package, - Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package, - Boolean $manage_pip_package = $python::params::manage_pip_package, - $gunicorn_package_name = $python::params::gunicorn_package_name, - Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']] $provider = $python::params::provider, - $valid_versions = $python::params::valid_versions, - Hash $python_pips = {}, - Hash $python_virtualenvs = {}, - Hash $python_pyvenvs = {}, - Hash $python_requirements = {}, - Hash $python_dotfiles = {}, - Boolean $use_epel = $python::params::use_epel, - $rhscl_use_public_repository = $python::params::rhscl_use_public_repository, - Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url, - Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path, - Boolean $manage_scl = $python::params::manage_scl, - Optional[Pattern[/[0-7]{1,4}/]] $umask = undef, + Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure, + Python::Version $version = $python::params::version, + Enum['absent', 'present', 'latest'] $pip = $python::params::pip, + Enum['absent', 'present', 'latest'] $dev = $python::params::dev, + Enum['absent', 'present', 'latest'] $virtualenv = $python::params::virtualenv, + Enum['absent', 'present', 'latest'] $gunicorn = $python::params::gunicorn, + Boolean $manage_gunicorn = $python::params::manage_gunicorn, + Boolean $manage_python_package = $python::params::manage_python_package, + Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package, + Boolean $manage_pip_package = $python::params::manage_pip_package, + Strng[1] $gunicorn_package_name = $python::params::gunicorn_package_name, + Optional[Python::Provider] $provider = $python::params::provider, + Hash $python_pips = {}, + Hash $python_virtualenvs = {}, + Hash $python_pyvenvs = {}, + Hash $python_requirements = {}, + Hash $python_dotfiles = {}, + Boolean $use_epel = $python::params::use_epel, + Boolean $rhscl_use_public_repository = $python::params::rhscl_use_public_repository, + Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url, + Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path, + Boolean $manage_scl = $python::params::manage_scl, + Optional[Python::Umask] $umask = undef, ) inherits python::params { $exec_prefix = $provider ? { 'scl' => "/usr/bin/scl enable ${version} -- ", @@ -67,11 +66,6 @@ default => '', } - unless $version =~ Pattern[/\A(python)?[0-9](\.?[0-9])*/, - /\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] { - fail("version needs to be pypy, system or a version string like '36', '3.6' or 'python3.6' )") - } - # Module compatibility check $compatible = ['Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX'] if ! ($facts['os']['family'] in $compatible) { diff --git a/manifests/pip.pp b/manifests/pip.pp index 8f09c95d..f5112b92 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -48,26 +48,26 @@ # } # define python::pip ( - String $pkgname = $name, - Variant[Enum[present, absent, latest], String[1]] $ensure = present, - Variant[Enum['system'], Stdlib::Absolutepath] $virtualenv = 'system', - String[1] $pip_provider = 'pip', - Variant[Boolean, String] $url = false, - String[1] $owner = 'root', - $group = getvar('python::params::group'), - $umask = undef, - $index = false, - Optional[Stdlib::HTTPUrl] $proxy = undef, - $egg = false, - Boolean $editable = false, - $environment = [], - $extras = [], - String $install_args = '', - String $uninstall_args = '', - Numeric $timeout = 1800, - String[1] $log_dir = '/tmp', - Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], - String[1] $exec_provider = 'shell', + String[1] $pkgname = $name, + Variant[Enum[present, absent, latest], String[1]] $ensure = present, + Variant[Enum['system'], Stdlib::Absolutepath] $virtualenv = 'system', + String[1] $pip_provider = 'pip', + Variant[Boolean, String] $url = false, + String[1] $owner = 'root', + Optional[String[1]] $group = getvar('python::params::group'), + Optional[Python::Umask] $umask = undef, + Variant[Boolean,String[1]] $index = false, + Optional[Stdlib::HTTPUrl] $proxy = undef, + Any $egg = false, + Boolean $editable = false, + Array $environment = [], + Array $extras = [], + String $install_args = '', + String $uninstall_args = '', + Numeric $timeout = 1800, + String[1] $log_dir = '/tmp', + Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + String[1] $exec_provider = 'shell', ) { $python_provider = getparam(Class['python'], 'provider') $python_version = getparam(Class['python'], 'version') diff --git a/manifests/pip/bootstrap.pp b/manifests/pip/bootstrap.pp index 1b69c8ae..19848e63 100644 --- a/manifests/pip/bootstrap.pp +++ b/manifests/pip/bootstrap.pp @@ -5,15 +5,15 @@ # @param manage_python if python module will manage deps # @param http_proxy Proxy server to use for outbound connections. # -# @example +# @example # class { 'python::pip::bootstrap': # version => 'pip', # } class python::pip::bootstrap ( - Enum['pip', 'pip3'] $version = 'pip', - Variant[Boolean, String] $manage_python = false, - Optional[Stdlib::HTTPUrl] $http_proxy = undef, - String[1] $exec_provider = 'shell', + Enum['pip', 'pip3'] $version = 'pip', + Variant[Boolean, String] $manage_python = false, + Optional[Stdlib::HTTPUrl] $http_proxy = undef, + String[1] $exec_provider = 'shell', ) inherits python::params { if $manage_python { include python diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 5b0c91f3..06148e20 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -22,15 +22,15 @@ # } # define python::pyvenv ( - $ensure = present, - $version = 'system', - $systempkgs = false, - $venv_dir = $name, - $owner = 'root', - $group = 'root', - $mode = '0755', - $path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'], - $environment = [], + $ensure = present, + $version = 'system', + $systempkgs = false, + $venv_dir = $name, + $owner = 'root', + $group = 'root', + $mode = '0755', + $path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'], + $environment = [], ) { include python diff --git a/manifests/requirements.pp b/manifests/requirements.pp index e0fbcf2b..e448f983 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -26,21 +26,21 @@ # } # define python::requirements ( - $requirements = $name, - $virtualenv = 'system', - Enum['pip', 'pip3'] $pip_provider = 'pip', - $owner = 'root', - $group = 'root', - Optional[Stdlib::HTTPUrl] $proxy = undef, - $src = false, - $environment = [], - $forceupdate = false, - $cwd = undef, - $extra_pip_args = '', - $manage_requirements = true, - $fix_requirements_owner = true, - $log_dir = '/tmp', - $timeout = 1800, + String[1] $requirements = $name, + Variant[Enum['system'],Stdlib::Absolutepath] $virtualenv = 'system', + Enum['pip', 'pip3'] $pip_provider = 'pip', + String[1] $owner = 'root', + String[1] $group = 'root', + Optional[Stdlib::HTTPUrl] $proxy = undef, + Any $src = false, + Array $environment = [], + Boolean $forceupdate = false, + Stdlib::Absolutepath $cwd = undef, + String $extra_pip_args = '', + Boolean $manage_requirements = true, + Boolean $fix_requirements_owner = true, + Stdlib::Absolutepath $log_dir = '/tmp', + Integer $timeout = 1800, ) { include python diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index e19cfa3b..e098b366 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -31,25 +31,25 @@ # } # define python::virtualenv ( - $ensure = 'present', - $version = 'system', - $requirements = false, - $systempkgs = false, - $venv_dir = $name, - $ensure_venv_dir = true, - $distribute = true, - $index = false, - $owner = 'root', - $group = 'root', - $mode = '0755', - Optional[Stdlib::HTTPUrl] $proxy = undef, - $environment = [], - $path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'], - $cwd = undef, - $timeout = 1800, - $pip_args = '', - $extra_pip_args = '', - $virtualenv = undef, + $ensure = 'present', + $version = 'system', + $requirements = false, + $systempkgs = false, + $venv_dir = $name, + $ensure_venv_dir = true, + $distribute = true, + $index = false, + $owner = 'root', + $group = 'root', + $mode = '0755', + $proxy = undef, + $environment = [], + $path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'], + $cwd = undef, + $timeout = 1800, + $pip_args = '', + $extra_pip_args = '', + $virtualenv = undef, ) { include python $python_provider = getparam(Class['python'], 'provider') diff --git a/types/loglevel.pp b/types/loglevel.pp new file mode 100644 index 00000000..a7911a54 --- /dev/null +++ b/types/loglevel.pp @@ -0,0 +1,3 @@ +# @summary A version type to match all valid versions for python +# +type Python::Loglevel = Enum['debug', 'info', 'warning', 'error', 'critical'] diff --git a/types/provider.pp b/types/provider.pp new file mode 100644 index 00000000..d7ad998b --- /dev/null +++ b/types/provider.pp @@ -0,0 +1,3 @@ +# @summary A version type to match all valid versions for python +# +type Python::Provider = Enum['pip', 'scl', 'rhscl', 'anaconda', ''] diff --git a/types/umask.pp b/types/umask.pp new file mode 100644 index 00000000..a5bf20da --- /dev/null +++ b/types/umask.pp @@ -0,0 +1,3 @@ +# @summary A version type to match all valid versions for python +# +type Python::Umask = Pattern[/[0-7]{1,4}/] diff --git a/types/version.pp b/types/version.pp new file mode 100644 index 00000000..e0023aef --- /dev/null +++ b/types/version.pp @@ -0,0 +1,8 @@ +# @summary A version type to match all valid versions for python +# +type Python::Version = Pattern[ + /\A(python)?[0-9](\.?[0-9])*/, + /\Apypy\Z/, + /\Asystem\Z/, + /\Arh-python[0-9]{2}(?:-python)?\Z/ +]