From 494e027765ad2704e2c7901d70225462f3c39217 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Sun, 21 Oct 2018 23:55:14 -0400 Subject: [PATCH] pip type updates - defined data types, updated for forge reference --- REFERENCE.md | 1253 ++++++++++++++++++++++++++++++++++++++++++++++ manifests/pip.pp | 134 ++--- 2 files changed, 1300 insertions(+), 87 deletions(-) create mode 100644 REFERENCE.md diff --git a/REFERENCE.md b/REFERENCE.md new file mode 100644 index 00000000..ac984f4f --- /dev/null +++ b/REFERENCE.md @@ -0,0 +1,1253 @@ +# Reference + + +## Table of Contents + +**Classes** + +* [`python`](#python): +* [`python::config`](#pythonconfig): +* [`python::install`](#pythoninstall): == Class: python::install Installs core python packages, === Examples include python::install === Authors Sergey Stankevich Ashley Penne +* [`python::params`](#pythonparams): == Class: python::params The python Module default configuration settings. + +**Defined types** + +* [`python::dotfile`](#pythondotfile): == Define: python::dotfile Manages any python dotfiles with a simple config hash. === Parameters [*ensure*] present|absent. Default: pres +* [`python::gunicorn`](#pythongunicorn): == Define: python::gunicorn Manages Gunicorn virtual hosts. === Parameters [*ensure*] present|absent. Default: present [*config_dir*] C +* [`python::pip`](#pythonpip): Installs and manages packages from pip. +* [`python::pyvenv`](#pythonpyvenv): [*environment*] Optionally specify environment variables for pyvenv === Examples python::venv { '/var/www/project1': ensure => pres +* [`python::requirements`](#pythonrequirements): == Define: python::requirements Installs and manages Python packages from requirements file. === Parameters [*requirements*] Path to the +* [`python::virtualenv`](#pythonvirtualenv): == Define: python::virtualenv Creates Python virtualenv. === Parameters [*ensure*] present|absent. Default: present [*version*] Python + +## Classes + +### python + +The python class. + +#### Parameters + +The following parameters are available in the `python` class. + +##### `ensure` + +Data type: `Enum['absent', 'present', 'latest']` + + + +Default value: $python::params::ensure + +##### `version` + +Data type: `Any` + + + +Default value: $python::params::version + +##### `pip` + +Data type: `Enum['absent', 'present', 'latest']` + + + +Default value: $python::params::pip + +##### `dev` + +Data type: `Any` + + + +Default value: $python::params::dev + +##### `virtualenv` + +Data type: `Enum['absent', 'present', 'latest']` + + + +Default value: $python::params::virtualenv + +##### `gunicorn` + +Data type: `Enum['absent', 'present', 'latest']` + + + +Default value: $python::params::gunicorn + +##### `manage_gunicorn` + +Data type: `Boolean` + + + +Default value: $python::params::manage_gunicorn + +##### `gunicorn_package_name` + +Data type: `Any` + + + +Default value: $python::params::gunicorn_package_name + +##### `provider` + +Data type: `Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']]` + + + +Default value: $python::params::provider + +##### `valid_versions` + +Data type: `Any` + + + +Default value: $python::params::valid_versions + +##### `python_pips` + +Data type: `Hash` + + + +Default value: { } + +##### `python_virtualenvs` + +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: { } + +##### `use_epel` + +Data type: `Boolean` + + + +Default value: $python::params::use_epel + +##### `rhscl_use_public_repository` + +Data type: `Any` + + + +Default value: $python::params::rhscl_use_public_repository + +##### `anaconda_installer_url` + +Data type: `Stdlib::Httpurl` + + + +Default value: $python::params::anaconda_installer_url + +##### `anaconda_install_path` + +Data type: `Stdlib::Absolutepath` + + + +Default value: $python::params::anaconda_install_path + +### python::config + +The python::config class. + +### python::install + +== Class: python::install + +Installs core python packages, + +=== Examples + +include python::install + +=== Authors + +Sergey Stankevich +Ashley Penney +Fotis Gimian +Garrett Honeycutt + +### python::params + +== Class: python::params + +The python Module default configuration settings. + +## Defined types + +### python::dotfile + +== Define: python::dotfile + +Manages any python dotfiles with a simple config hash. + +=== Parameters + +[*ensure*] + present|absent. Default: present + +[*filename*] + Filename. Default: $title + +[*mode*] + File mode. Default: 0644 + +[*owner*] +[*group*] + Owner/group. Default: `root`/`root` + +[*config*] + Config hash. This will be expanded to an ini-file. Default: {} + +=== Examples + +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: `Any` + + + +Default value: 'present' + +##### `filename` + +Data type: `Any` + + + +Default value: $title + +##### `owner` + +Data type: `Any` + + + +Default value: 'root' + +##### `group` + +Data type: `Any` + + + +Default value: 'root' + +##### `mode` + +Data type: `Any` + + + +Default value: '0644' + +##### `config` + +Data type: `Any` + + + +Default value: {} + +### python::gunicorn + +== Define: python::gunicorn + +Manages Gunicorn virtual hosts. + +=== Parameters + +[*ensure*] + present|absent. Default: present + +[*config_dir*] + Configure the gunicorn config directory path. Default: /etc/gunicorn.d + +[*manage_config_dir*] + Set if the gunicorn config directory should be created. Default: false + +[*virtualenv*] + Run in virtualenv, specify directory. Default: disabled + +[*mode*] + Gunicorn mode. + wsgi|django. Default: wsgi + +[*dir*] + Application directory. + +[*bind*] + Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. + Default: system-wide: unix:/tmp/gunicorn-$name.socket + virtualenv: unix:${virtualenv}/${name}.socket + +[*environment*] + Set ENVIRONMENT variable. Default: none + +[*appmodule*] + Set the application module name for gunicorn to load when not using Django. + Default: app:app + +[*osenv*] + Allows setting environment variables for the gunicorn service. Accepts a + hash of 'key': 'value' pairs. + Default: false + +[*timeout*] + Allows setting the gunicorn idle worker process time before being killed. + The unit of time is seconds. + Default: 30 + +[*template*] + Which ERB template to use. Default: python/gunicorn.erb + +[*args*] + Custom arguments to add in gunicorn config file. Default: [] + +=== Examples + +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', +} + +=== Authors + +Sergey Stankevich +Ashley Penney +Marc Fournier + +#### Parameters + +The following parameters are available in the `python::gunicorn` defined type. + +##### `ensure` + +Data type: `Any` + + + +Default value: present + +##### `config_dir` + +Data type: `Any` + + + +Default value: '/etc/gunicorn.d' + +##### `manage_config_dir` + +Data type: `Any` + + + +Default value: `false` + +##### `virtualenv` + +Data type: `Any` + + + +Default value: `false` + +##### `mode` + +Data type: `Any` + + + +Default value: 'wsgi' + +##### `dir` + +Data type: `Any` + + + +Default value: `false` + +##### `bind` + +Data type: `Any` + + + +Default value: `false` + +##### `environment` + +Data type: `Any` + + + +Default value: `false` + +##### `owner` + +Data type: `Any` + + + +Default value: 'www-data' + +##### `group` + +Data type: `Any` + + + +Default value: 'www-data' + +##### `appmodule` + +Data type: `Any` + + + +Default value: 'app:app' + +##### `osenv` + +Data type: `Any` + + + +Default value: `false` + +##### `timeout` + +Data type: `Any` + + + +Default value: 30 + +##### `workers` + +Data type: `Any` + + + +Default value: `false` + +##### `access_log_format` + +Data type: `Any` + + + +Default value: `false` + +##### `accesslog` + +Data type: `Any` + + + +Default value: `false` + +##### `errorlog` + +Data type: `Any` + + + +Default value: `false` + +##### `log_level` + +Data type: `Any` + + + +Default value: 'error' + +##### `template` + +Data type: `Any` + + + +Default value: 'python/gunicorn.erb' + +##### `args` + +Data type: `Any` + + + +Default value: [] + +### 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/', +} +``` + +#### Parameters + +The following parameters are available in the `python::pip` defined type. + +##### `name` + +must be unique + +##### `pkgname` + +Data type: `String` + +name of the package. + +Default value: $name + +##### `ensure` + +Data type: `Optional[Enum[present, absent, latest]]` + +Require pip to be available. + +Default value: present + +##### `virtualenv` + +Data type: `Optional[String]` + +virtualenv to run pip in. + +Default value: 'system' + +##### `pip_provider` + +Data type: `Optional[Enum['pip', 'pip3']]` + +version of pip you wish to use. + +Default value: 'pip' + +##### `url` + +Data type: `Optional[Variant[Boolean, String]]` + +URL to install from. + +Default value: `false` + +##### `owner` + +Data type: `Optional[String]` + +The owner of the virtualenv being manipulated. + +Default value: 'root' + +##### `group` + +Data type: `Optional[String]` + +The group of the virtualenv being manipulated. + +Default value: 'root' + +##### `index` + +Data type: `Any` + +Base URL of Python package index. + +Default value: `false` + +##### `proxy` + +Data type: `Optional[Variant[Boolean, String]]` + +Proxy server to use for outbound connections. + +Default value: `false` + +##### `editable` + +Data type: `Optional[Boolean]` + +If true the package is installed as an editable resource. + +Default value: `false` + +##### `environment` + +Data type: `Any` + +Additional environment variables required to install the packages. + +Default value: [] + +##### `extras` + +Data type: `Any` + +Extra features provided by the package which should be installed. + +Default value: [] + +##### `timeout` + +Data type: `Optional[Numeric]` + +The maximum time in seconds the "pip install" command should take. + +Default value: 1800 + +##### `install_args` + +Data type: `Optional[String]` + +Any additional installation arguments that will be supplied when running pip install. + +Default value: '' + +##### `uninstall_args` + +Data type: `Optional[String]` + +Any additional arguments that will be supplied when running pip uninstall. + +Default value: '' + +##### `log_dir` + +Data type: `Optional[String]` + +Log directory + +Default value: '/tmp' + +##### `egg` + +Data type: `Any` + + + +Default value: `false` + +##### `umask` + +Data type: `Any` + + + +Default value: `undef` + +##### `egg` + + + +Default value: `false` + +##### `path` + +Data type: `Optional[Array[String]]` + + + +Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'] + +### python::pyvenv + +[*environment*] +Optionally specify environment variables for pyvenv + +=== Examples + +python::venv { '/var/www/project1': + ensure => present, + version => 'system', + systempkgs => true, +} + +=== Authors + +Sergey Stankevich +Ashley Penney +Marc Fournier +Fotis Gimian +Seth Cleveland + +#### Parameters + +The following parameters are available in the `python::pyvenv` defined type. + +##### `ensure` + +Data type: `Any` + + + +Default value: present + +##### `version` + +Data type: `Any` + + + +Default value: 'system' + +##### `systempkgs` + +Data type: `Any` + + + +Default value: `false` + +##### `venv_dir` + +Data type: `Any` + + + +Default value: $name + +##### `owner` + +Data type: `Any` + + + +Default value: 'root' + +##### `group` + +Data type: `Any` + + + +Default value: 'root' + +##### `mode` + +Data type: `Any` + + + +Default value: '0755' + +##### `path` + +Data type: `Any` + + + +Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] + +##### `environment` + +Data type: `Any` + + + +Default value: [] + +### python::requirements + +== Define: python::requirements + +Installs and manages Python packages from requirements file. + +=== Parameters + +[*requirements*] + Path to the requirements file. Defaults to the resource name + +[*virtualenv*] + virtualenv to run pip in. Default: system-wide + +[*pip_provider*] + version of pip you wish to use. Default: pip + +[*owner*] + The owner of the virtualenv being manipulated. Default: root + +[*group*] + The group relating to the virtualenv being manipulated. Default: root + +[*proxy*] + Proxy server to use for outbound connections. Default: none + +[*src*] +Pip --src parameter; if the requirements file contains --editable resources, +this parameter specifies where they will be installed. See the pip +documentation for more. Default: none (i.e. use the pip default). + +[*environment*] + Additional environment variables required to install the packages. Default: none + +[*forceupdate*] + 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) + +[*cwd*] + The directory from which to run the "pip install" command. Default: undef + +[*extra_pip_args*] +Extra arguments to pass to pip after the requirements file + +[*manage_requirements*] +Create the requirements file if it doesn't exist. Default: true + +[*fix_requirements_owner*] +Change owner and group of requirements file. Default: true + +[*log_dir*] +String. Log directory. + +[*timeout*] + The maximum time in seconds the "pip install" command should take. Default: 1800 + +=== Examples + +python::requirements { '/var/www/project1/requirements.txt': + virtualenv => '/var/www/project1', + proxy => 'http://proxy.domain.com:3128', +} + +=== Authors + +Sergey Stankevich +Ashley Penney +Fotis Gimian +Daniel Quackenbush + +#### Parameters + +The following parameters are available in the `python::requirements` defined type. + +##### `requirements` + +Data type: `Any` + + + +Default value: $name + +##### `virtualenv` + +Data type: `Any` + + + +Default value: 'system' + +##### `pip_provider` + +Data type: `Enum['pip', 'pip3']` + + + +Default value: 'pip' + +##### `owner` + +Data type: `Any` + + + +Default value: 'root' + +##### `group` + +Data type: `Any` + + + +Default value: 'root' + +##### `proxy` + +Data type: `Any` + + + +Default value: `false` + +##### `src` + +Data type: `Any` + + + +Default value: `false` + +##### `environment` + +Data type: `Any` + + + +Default value: [] + +##### `forceupdate` + +Data type: `Any` + + + +Default value: `false` + +##### `cwd` + +Data type: `Any` + + + +Default value: `undef` + +##### `extra_pip_args` + +Data type: `Any` + + + +Default value: '' + +##### `manage_requirements` + +Data type: `Any` + + + +Default value: `true` + +##### `fix_requirements_owner` + +Data type: `Any` + + + +Default value: `true` + +##### `log_dir` + +Data type: `Any` + + + +Default value: '/tmp' + +##### `timeout` + +Data type: `Any` + + + +Default value: 1800 + +### python::virtualenv + +== Define: python::virtualenv + +Creates Python virtualenv. + +=== Parameters + +[*ensure*] + present|absent. Default: present + +[*version*] + Python version to use. Default: system default + +[*requirements*] + Path to pip requirements.txt file. Default: none + +[*systempkgs*] + Copy system site-packages into virtualenv. Default: don't + If virtualenv version < 1.7 this flag has no effect since + +[*venv_dir*] + Directory to install virtualenv to. Default: $name + +[*ensure_venv_dir*] +Create $venv_dir. Default: true + +[*distribute*] + Include distribute in the virtualenv. Default: true + +[*index*] + Base URL of Python package index. Default: none (http://pypi.python.org/simple/) + +[*owner*] + The owner of the virtualenv being manipulated. Default: root + +[*group*] + The group relating to the virtualenv being manipulated. Default: root + +[*mode*] +Optionally specify directory mode. Default: 0755 + +[*proxy*] + Proxy server to use for outbound connections. Default: none + +[*environment*] + Additional environment variables required to install the packages. Default: none + +[*path*] + Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] + +[*cwd*] + The directory from which to run the "pip install" command. Default: undef + +[*timeout*] + The maximum time in seconds the "pip install" command should take. Default: 1800 + +[*pip_args*] + Arguments to pass to pip during initialization. Default: blank + +[*extra_pip_args*] + Extra arguments to pass to pip after requirements file. Default: blank + +=== Examples + +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/', +} + +=== Authors + +Sergey Stankevich +Shiva Poudel + +#### Parameters + +The following parameters are available in the `python::virtualenv` defined type. + +##### `ensure` + +Data type: `Any` + + + +Default value: present + +##### `version` + +Data type: `Any` + + + +Default value: 'system' + +##### `requirements` + +Data type: `Any` + + + +Default value: `false` + +##### `systempkgs` + +Data type: `Any` + + + +Default value: `false` + +##### `venv_dir` + +Data type: `Any` + + + +Default value: $name + +##### `ensure_venv_dir` + +Data type: `Any` + + + +Default value: `true` + +##### `distribute` + +Data type: `Any` + + + +Default value: `true` + +##### `index` + +Data type: `Any` + + + +Default value: `false` + +##### `owner` + +Data type: `Any` + + + +Default value: 'root' + +##### `group` + +Data type: `Any` + + + +Default value: 'root' + +##### `mode` + +Data type: `Any` + + + +Default value: '0755' + +##### `proxy` + +Data type: `Any` + + + +Default value: `false` + +##### `environment` + +Data type: `Any` + + + +Default value: [] + +##### `path` + +Data type: `Any` + + + +Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] + +##### `cwd` + +Data type: `Any` + + + +Default value: `undef` + +##### `timeout` + +Data type: `Any` + + + +Default value: 1800 + +##### `pip_args` + +Data type: `Any` + + + +Default value: '' + +##### `extra_pip_args` + +Data type: `Any` + + + +Default value: '' + +##### `virtualenv` + +Data type: `Any` + + + +Default value: `undef` + diff --git a/manifests/pip.pp b/manifests/pip.pp index e7aa6efe..fc80fe4c 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -1,96 +1,56 @@ -# == Define: python::pip -# -# Installs and manages packages from pip. -# -# === Parameters -# -# [*name] -# must be unique -# -# [*pkgname] -# name of the package. If pkgname is not specified, use name (title) instead. -# -# [*ensure*] -# present|absent. Default: present -# -# [*virtualenv*] -# virtualenv to run pip in. -# -# [*pip_provider*] -# version of pip you wish to use. Default: pip -# -# [*url*] -# URL to install from. Default: none -# -# [*owner*] -# The owner of the virtualenv being manipulated. Default: root -# -# [*group*] -# The group of the virtualenv being manipulated. Default: root -# -# [*index*] -# Base URL of Python package index. Default: none (http://pypi.python.org/simple/) -# -# [*proxy*] -# Proxy server to use for outbound connections. Default: none -# -# [*editable*] -# Boolean. If true the package is installed as an editable resource. -# -# [*environment*] -# Additional environment variables required to install the packages. Default: none -# -# [*extras*] -# Extra features provided by the package which should be installed. Default: none -# -# [*timeout*] -# The maximum time in seconds the "pip install" command should take. Default: 1800 -# -# [*install_args*] -# String. Any additional installation arguments that will be supplied -# when running pip install. -# -# [*uninstall_args*] -# String. Any additional arguments that will be supplied when running -# pip uninstall. -# -# [*log_dir*] -# String. Log directory. + # -# === Examples +# @summary 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/', -# } +# @param name must be unique +# @param pkgname name of the package. +# @param ensure Require pip to be available. +# @param virtualenv virtualenv to run pip in. +# @param pip_provider version of pip you wish to use. +# @param url URL to install from. +# @param owner The owner of the virtualenv being manipulated. +# @param group The group of the virtualenv being manipulated. +# @param index Base URL of Python package index. +# @param proxy Proxy server to use for outbound connections. +# @param editable If true the package is installed as an editable resource. +# @param environment Additional environment variables required to install the packages. +# @param extras Extra features provided by the package which should be installed. +# @param timeout The maximum time in seconds the "pip install" command should take. +# @param install_args Any additional installation arguments that will be supplied when running pip install. +# @param uninstall_args Any additional arguments that will be supplied when running pip uninstall. +# @param log_dir Log directory +# @param egg +# @param umask +# @param egg # -# === Authors +# @example 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/', +# } # -# Sergey Stankevich -# Fotis Gimian -# Daniel Quackenbush # define python::pip ( - $pkgname = $name, - $ensure = present, - $virtualenv = 'system', - Enum['pip', 'pip3'] $pip_provider = 'pip', - $url = false, - $owner = 'root', - $group = 'root', - $umask = undef, - $index = false, - $proxy = false, - $egg = false, - $editable = false, - $environment = [], - $extras = [], - $install_args = '', - $uninstall_args = '', - $timeout = 1800, - $log_dir = '/tmp', - $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + String $pkgname = $name, + Optional[Enum[present, absent, latest]] $ensure = present, + Optional[String] $virtualenv = 'system', + Optional[Enum['pip', 'pip3']] $pip_provider = 'pip', + Optional[Variant[Boolean, String]] $url = false, + Optional[String] $owner = 'root', + Optional[String] $group = 'root', + $umask = undef, + $index = false, + Optional[Variant[Boolean, String]] $proxy = false, + $egg = false, + Optional[Boolean] $editable = false, + $environment = [], + $extras = [], + Optional[String] $install_args = '', + Optional[String] $uninstall_args = '', + Optional[Numeric] $timeout = 1800, + Optional[String] $log_dir = '/tmp', + Optional[Array[String]] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], ) { $python_provider = getparam(Class['python'], 'provider') $python_version = getparam(Class['python'], 'version')