From 8bb994c1820b5dbd6ff5870d24bd1c23223b8ab6 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Mon, 22 Oct 2018 00:01:58 -0400 Subject: [PATCH 1/9] 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..b5fd1b6e --- /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: `Enum[present, absent, latest]` + +Require pip to be available. + +Default value: present + +##### `virtualenv` + +Data type: `String` + +virtualenv to run pip in. + +Default value: 'system' + +##### `pip_provider` + +Data type: `Enum['pip', 'pip3']` + +version of pip you wish to use. + +Default value: 'pip' + +##### `url` + +Data type: `Variant[Boolean, String]` + +URL to install from. + +Default value: `false` + +##### `owner` + +Data type: `String` + +The owner of the virtualenv being manipulated. + +Default value: 'root' + +##### `group` + +Data type: `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: `Variant[Boolean, String]` + +Proxy server to use for outbound connections. + +Default value: `false` + +##### `editable` + +Data type: `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: `Numeric` + +The maximum time in seconds the "pip install" command should take. + +Default value: 1800 + +##### `install_args` + +Data type: `String` + +Any additional installation arguments that will be supplied when running pip install. + +Default value: '' + +##### `uninstall_args` + +Data type: `String` + +Any additional arguments that will be supplied when running pip uninstall. + +Default value: '' + +##### `log_dir` + +Data type: `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: `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..04d956b8 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, + Enum[present, absent, latest] $ensure = present, + String $virtualenv = 'system', + Enum['pip', 'pip3'] $pip_provider = 'pip', + Variant[Boolean, String] $url = false, + String $owner = 'root', + String $group = 'root', + $umask = undef, + $index = false, + Variant[Boolean, String] $proxy = false, + $egg = false, + Boolean $editable = false, + $environment = [], + $extras = [], + String $install_args = '', + String $uninstall_args = '', + Numeric $timeout = 1800, + String $log_dir = '/tmp', + Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], ) { $python_provider = getparam(Class['python'], 'provider') $python_version = getparam(Class['python'], 'version') From 84f46b542bb2a9cd320966fd470ff4d6fb4df122 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Mon, 22 Oct 2018 00:36:20 -0400 Subject: [PATCH 2/9] Update forge reference.md documentation for remaning manifest files --- REFERENCE.md | 530 ++++++++++++++------------------------ manifests/config.pp | 15 +- manifests/dotfile.pp | 45 ++-- manifests/gunicorn.pp | 95 +++---- manifests/init.pp | 73 ++---- manifests/install.pp | 15 +- manifests/params.pp | 3 +- manifests/pyvenv.pp | 61 ++--- manifests/requirements.pp | 90 ++----- manifests/virtualenv.pp | 105 +++----- 10 files changed, 330 insertions(+), 702 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index b5fd1b6e..b16b5302 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -5,25 +5,39 @@ **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. +* [`python`](#python): Installs and manages python, python-dev, python-virtualenv and gunicorn. +* [`python::config`](#pythonconfig): Optionally installs the gunicorn service +* [`python::install`](#pythoninstall): Installs core python packages +* [`python::params`](#pythonparams): 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::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): [*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 +* [`python::pyvenv`](#pythonpyvenv): +* [`python::requirements`](#pythonrequirements): Installs and manages Python packages from requirements file. +* [`python::virtualenv`](#pythonvirtualenv): Creates Python virtualenv. ## Classes ### python -The python class. +Installs and manages python, python-dev, python-virtualenv and gunicorn. + +#### Examples + +##### ensure system python is installed, with pip,dev, virtualenv, and gunicorn packages present + +```puppet +class { 'python': + version => 'system', + pip => 'present', + dev => 'present', + virtualenv => 'present', + gunicorn => 'present', +} +``` #### Parameters @@ -33,7 +47,8 @@ The following parameters are available in the `python` class. Data type: `Enum['absent', 'present', 'latest']` - +Desired installation state for the Python package. +Allowed values: absent, present and latest Default value: $python::params::ensure @@ -41,7 +56,14 @@ 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 @@ -49,7 +71,8 @@ Default value: $python::params::version Data type: `Enum['absent', 'present', 'latest']` - +Desired installation state for python-pip. Boolean values are deprecated. +Allowed values: 'absent', 'present', 'latest' Default value: $python::params::pip @@ -57,7 +80,8 @@ Default value: $python::params::pip Data type: `Any` - +Desired installation state for python-dev. Boolean values are deprecated. +Allowed values: 'absent', 'present', 'latest' Default value: $python::params::dev @@ -65,7 +89,8 @@ Default value: $python::params::dev Data type: `Enum['absent', 'present', 'latest']` - +Desired installation state for python-virtualenv. Boolean values are deprecated +Allowed values: 'absent', 'present', 'latest Default value: $python::params::virtualenv @@ -73,7 +98,8 @@ Default value: $python::params::virtualenv Data type: `Enum['absent', 'present', 'latest']` - +Desired installation state for Gunicorn. Boolean values are deprecated. +Allowed values: 'absent', 'present', 'latest' Default value: $python::params::gunicorn @@ -81,25 +107,34 @@ Default value: $python::params::gunicorn Data type: `Boolean` - +Allow Installation / Removal of Gunicorn. Default: true Default value: $python::params::manage_gunicorn -##### `gunicorn_package_name` +##### `provider` -Data type: `Any` +Data type: `Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']]` +What provider to use for installation of the packages, except gunicorn and Python itself. +Allowed values: 'pip' +Default value: $python::params::provider -Default value: $python::params::gunicorn_package_name +##### `use_epel` -##### `provider` +Data type: `Boolean` -Data type: `Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']]` +to determine if the epel class is used. + +Default value: $python::params::use_epel +##### `gunicorn_package_name` +Data type: `Any` -Default value: $python::params::provider + + +Default value: $python::params::gunicorn_package_name ##### `valid_versions` @@ -149,14 +184,6 @@ Data type: `Hash` Default value: { } -##### `use_epel` - -Data type: `Boolean` - - - -Default value: $python::params::use_epel - ##### `rhscl_use_public_repository` Data type: `Any` @@ -183,28 +210,29 @@ Default value: $python::params::anaconda_install_path ### python::config -The python::config class. +Optionally installs the gunicorn service -### python::install +#### Examples -== Class: python::install +##### -Installs core python packages, +```puppet +include python::config +``` -=== Examples +### python::install -include python::install +Installs core python packages -=== Authors +#### Examples -Sergey Stankevich -Ashley Penney -Fotis Gimian -Garrett Honeycutt +##### -### python::params +```puppet +include python::install +``` -== Class: python::params +### python::params The python Module default configuration settings. @@ -212,30 +240,13 @@ The python Module default configuration settings. ### 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` +=== Examples -[*config*] - Config hash. This will be expanded to an ini-file. Default: {} +#### Examples -=== Examples +##### Create a pip config in /var/lib/jenkins/.pip/ +```puppet python::dotfile { '/var/lib/jenkins/.pip/pip.conf': ensure => present, owner => 'jenkins', @@ -247,6 +258,7 @@ python::dotfile { '/var/lib/jenkins/.pip/pip.conf': } } } +``` #### Parameters @@ -256,7 +268,7 @@ The following parameters are available in the `python::dotfile` defined type. Data type: `Any` - +present|absent. Default: present Default value: 'present' @@ -264,99 +276,51 @@ Default value: 'present' Data type: `Any` - +Filename. Default: $title Default value: $title -##### `owner` +##### `mode` Data type: `Any` +File mode. Default: 0644 +Default value: '0644' -Default value: 'root' - -##### `group` +##### `owner` Data type: `Any` - +user owner of dotfile Default value: 'root' -##### `mode` +##### `group` Data type: `Any` +group owner of dotfile - -Default value: '0644' +Default value: 'root' ##### `config` Data type: `Any` - +Config hash. This will be expanded to an ini-file. Default: {} 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 -=== Examples +##### run gunicorn on vhost in virtualenv /var/www/project1 +```puppet python::gunicorn { 'vhost': ensure => present, virtualenv => '/var/www/project1', @@ -371,12 +335,7 @@ python::gunicorn { 'vhost': timeout => 30, template => 'python/gunicorn.erb', } - -=== Authors - -Sergey Stankevich -Ashley Penney -Marc Fournier +``` #### Parameters @@ -394,7 +353,7 @@ Default value: present Data type: `Any` - +Configure the gunicorn config directory path. Default: /etc/gunicorn.d Default value: '/etc/gunicorn.d' @@ -402,7 +361,7 @@ Default value: '/etc/gunicorn.d' Data type: `Any` - +Set if the gunicorn config directory should be created. Default: false Default value: `false` @@ -410,7 +369,7 @@ Default value: `false` Data type: `Any` - +Run in virtualenv, specify directory. Default: disabled Default value: `false` @@ -418,7 +377,8 @@ Default value: `false` Data type: `Any` - +Gunicorn mode. +wsgi|django. Default: wsgi Default value: 'wsgi' @@ -426,7 +386,7 @@ Default value: 'wsgi' Data type: `Any` - +Application directory. Default value: `false` @@ -434,7 +394,9 @@ 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` @@ -442,67 +404,72 @@ Default value: `false` Data type: `Any` - +Set ENVIRONMENT variable. Default: none Default value: `false` -##### `owner` +##### `appmodule` Data type: `Any` +Set the application module name for gunicorn to load when not using Django. +Default: app:app +Default value: 'app:app' -Default value: 'www-data' - -##### `group` +##### `osenv` Data type: `Any` +Allows setting environment variables for the gunicorn service. Accepts a +hash of 'key': 'value' pairs. +Default: false +Default value: `false` -Default value: 'www-data' - -##### `appmodule` +##### `timeout` Data type: `Any` +Allows setting the gunicorn idle worker process time before being killed. +The unit of time is seconds. +Default: 30 +Default value: 30 -Default value: 'app:app' - -##### `osenv` +##### `template` Data type: `Any` +Which ERB template to use. Default: python/gunicorn.erb +Default value: 'python/gunicorn.erb' -Default value: `false` - -##### `timeout` +##### `args` Data type: `Any` +Custom arguments to add in gunicorn config file. Default: [] +Default value: [] -Default value: 30 - -##### `workers` +##### `owner` Data type: `Any` -Default value: `false` +Default value: 'www-data' -##### `access_log_format` +##### `group` Data type: `Any` -Default value: `false` +Default value: 'www-data' -##### `accesslog` +##### `workers` Data type: `Any` @@ -510,7 +477,7 @@ Data type: `Any` Default value: `false` -##### `errorlog` +##### `access_log_format` Data type: `Any` @@ -518,29 +485,29 @@ Data type: `Any` Default value: `false` -##### `log_level` +##### `accesslog` Data type: `Any` -Default value: 'error' +Default value: `false` -##### `template` +##### `errorlog` Data type: `Any` -Default value: 'python/gunicorn.erb' +Default value: `false` -##### `args` +##### `log_level` Data type: `Any` -Default value: [] +Default value: 'error' ### python::pip @@ -726,24 +693,19 @@ Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'] ### python::pyvenv -[*environment*] -Optionally specify environment variables for pyvenv +The python::pyvenv class. -=== Examples +#### Examples + +##### +```puppet python::venv { '/var/www/project1': ensure => present, version => 'system', systempkgs => true, } - -=== Authors - -Sergey Stankevich -Ashley Penney -Marc Fournier -Fotis Gimian -Seth Cleveland +``` #### Parameters @@ -761,7 +723,7 @@ Default value: present Data type: `Any` - +Python version to use. Default: system default Default value: 'system' @@ -769,7 +731,7 @@ Default value: 'system' Data type: `Any` - +Copy system site-packages into virtualenv Default value: `false` @@ -777,7 +739,7 @@ Default value: `false` Data type: `Any` - +Directory to install virtualenv to Default value: $name @@ -785,7 +747,7 @@ Default value: $name Data type: `Any` - +The owner of the virtualenv being manipulated Default value: 'root' @@ -793,7 +755,7 @@ Default value: 'root' Data type: `Any` - +The group relating to the virtualenv being manipulated Default value: 'root' @@ -801,7 +763,7 @@ Default value: 'root' Data type: `Any` - +Optionally specify directory mode Default value: '0755' @@ -809,7 +771,7 @@ Default value: '0755' Data type: `Any` - +Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] @@ -817,80 +779,24 @@ Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] Data type: `Any` - +Optionally specify environment variables for pyvenv 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 -=== 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', } - -=== Authors - -Sergey Stankevich -Ashley Penney -Fotis Gimian -Daniel Quackenbush +``` #### Parameters @@ -900,7 +806,7 @@ The following parameters are available in the `python::requirements` defined typ Data type: `Any` - +Path to the requirements file. Defaults to the resource name Default value: $name @@ -908,7 +814,7 @@ Default value: $name Data type: `Any` - +virtualenv to run pip in. Default: system-wide Default value: 'system' @@ -916,7 +822,7 @@ Default value: 'system' Data type: `Enum['pip', 'pip3']` - +version of pip you wish to use. Default: pip Default value: 'pip' @@ -924,7 +830,7 @@ Default value: 'pip' Data type: `Any` - +The owner of the virtualenv being manipulated. Default value: 'root' @@ -932,7 +838,7 @@ Default value: 'root' Data type: `Any` - +The group relating to the virtualenv being manipulated. Default value: 'root' @@ -940,7 +846,7 @@ Default value: 'root' Data type: `Any` - +Proxy server to use for outbound connections. Default value: `false` @@ -948,7 +854,7 @@ Default value: `false` Data type: `Any` - +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 value: `false` @@ -956,7 +862,7 @@ Default value: `false` Data type: `Any` - +Additional environment variables required to install the packages. Default value: [] @@ -964,7 +870,7 @@ 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` @@ -972,7 +878,7 @@ Default value: `false` Data type: `Any` - +The directory from which to run the "pip install" command. Default value: `undef` @@ -980,7 +886,7 @@ Default value: `undef` Data type: `Any` - +Extra arguments to pass to pip after the requirements file Default value: '' @@ -988,7 +894,7 @@ Default value: '' Data type: `Any` - +Create the requirements file if it doesn't exist. Default value: `true` @@ -996,7 +902,7 @@ Default value: `true` Data type: `Any` - +Change owner and group of requirements file. Default value: `true` @@ -1004,7 +910,7 @@ Default value: `true` Data type: `Any` - +Log directory. Default value: '/tmp' @@ -1012,75 +918,19 @@ Default value: '/tmp' Data type: `Any` - +The maximum time in seconds the "pip install" command should take. 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 -=== Examples +##### install a virtual env at /var/www/project1 +```puppet python::virtualenv { '/var/www/project1': ensure => present, version => 'system', @@ -1089,11 +939,7 @@ python::virtualenv { '/var/www/project1': systempkgs => true, index => 'http://www.example.com/simple/', } - -=== Authors - -Sergey Stankevich -Shiva Poudel +``` #### Parameters @@ -1111,7 +957,7 @@ Default value: present Data type: `Any` - +Python version to use. Default value: 'system' @@ -1119,7 +965,7 @@ Default value: 'system' Data type: `Any` - +Path to pip requirements.txt file Default value: `false` @@ -1127,7 +973,7 @@ Default value: `false` Data type: `Any` - +Copy system site-packages into virtualenv. Default: don't If virtualenv version < 1.7 this flag has no effect since Default value: `false` @@ -1135,7 +981,7 @@ Default value: `false` Data type: `Any` - +Directory to install virtualenv to Default value: $name @@ -1143,7 +989,7 @@ Default value: $name Data type: `Any` - +reate $venv_dir Default value: `true` @@ -1151,7 +997,7 @@ Default value: `true` Data type: `Any` - +Include distribute in the virtualenv Default value: `true` @@ -1159,7 +1005,7 @@ Default value: `true` Data type: `Any` - +Base URL of Python package index Default value: `false` @@ -1167,7 +1013,7 @@ Default value: `false` Data type: `Any` - +The owner of the virtualenv being manipulated Default value: 'root' @@ -1175,7 +1021,7 @@ Default value: 'root' Data type: `Any` - +The group relating to the virtualenv being manipulated Default value: 'root' @@ -1183,7 +1029,7 @@ Default value: 'root' Data type: `Any` - +Optionally specify directory mode Default value: '0755' @@ -1191,7 +1037,7 @@ Default value: '0755' Data type: `Any` - +Proxy server to use for outbound connections Default value: `false` @@ -1199,7 +1045,7 @@ Default value: `false` Data type: `Any` - +Additional environment variables required to install the packages Default value: [] @@ -1207,7 +1053,7 @@ Default value: [] Data type: `Any` - +Specifies the PATH variable Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] @@ -1215,7 +1061,7 @@ 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` @@ -1223,7 +1069,7 @@ Default value: `undef` Data type: `Any` - +The maximum time in seconds the "pip install" command should take Default value: 1800 @@ -1231,7 +1077,7 @@ Default value: 1800 Data type: `Any` - +Arguments to pass to pip during initialization Default value: '' @@ -1239,7 +1085,7 @@ Default value: '' Data type: `Any` - +Extra arguments to pass to pip after requirements file Default value: '' diff --git a/manifests/config.pp b/manifests/config.pp index 78a424b9..9788838d 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,18 +1,9 @@ -# == Define: python::config # -# Optionally installs the gunicorn service +# @summary Optionally installs the gunicorn service # -# === Examples +# @example +# include python::config # -# include python::config -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Fotis Gimian -# - class python::config { Class['python::install'] -> Python::Pip <| |> diff --git a/manifests/dotfile.pp b/manifests/dotfile.pp index 5bc70ae9..de1bd096 100644 --- a/manifests/dotfile.pp +++ b/manifests/dotfile.pp @@ -1,38 +1,27 @@ -# == Define: python::dotfile # -# Manages any python dotfiles with a simple config hash. +# @summary 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: {} +# @param ensure present|absent. Default: present +# @param filename Filename. Default: $title +# @param mode File mode. Default: 0644 +# @param owner user owner of dotfile +# @param group group owner of dotfile +# @param 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/ +# @example Create a pip config in /var/lib/jenkins/.pip/ +# python::dotfile { '/var/lib/jenkins/.pip/pip.conf': +# ensure => present, +# owner => 'jenkins', +# group => 'jenkins', +# config => { +# 'global' => { +# 'index-url => 'https://mypypi.acme.com/simple/' +# 'extra-index-url => https://pypi.risedev.at/simple/ +# } # } # } -# } # # define python::dotfile ( diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index bc996e6e..74e3251a 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -1,78 +1,43 @@ -# == Define: python::gunicorn # -# Manages Gunicorn virtual hosts. +# @summary 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. +# @param ensure +# @param config_dir Configure the gunicorn config directory path. Default: /etc/gunicorn.d +# @param manage_config_dir Set if the gunicorn config directory should be created. Default: false +# @param virtualenv Run in virtualenv, specify directory. Default: disabled +# @param mode Gunicorn mode. # wsgi|django. Default: wsgi -# -# [*dir*] -# Application directory. -# -# [*bind*] -# Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. +# @param dir Application directory. +# @param 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. +# @param environment Set ENVIRONMENT variable. Default: none +# @param 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 +# @param 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. +# @param 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 +# @param template Which ERB template to use. Default: python/gunicorn.erb +# @param args Custom arguments to add in gunicorn config file. Default: [] +# +# @example run gunicorn on vhost in virtualenv /var/www/project1 +# python::gunicorn { 'vhost': +# ensure => present, +# virtualenv => '/var/www/project1', +# mode => 'wsgi', +# dir => '/var/www/project1/current', +# bind => 'unix:/tmp/gunicorn.socket', +# environment => 'prod', +# owner => 'www-data', +# group => 'www-data', +# appmodule => 'app:app', +# osenv => { 'DBHOST' => 'dbserver.example.com' }, +# timeout => 30, +# template => 'python/gunicorn.erb', +# } # define python::gunicorn ( $ensure = present, diff --git a/manifests/init.pp b/manifests/init.pp index 258d0677..212ea90c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,17 +1,8 @@ -# == Class: python +# @summary Installs and manages python, python-dev, python-virtualenv and gunicorn. # -# Installs and manages python, python-dev, python-virtualenv and Gunicorn. -# -# === Parameters -# -# [*ensure*] -# Desired installation state for the Python package. Valid options are absent, -# present and latest. Default: present -# -# [*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. -# Default: system default +# @param ensure Desired installation state for the Python package. +# Allowed values: absent, present and latest +# @param 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/... @@ -19,54 +10,28 @@ # - '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. -# -# [*pip*] -# Desired installation state for python-pip. Boolean values are deprecated. -# Default: present +# @param pip Desired installation state for python-pip. Boolean values are deprecated. # Allowed values: 'absent', 'present', 'latest' -# -# [*dev*] -# Desired installation state for python-dev. Boolean values are deprecated. -# Default: absent +# @param dev Desired installation state for python-dev. Boolean values are deprecated. # Allowed values: 'absent', 'present', 'latest' -# -# [*virtualenv*] -# Desired installation state for python-virtualenv. Boolean values are -# deprecated. Default: absent +# @param virtualenv Desired installation state for python-virtualenv. Boolean values are deprecated # Allowed values: 'absent', 'present', 'latest -# -# [*gunicorn*] -# Desired installation state for Gunicorn. Boolean values are deprecated. -# Default: absent +# @param gunicorn Desired installation state for Gunicorn. Boolean values are deprecated. # Allowed values: 'absent', 'present', 'latest' -# -# [*manage_gunicorn*] -# Allow Installation / Removal of Gunicorn. Default: true -# -# [*provider*] -# What provider to use for installation of the packages, except gunicorn and -# Python itself. Default: system default provider +# @param manage_gunicorn Allow Installation / Removal of Gunicorn. Default: true +# @param provider What provider to use for installation of the packages, except gunicorn and Python itself. # Allowed values: 'pip' +# @param use_epel to determine if the epel class is used. # -# [*use_epel*] -# Boolean to determine if the epel class is used. Default: true -# -# === Examples -# -# class { 'python': -# version => 'system', -# pip => 'present', -# dev => 'present', -# virtualenv => 'present', -# gunicorn => 'present', -# } +# @example ensure system python is installed, with pip,dev, virtualenv, and gunicorn packages present +# class { 'python': +# version => 'system', +# pip => 'present', +# dev => 'present', +# virtualenv => 'present', +# gunicorn => 'present', +# } # -# === Authors -# -# Sergey Stankevich -# Garrett Honeycutt -# - class python ( Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure, $version = $python::params::version, diff --git a/manifests/install.pp b/manifests/install.pp index bddfd0ec..28505472 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,17 +1,8 @@ -# == Class: python::install # -# Installs core python packages, +# @summary Installs core python packages # -# === Examples -# -# include python::install -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Fotis Gimian -# Garrett Honeycutt +# @example +# include python::install # class python::install { diff --git a/manifests/params.pp b/manifests/params.pp index 5dacfc08..b68ed9ea 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,6 +1,5 @@ -# == Class: python::params # -# The python Module default configuration settings. +# @summary The python Module default configuration settings. # class python::params { $ensure = 'present' diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 587f1baa..b2e3d29a 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -1,51 +1,22 @@ -# == Define: python::pyvenv # -# Create a Python3 virtualenv using pyvenv. +# @summary Create a Python3 virtualenv using pyvenv. # -# === Parameters +# @param ensure +# @param version Python version to use. Default: system default +# @param systempkgs Copy system site-packages into virtualenv +# @param venv_dir Directory to install virtualenv to +# @param owner The owner of the virtualenv being manipulated +# @param group The group relating to the virtualenv being manipulated +# @param mode Optionally specify directory mode +# @param path Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] +# @param environment Optionally specify environment variables for pyvenv # -# [*ensure*] -# present|absent. Default: present -# -# [*version*] -# Python version to use. Default: system default -# -# [*systempkgs*] -# Copy system site-packages into virtualenv. Default: don't -# -# [*venv_dir*] -# Directory to install virtualenv to. Default: $name -# -# [*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 -# -# [*path*] -# Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] - -# [*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 +# @example +# python::venv { '/var/www/project1': +# ensure => present, +# version => 'system', +# systempkgs => true, +# } # define python::pyvenv ( $ensure = present, diff --git a/manifests/requirements.pp b/manifests/requirements.pp index ffdfd420..1127f5db 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -1,71 +1,27 @@ -# == 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 +# @summary Installs and manages Python packages from requirements file. +# +# @param requirements Path to the requirements file. Defaults to the resource name +# @param virtualenv virtualenv to run pip in. Default: system-wide +# @param pip_provider version of pip you wish to use. Default: pip +# @param owner The owner of the virtualenv being manipulated. +# @param group The group relating to the virtualenv being manipulated. +# @param proxy Proxy server to use for outbound connections. +# @param 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. +# @param environment Additional environment variables required to install the packages. +# @param 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) +# @param cwd The directory from which to run the "pip install" command. +# @param extra_pip_args Extra arguments to pass to pip after the requirements file +# @param manage_requirements Create the requirements file if it doesn't exist. +# @param fix_requirements_owner Change owner and group of requirements file. +# @param log_dir Log directory. +# @param timeout The maximum time in seconds the "pip install" command should take. +# +# @example install pip requirements from /var/www/project1/requirements.txt +# python::requirements { '/var/www/project1/requirements.txt': +# virtualenv => '/var/www/project1', +# proxy => 'http://proxy.domain.com:3128', +# } # define python::requirements ( $requirements = $name, diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index ad526678..c1a06ffe 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -1,79 +1,34 @@ -# == 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 +# @summary Creates Python virtualenv. +# +# @param ensure +# @param version Python version to use. +# @param requirements Path to pip requirements.txt file +# @param systempkgs Copy system site-packages into virtualenv. Default: don't If virtualenv version < 1.7 this flag has no effect since +# @param venv_dir Directory to install virtualenv to +# @param ensure_venv_dir reate $venv_dir +# @param distribute Include distribute in the virtualenv +# @param index Base URL of Python package index +# @param owner The owner of the virtualenv being manipulated +# @param group The group relating to the virtualenv being manipulated +# @param mode Optionally specify directory mode +# @param proxy Proxy server to use for outbound connections +# @param environment Additional environment variables required to install the packages +# @param path Specifies the PATH variable +# @param cwd The directory from which to run the "pip install" command +# @param timeout The maximum time in seconds the "pip install" command should take +# @param pip_args Arguments to pass to pip during initialization +# @param extra_pip_args Extra arguments to pass to pip after requirements file +# +# @example install a virtual env at /var/www/project1 +# 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/', +# } # define python::virtualenv ( $ensure = present, From 0faf83acdd59a14f4779e1393d3554573def2dd7 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Mon, 22 Oct 2018 09:52:33 -0400 Subject: [PATCH 3/9] Added string type to defined type pip, ensure --- REFERENCE.md | 6 +++--- manifests/pip.pp | 38 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index b16b5302..95389ba7 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -15,7 +15,7 @@ * [`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): +* [`python::pyvenv`](#pythonpyvenv): Create a Python3 virtualenv using pyvenv. * [`python::requirements`](#pythonrequirements): Installs and manages Python packages from requirements file. * [`python::virtualenv`](#pythonvirtualenv): Creates Python virtualenv. @@ -543,7 +543,7 @@ Default value: $name ##### `ensure` -Data type: `Enum[present, absent, latest]` +Data type: `Variant[Enum[present, absent, latest], String]` Require pip to be available. @@ -693,7 +693,7 @@ Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'] ### python::pyvenv -The python::pyvenv class. +Create a Python3 virtualenv using pyvenv. #### Examples diff --git a/manifests/pip.pp b/manifests/pip.pp index 04d956b8..6eab00bd 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -32,25 +32,25 @@ # # define python::pip ( - String $pkgname = $name, - Enum[present, absent, latest] $ensure = present, - String $virtualenv = 'system', - Enum['pip', 'pip3'] $pip_provider = 'pip', - Variant[Boolean, String] $url = false, - String $owner = 'root', - String $group = 'root', - $umask = undef, - $index = false, - Variant[Boolean, String] $proxy = false, - $egg = false, - Boolean $editable = false, - $environment = [], - $extras = [], - String $install_args = '', - String $uninstall_args = '', - Numeric $timeout = 1800, - String $log_dir = '/tmp', - Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + String $pkgname = $name, + Variant[Enum[present, absent, latest], String] $ensure = present, + String $virtualenv = 'system', + Enum['pip', 'pip3'] $pip_provider = 'pip', + Variant[Boolean, String] $url = false, + String $owner = 'root', + String $group = 'root', + $umask = undef, + $index = false, + Variant[Boolean, String] $proxy = false, + $egg = false, + Boolean $editable = false, + $environment = [], + $extras = [], + String $install_args = '', + String $uninstall_args = '', + Numeric $timeout = 1800, + String $log_dir = '/tmp', + Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], ) { $python_provider = getparam(Class['python'], 'provider') $python_version = getparam(Class['python'], 'version') From 22e3b3b8ea40e539ad43bccaf8d47096c7a8c33c Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Mon, 22 Oct 2018 17:33:46 -0400 Subject: [PATCH 4/9] Removed default comments, install/param -> private, typed mode/dev vars --- REFERENCE.md | 58 ++++++++++++++----------------------------- manifests/gunicorn.pp | 50 ++++++++++++++++--------------------- manifests/init.pp | 17 +++++-------- manifests/install.pp | 2 +- manifests/params.pp | 2 +- manifests/pyvenv.pp | 4 +-- 6 files changed, 50 insertions(+), 83 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 95389ba7..f3295d3b 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -5,10 +5,15 @@ **Classes** +_Public Classes_ + * [`python`](#python): Installs and manages python, python-dev, python-virtualenv and gunicorn. * [`python::config`](#pythonconfig): Optionally installs the gunicorn service -* [`python::install`](#pythoninstall): Installs core python packages -* [`python::params`](#pythonparams): The python Module default configuration settings. + +_Private Classes_ + +* `python::install`: Installs core python packages +* `python::params`: The python Module default configuration settings. **Defined types** @@ -71,17 +76,15 @@ Default value: $python::params::version Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for python-pip. Boolean values are deprecated. -Allowed values: 'absent', 'present', 'latest' +Desired installation state for python-pip. Default value: $python::params::pip ##### `dev` -Data type: `Any` +Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for python-dev. Boolean values are deprecated. -Allowed values: 'absent', 'present', 'latest' +Desired installation state for python-dev. Default value: $python::params::dev @@ -89,8 +92,7 @@ Default value: $python::params::dev Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for python-virtualenv. Boolean values are deprecated -Allowed values: 'absent', 'present', 'latest +Desired installation state for python-virtualenv. Default value: $python::params::virtualenv @@ -98,8 +100,7 @@ Default value: $python::params::virtualenv Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for Gunicorn. Boolean values are deprecated. -Allowed values: 'absent', 'present', 'latest' +Desired installation state for Gunicorn. Default value: $python::params::gunicorn @@ -107,7 +108,7 @@ Default value: $python::params::gunicorn Data type: `Boolean` -Allow Installation / Removal of Gunicorn. Default: true +Allow Installation / Removal of Gunicorn. Default value: $python::params::manage_gunicorn @@ -116,7 +117,6 @@ 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. -Allowed values: 'pip' Default value: $python::params::provider @@ -220,22 +220,6 @@ Optionally installs the gunicorn service include python::config ``` -### python::install - -Installs core python packages - -#### Examples - -##### - -```puppet -include python::install -``` - -### python::params - -The python Module default configuration settings. - ## Defined types ### python::dotfile @@ -375,10 +359,9 @@ Default value: `false` ##### `mode` -Data type: `Any` +Data type: `Enum['wsgi', 'django']` Gunicorn mode. -wsgi|django. Default: wsgi Default value: 'wsgi' @@ -413,7 +396,6 @@ Default value: `false` Data type: `Any` Set the application module name for gunicorn to load when not using Django. -Default: app:app Default value: 'app:app' @@ -421,9 +403,7 @@ Default value: 'app:app' Data type: `Any` -Allows setting environment variables for the gunicorn service. Accepts a -hash of 'key': 'value' pairs. -Default: false +Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default value: `false` @@ -431,9 +411,7 @@ Default value: `false` Data type: `Any` -Allows setting the gunicorn idle worker process time before being killed. -The unit of time is seconds. -Default: 30 +Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. Default value: 30 @@ -723,7 +701,7 @@ Default value: present Data type: `Any` -Python version to use. Default: system default +Python version to use. Default value: 'system' @@ -771,7 +749,7 @@ Default value: '0755' Data type: `Any` -Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] +Specifies the PATH variable. Default value: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ] diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index 74e3251a..b6a9542c 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -6,20 +6,14 @@ # @param manage_config_dir Set if the gunicorn config directory should be created. Default: false # @param virtualenv Run in virtualenv, specify directory. Default: disabled # @param mode Gunicorn mode. -# wsgi|django. Default: wsgi # @param dir Application directory. # @param bind Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. # Default: system-wide: unix:/tmp/gunicorn-$name.socket # virtualenv: unix:${virtualenv}/${name}.socket # @param environment Set ENVIRONMENT variable. Default: none # @param appmodule Set the application module name for gunicorn to load when not using Django. -# Default: app:app -# @param osenv Allows setting environment variables for the gunicorn service. Accepts a -# hash of 'key': 'value' pairs. -# Default: false -# @param timeout Allows setting the gunicorn idle worker process time before being killed. -# The unit of time is seconds. -# Default: 30 +# @param osenv Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. +# @param timeout Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. # @param template Which ERB template to use. Default: python/gunicorn.erb # @param args Custom arguments to add in gunicorn config file. Default: [] # @@ -40,26 +34,26 @@ # } # define python::gunicorn ( - $ensure = present, - $config_dir = '/etc/gunicorn.d', - $manage_config_dir = false, - $virtualenv = false, - $mode = 'wsgi', - $dir = false, - $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, - $log_level = 'error', - $template = 'python/gunicorn.erb', - $args = [], + $ensure = present, + $config_dir = '/etc/gunicorn.d', + $manage_config_dir = false, + $virtualenv = false, + Enum['wsgi', 'django'] $mode = 'wsgi', + $dir = false, + $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, + $log_level = 'error', + $template = 'python/gunicorn.erb', + $args = [], ) { # Parameter validation diff --git a/manifests/init.pp b/manifests/init.pp index 212ea90c..a0c5a8be 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,17 +10,12 @@ # - '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. -# @param pip Desired installation state for python-pip. Boolean values are deprecated. -# Allowed values: 'absent', 'present', 'latest' -# @param dev Desired installation state for python-dev. Boolean values are deprecated. -# Allowed values: 'absent', 'present', 'latest' -# @param virtualenv Desired installation state for python-virtualenv. Boolean values are deprecated -# Allowed values: 'absent', 'present', 'latest -# @param gunicorn Desired installation state for Gunicorn. Boolean values are deprecated. -# Allowed values: 'absent', 'present', 'latest' -# @param manage_gunicorn Allow Installation / Removal of Gunicorn. Default: true +# @param pip Desired installation state for python-pip. +# @param dev Desired installation state for python-dev. +# @param virtualenv Desired installation state for python-virtualenv. +# @param gunicorn Desired installation state for Gunicorn. +# @param manage_gunicorn Allow Installation / Removal of Gunicorn. # @param provider What provider to use for installation of the packages, except gunicorn and Python itself. -# Allowed values: 'pip' # @param use_epel to determine if the epel class is used. # # @example ensure system python is installed, with pip,dev, virtualenv, and gunicorn packages present @@ -36,7 +31,7 @@ Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure, $version = $python::params::version, Enum['absent', 'present', 'latest'] $pip = $python::params::pip, - $dev = $python::params::dev, + 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, diff --git a/manifests/install.pp b/manifests/install.pp index 28505472..fe0e1911 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,4 +1,4 @@ -# +# @api private # @summary Installs core python packages # # @example diff --git a/manifests/params.pp b/manifests/params.pp index b68ed9ea..d8e5d5d4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,4 +1,4 @@ -# +# @api private # @summary The python Module default configuration settings. # class python::params { diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index b2e3d29a..509926c7 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -2,13 +2,13 @@ # @summary Create a Python3 virtualenv using pyvenv. # # @param ensure -# @param version Python version to use. Default: system default +# @param version Python version to use. # @param systempkgs Copy system site-packages into virtualenv # @param venv_dir Directory to install virtualenv to # @param owner The owner of the virtualenv being manipulated # @param group The group relating to the virtualenv being manipulated # @param mode Optionally specify directory mode -# @param path Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] +# @param path Specifies the PATH variable. # @param environment Optionally specify environment variables for pyvenv # # @example From e63659e3d34c4c2fb5555f033f62ae8b78b3a7c3 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Mon, 22 Oct 2018 19:05:32 -0400 Subject: [PATCH 5/9] fixed typos in comments added some more types, config.pp -> private, removed remaining defaults --- REFERENCE.md | 57 +++++++++++++++------------------------ manifests/config.pp | 2 +- manifests/dotfile.pp | 24 ++++++++--------- manifests/gunicorn.pp | 12 ++++----- manifests/init.pp | 1 - manifests/requirements.pp | 6 ++--- manifests/virtualenv.pp | 4 +-- 7 files changed, 46 insertions(+), 60 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index f3295d3b..9acfb173 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -8,10 +8,10 @@ _Public Classes_ * [`python`](#python): Installs and manages python, python-dev, python-virtualenv and gunicorn. -* [`python::config`](#pythonconfig): Optionally installs the gunicorn service _Private Classes_ +* `python::config`: Optionally installs the gunicorn service * `python::install`: Installs core python packages * `python::params`: The python Module default configuration settings. @@ -53,7 +53,6 @@ The following parameters are available in the `python` class. Data type: `Enum['absent', 'present', 'latest']` Desired installation state for the Python package. -Allowed values: absent, present and latest Default value: $python::params::ensure @@ -208,18 +207,6 @@ Data type: `Stdlib::Absolutepath` Default value: $python::params::anaconda_install_path -### python::config - -Optionally installs the gunicorn service - -#### Examples - -##### - -```puppet -include python::config -``` - ## Defined types ### python::dotfile @@ -237,8 +224,8 @@ python::dotfile { '/var/lib/jenkins/.pip/pip.conf': group => 'jenkins', config => { 'global' => { - 'index-url => 'https://mypypi.acme.com/simple/' - 'extra-index-url => https://pypi.risedev.at/simple/ + 'index-url' => 'https://mypypi.acme.com/simple/' + 'extra-index-url' => 'https://pypi.risedev.at/simple/' } } } @@ -250,9 +237,9 @@ The following parameters are available in the `python::dotfile` defined type. ##### `ensure` -Data type: `Any` +Data type: `Enum['absent', 'present']` + -present|absent. Default: present Default value: 'present' @@ -260,21 +247,21 @@ Default value: 'present' Data type: `Any` -Filename. Default: $title +Filename. Default value: $title ##### `mode` -Data type: `Any` +Data type: `String` -File mode. Default: 0644 +File mode. Default value: '0644' ##### `owner` -Data type: `Any` +Data type: `String` user owner of dotfile @@ -282,7 +269,7 @@ Default value: 'root' ##### `group` -Data type: `Any` +Data type: `String` group owner of dotfile @@ -292,7 +279,7 @@ Default value: 'root' Data type: `Any` -Config hash. This will be expanded to an ini-file. Default: {} +Config hash. This will be expanded to an ini-file. Default value: {} @@ -337,7 +324,7 @@ Default value: present Data type: `Any` -Configure the gunicorn config directory path. Default: /etc/gunicorn.d +Configure the gunicorn config directory path. Default value: '/etc/gunicorn.d' @@ -345,7 +332,7 @@ Default value: '/etc/gunicorn.d' Data type: `Any` -Set if the gunicorn config directory should be created. Default: false +Set if the gunicorn config directory should be created. Default value: `false` @@ -353,7 +340,7 @@ Default value: `false` Data type: `Any` -Run in virtualenv, specify directory. Default: disabled +Run in virtualenv, specify directory. Default value: `false` @@ -387,7 +374,7 @@ Default value: `false` Data type: `Any` -Set ENVIRONMENT variable. Default: none +Set ENVIRONMENT variable. Default value: `false` @@ -419,7 +406,7 @@ Default value: 30 Data type: `Any` -Which ERB template to use. Default: python/gunicorn.erb +Which ERB template to use. Default value: 'python/gunicorn.erb' @@ -427,7 +414,7 @@ Default value: 'python/gunicorn.erb' Data type: `Any` -Custom arguments to add in gunicorn config file. Default: [] +Custom arguments to add in gunicorn config file. Default value: [] @@ -784,7 +771,7 @@ The following parameters are available in the `python::requirements` defined typ Data type: `Any` -Path to the requirements file. Defaults to the resource name +Path to the requirements file. Default value: $name @@ -792,7 +779,7 @@ Default value: $name Data type: `Any` -virtualenv to run pip in. Default: system-wide +virtualenv to run pip in. Default value: 'system' @@ -800,7 +787,7 @@ Default value: 'system' Data type: `Enum['pip', 'pip3']` -version of pip you wish to use. Default: pip +version of pip you wish to use. Default value: 'pip' @@ -951,7 +938,7 @@ Default value: `false` Data type: `Any` -Copy system site-packages into virtualenv. Default: don't If virtualenv version < 1.7 this flag has no effect since +Copy system site-packages into virtualenv. Default value: `false` @@ -967,7 +954,7 @@ Default value: $name Data type: `Any` -reate $venv_dir +Create $venv_dir Default value: `true` diff --git a/manifests/config.pp b/manifests/config.pp index 9788838d..73a346d7 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,4 +1,4 @@ -# +# @api private # @summary Optionally installs the gunicorn service # # @example diff --git a/manifests/dotfile.pp b/manifests/dotfile.pp index de1bd096..dd9eb37c 100644 --- a/manifests/dotfile.pp +++ b/manifests/dotfile.pp @@ -1,12 +1,12 @@ # # @summary Manages any python dotfiles with a simple config hash. # -# @param ensure present|absent. Default: present -# @param filename Filename. Default: $title -# @param mode File mode. Default: 0644 +# @param ensure +# @param filename Filename. +# @param mode File mode. # @param owner user owner of dotfile # @param group group owner of dotfile -# @param config Config hash. This will be expanded to an ini-file. Default: {} +# @param config Config hash. This will be expanded to an ini-file. # # === Examples # @@ -17,20 +17,20 @@ # group => 'jenkins', # config => { # 'global' => { -# 'index-url => 'https://mypypi.acme.com/simple/' -# 'extra-index-url => https://pypi.risedev.at/simple/ +# 'index-url' => 'https://mypypi.acme.com/simple/' +# 'extra-index-url' => 'https://pypi.risedev.at/simple/' # } # } # } # # define python::dotfile ( - $ensure = 'present', - $filename = $title, - $owner = 'root', - $group = 'root', - $mode = '0644', - $config = {}, + Enum['absent', 'present'] $ensure = 'present', + $filename = $title, + String $owner = 'root', + String $group = 'root', + String $mode = '0644', + $config = {}, ) { $parent_dir = dirname($filename) diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index b6a9542c..994bf08c 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -2,20 +2,20 @@ # @summary Manages Gunicorn virtual hosts. # # @param ensure -# @param config_dir Configure the gunicorn config directory path. Default: /etc/gunicorn.d -# @param manage_config_dir Set if the gunicorn config directory should be created. Default: false -# @param virtualenv Run in virtualenv, specify directory. Default: disabled +# @param config_dir Configure the gunicorn config directory path. +# @param manage_config_dir Set if the gunicorn config directory should be created. +# @param virtualenv Run in virtualenv, specify directory. # @param mode Gunicorn mode. # @param dir Application directory. # @param bind Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. # Default: system-wide: unix:/tmp/gunicorn-$name.socket # virtualenv: unix:${virtualenv}/${name}.socket -# @param environment Set ENVIRONMENT variable. Default: none +# @param environment Set ENVIRONMENT variable. # @param appmodule Set the application module name for gunicorn to load when not using Django. # @param osenv Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. # @param timeout Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. -# @param template Which ERB template to use. Default: python/gunicorn.erb -# @param args Custom arguments to add in gunicorn config file. Default: [] +# @param template Which ERB template to use. +# @param args Custom arguments to add in gunicorn config file. # # @example run gunicorn on vhost in virtualenv /var/www/project1 # python::gunicorn { 'vhost': diff --git a/manifests/init.pp b/manifests/init.pp index a0c5a8be..0a03faf8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,7 +1,6 @@ # @summary Installs and manages python, python-dev, python-virtualenv and gunicorn. # # @param ensure Desired installation state for the Python package. -# Allowed values: absent, present and latest # @param 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==' diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 1127f5db..615b091b 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -1,9 +1,9 @@ # # @summary Installs and manages Python packages from requirements file. # -# @param requirements Path to the requirements file. Defaults to the resource name -# @param virtualenv virtualenv to run pip in. Default: system-wide -# @param pip_provider version of pip you wish to use. Default: pip +# @param requirements Path to the requirements file. +# @param virtualenv virtualenv to run pip in. +# @param pip_provider version of pip you wish to use. # @param owner The owner of the virtualenv being manipulated. # @param group The group relating to the virtualenv being manipulated. # @param proxy Proxy server to use for outbound connections. diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index c1a06ffe..23c3a7d7 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -4,9 +4,9 @@ # @param ensure # @param version Python version to use. # @param requirements Path to pip requirements.txt file -# @param systempkgs Copy system site-packages into virtualenv. Default: don't If virtualenv version < 1.7 this flag has no effect since +# @param systempkgs Copy system site-packages into virtualenv. # @param venv_dir Directory to install virtualenv to -# @param ensure_venv_dir reate $venv_dir +# @param ensure_venv_dir Create $venv_dir # @param distribute Include distribute in the virtualenv # @param index Base URL of Python package index # @param owner The owner of the virtualenv being manipulated From d8cd414221ae0004266c5f3cf6d8e68e08397a3c Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Tue, 23 Oct 2018 12:08:28 -0400 Subject: [PATCH 6/9] moved examples, variable info from READme to REFERENCE. --- README.md | 281 +------------------------------------- REFERENCE.md | 72 +++++++--- manifests/dotfile.pp | 2 - manifests/gunicorn.pp | 40 +++--- manifests/init.pp | 15 +- manifests/pip.pp | 26 +++- manifests/pyvenv.pp | 5 +- manifests/requirements.pp | 6 +- 8 files changed, 119 insertions(+), 328 deletions(-) diff --git a/README.md b/README.md index e24ed058..22f8ff1f 100644 --- a/README.md +++ b/README.md @@ -38,284 +38,9 @@ puppet module install stankevich-python ``` ## Usage - -### python - -Installs and manages python, python-pip, python-dev, python-virtualenv and Gunicorn. - -**ensure** - Desired installation state for the Python package. Options are absent, present and latest. Default: present - -**version** - Python version to install. Default: system - -**pip** - Desired installation state for the python-pip package. Options are absent, present and latest. Default: present - -**dev** - Desired installation state for the python-dev package. Options are absent, present and latest. Default: absent - -**virtualenv** - Desired installation state for the virtualenv package. Options are absent, present and latest. Default: absent - -**gunicorn** - Desired installation state for Gunicorn. Options are absent, present and latest. Default: absent - -**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true - -**use_epel** - Boolean to determine if the epel class is used. Default: true on RHEL like systems, false otherwise - -*Install Python from system python* -```puppet - class { 'python' : - version => 'system', - pip => 'present', - dev => 'absent', - virtualenv => 'absent', - gunicorn => 'absent', - } -``` -*Install Python 3 from the scl repo* -```puppet - class { 'python' : - ensure => 'present', - version => 'rh-python36-python', - dev => 'present', - virtualenv => 'present', - } -``` - -### python::pip - -Installs and manages packages from pip. - -**pkgname** - the name of the package to install. Required. - -**ensure** - present/latest/absent. You can also specify the version. Default: present - -**virtualenv** - virtualenv to run pip in. Default: system (no virtualenv) - -**pip_provider** - pip provider to execute pip with. Default: pip. - -**url** - URL to install from. Default: none - -**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root - -**proxy** - Proxy server to use for outbound connections. Default: none - -**environment** - Additional environment variables required to install the packages. Default: none - -**extras** - Extra features provided by the package which should be installed. Default: none - -**egg** - The egg name to use. Default: `$name` of the class, e.g. cx_Oracle - -**install_args** - String of additional flags to pass to pip during installaton. Default: none - -**uninstall_args** - String of additional flags to pass to pip during uninstall. Default: none - -**timeout** - Timeout for the pip install command. Defaults to 1800. - -*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 - } -``` - -### python::requirements - -Installs and manages Python packages from requirements file. - -**virtualenv** - virtualenv to run pip in. Default: system-wide - -**proxy** - Proxy server to use for outbound connections. Default: none - -**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root - -**src** - The `--src` parameter to `pip`, used to specify where to install `--editable` resources; by default no `--src` parameter is passed to `pip`. - -**group** - The group that was used to create the virtualenv. This is used to create the requirements file with correct permissions if it's not present already. - -**manage_requirements** - Create the requirements file if it doesn't exist. Default: true - -```puppet - python::requirements { '/var/www/project1/requirements.txt' : - virtualenv => '/var/www/project1', - proxy => 'http://proxy.domain.com:3128', - owner => 'appuser', - group => 'apps', - } -``` - -### python::virtualenv - -Creates Python virtualenv. - -**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 - -**venv_dir** - The location of the virtualenv if resource path not specified. Must be absolute path. Default: resource name - -**ensure_venv_dir** - Create virtualenv directory. Default: true - -**distribute** - Include distribute in the virtualenv. Default: true - -**index** - Base URL of Python package index. Default: none - -**owner** - Specify the owner of this virtualenv - -**group** - Specify the group for this virtualenv - -**mode** - Specify the 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** - Set the $PATH environment 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 installation. Default: blank - -**extra_pip_args** - Arguments to pass to pip for package install. These are included in the pip command *after* the requirements file. Default: blank - -```puppet - python::virtualenv { '/var/www/project1' : - ensure => present, - version => 'system', - requirements => '/var/www/project1/requirements.txt', - systempkgs => true, - venv_dir => '/home/appuser/virtualenvs', - ensure_venv_dir => false, - distribute => false, - index => 'appuser', - owner => 'appuser', - group => 'apps', - proxy => 'http://proxy.domain.com:3128', - cwd => '/var/www/project1', - timeout => 0, - extra_pip_args => '--no-binary :none:', - } -``` - -### python::pyvenv - -Creates Python3 virtualenv. - -**ensure** - present/absent. Default: present - -**version** - Python version to use. Default: system default - -**systempkgs** - Copy system site-packages into virtualenv. Default: don't - -**venv_dir** - The location of the virtualenv if resource path not specified. Must be absolute path. Default: resource name - -**owner** - Specify the owner of this virtualenv - -**group** - Specify the group for this virtualenv - -**path** - Specifies the PATH variable that contains `pyvenv` executable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] - -**environment** - Specify any environment variables to use when creating pyvenv - -```puppet - python::pyvenv { '/var/www/project1' : - ensure => present, - version => 'system', - systempkgs => true, - venv_dir => '/home/appuser/virtualenvs', - owner => 'appuser', - group => 'apps', - } -``` - -### python::gunicorn - -Manages Gunicorn virtual hosts. - -**ensure** - present/absent. Default: present - -**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: `unix:/tmp/gunicorn-$name.socket` or `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 - -```puppet - python::gunicorn { 'vhost' : - ensure => present, - virtualenv => '/var/www/project1', - mode => 'wsgi', - dir => '/var/www/project1/current', - bind => 'unix:/tmp/gunicorn.socket', - environment => 'prod', - appmodule => 'app:app', - osenv => { 'DBHOST' => 'dbserver.example.com' }, - timeout => 30, - template => 'python/gunicorn.erb', - } -``` - -### python::dotfile - -Manages arbitrary python dotiles with a simple config hash. - -**ensure** - present/absent. Default: present - -**filename** - Default: $title - -**mode** - Default: 0644 - -**owner** - Default: root - -**group** - Default: root - -**config** Config hash. This will be expanded to an ini-file. Default: {} - -```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/ - } - } -} +For class usage refer to the REFERENCE.md. If contributing, this is updated with +```shell +bundle exec rake strings:generate\[',,,,false,true'] ``` ### hiera configuration diff --git a/REFERENCE.md b/REFERENCE.md index 9acfb173..732c49ba 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -32,7 +32,7 @@ Installs and manages python, python-dev, python-virtualenv and gunicorn. #### Examples -##### ensure system python is installed, with pip,dev, virtualenv, and gunicorn packages present +##### install python from system python ```puppet class { 'python': @@ -44,6 +44,17 @@ class { 'python': } ``` +##### install python3 from scl report + +```puppet +class { 'python' : + ensure => 'present', + version => 'rh-python36-python', + dev => 'present', + virtualenv => 'present', +} +``` + #### Parameters The following parameters are available in the `python` class. @@ -75,7 +86,7 @@ Default value: $python::params::version Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for python-pip. +Desired installation state for the python-pip package. Default value: $python::params::pip @@ -83,7 +94,7 @@ Default value: $python::params::pip Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for python-dev. +Desired installation state for the python-dev package. Default value: $python::params::dev @@ -91,7 +102,7 @@ Default value: $python::params::dev Data type: `Enum['absent', 'present', 'latest']` -Desired installation state for python-virtualenv. +Desired installation state for the virtualenv package Default value: $python::params::virtualenv @@ -211,7 +222,7 @@ Default value: $python::params::anaconda_install_path ### python::dotfile -=== Examples +Manages any python dotfiles with a simple config hash. #### Examples @@ -314,7 +325,7 @@ The following parameters are available in the `python::gunicorn` defined type. ##### `ensure` -Data type: `Any` +Data type: `Enum['present', 'abesent']` @@ -490,6 +501,34 @@ python::pip { 'flask': } ``` +##### 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. @@ -502,7 +541,7 @@ must be unique Data type: `String` -name of the package. +the name of the package. Default value: $name @@ -630,7 +669,7 @@ Default value: '/tmp' Data type: `Any` - +The egg name to use Default value: `false` @@ -642,12 +681,6 @@ Data type: `Any` Default value: `undef` -##### `egg` - - - -Default value: `false` - ##### `path` Data type: `Array[String]` @@ -665,10 +698,13 @@ Create a Python3 virtualenv using pyvenv. ##### ```puppet -python::venv { '/var/www/project1': +python::pyvenv { '/var/www/project1' : ensure => present, version => 'system', systempkgs => true, + venv_dir => '/home/appuser/virtualenvs', + owner => 'appuser', + group => 'apps', } ``` @@ -757,9 +793,11 @@ Installs and manages Python packages from requirements file. ##### install pip requirements from /var/www/project1/requirements.txt ```puppet -python::requirements { '/var/www/project1/requirements.txt': +python::requirements { '/var/www/project1/requirements.txt' : virtualenv => '/var/www/project1', proxy => 'http://proxy.domain.com:3128', + owner => 'appuser', + group => 'apps', } ``` @@ -819,7 +857,7 @@ Default value: `false` Data type: `Any` -Pip --src parameter; if the requirements file contains --editable resources, this parameter specifies where they will be installed. See the pip documentation for more. +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` diff --git a/manifests/dotfile.pp b/manifests/dotfile.pp index dd9eb37c..fcff6e10 100644 --- a/manifests/dotfile.pp +++ b/manifests/dotfile.pp @@ -8,8 +8,6 @@ # @param group group owner of dotfile # @param config Config hash. This will be expanded to an ini-file. # -# === Examples -# # @example Create a pip config in /var/lib/jenkins/.pip/ # python::dotfile { '/var/lib/jenkins/.pip/pip.conf': # ensure => present, diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index 994bf08c..d15bfa78 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -34,26 +34,26 @@ # } # define python::gunicorn ( - $ensure = present, - $config_dir = '/etc/gunicorn.d', - $manage_config_dir = false, - $virtualenv = false, - Enum['wsgi', 'django'] $mode = 'wsgi', - $dir = false, - $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, - $log_level = 'error', - $template = 'python/gunicorn.erb', - $args = [], + Enum['present', 'abesent'] $ensure = present, + $config_dir = '/etc/gunicorn.d', + $manage_config_dir = false, + $virtualenv = false, + Enum['wsgi', 'django'] $mode = 'wsgi', + $dir = false, + $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, + $log_level = 'error', + $template = 'python/gunicorn.erb', + $args = [], ) { # Parameter validation diff --git a/manifests/init.pp b/manifests/init.pp index 0a03faf8..583c2d59 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,15 +9,15 @@ # - '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. -# @param pip Desired installation state for python-pip. -# @param dev Desired installation state for python-dev. -# @param virtualenv Desired installation state for python-virtualenv. +# @param pip Desired installation state for the python-pip package. +# @param dev Desired installation state for the python-dev package. +# @param virtualenv Desired installation state for the virtualenv package # @param gunicorn Desired installation state for Gunicorn. # @param manage_gunicorn Allow Installation / Removal of Gunicorn. # @param provider What provider to use for installation of the packages, except gunicorn and Python itself. # @param use_epel to determine if the epel class is used. # -# @example ensure system python is installed, with pip,dev, virtualenv, and gunicorn packages present +# @example install python from system python # class { 'python': # version => 'system', # pip => 'present', @@ -25,6 +25,13 @@ # virtualenv => 'present', # gunicorn => 'present', # } +# @example install python3 from scl report +# class { 'python' : +# ensure => 'present', +# version => 'rh-python36-python', +# dev => 'present', +# virtualenv => 'present', +# } # class python ( Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure, diff --git a/manifests/pip.pp b/manifests/pip.pp index 6eab00bd..5e983187 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -3,7 +3,7 @@ # @summary Installs and manages packages from pip. # # @param name must be unique -# @param pkgname name of the package. +# @param pkgname the 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. @@ -19,9 +19,8 @@ # @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 egg The egg name to use # @param umask -# @param egg # # @example Install Flask to /var/www/project1 using a proxy # python::pip { 'flask': @@ -29,7 +28,26 @@ # proxy => 'http://proxy.domain.com:3128', # index => 'http://www.example.com/simple/', # } -# +# @example Install cx_Oracle with pip +# python::pip { 'cx_Oracle' : +# pkgname => 'cx_Oracle', +# ensure => '5.1.2', +# virtualenv => '/var/www/project1', +# owner => 'appuser', +# proxy => 'http://proxy.domain.com:3128', +# environment => 'ORACLE_HOME=/usr/lib/oracle/11.2/client64', +# install_args => '-e', +# timeout => 1800, +# } +# @example Install Requests with pip3 +# python::pip { 'requests' : +# ensure => 'present', +# pkgname => 'requests', +# pip_provider => 'pip3', +# virtualenv => '/var/www/project1', +# owner => 'root', +# timeout => 1800 +# } # define python::pip ( String $pkgname = $name, diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 509926c7..66957731 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -12,10 +12,13 @@ # @param environment Optionally specify environment variables for pyvenv # # @example -# python::venv { '/var/www/project1': +# python::pyvenv { '/var/www/project1' : # ensure => present, # version => 'system', # systempkgs => true, +# venv_dir => '/home/appuser/virtualenvs', +# owner => 'appuser', +# group => 'apps', # } # define python::pyvenv ( diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 615b091b..d592ebfe 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -7,7 +7,7 @@ # @param owner The owner of the virtualenv being manipulated. # @param group The group relating to the virtualenv being manipulated. # @param proxy Proxy server to use for outbound connections. -# @param 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. +# @param src 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. # @param environment Additional environment variables required to install the packages. # @param 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) # @param cwd The directory from which to run the "pip install" command. @@ -18,9 +18,11 @@ # @param timeout The maximum time in seconds the "pip install" command should take. # # @example install pip requirements from /var/www/project1/requirements.txt -# python::requirements { '/var/www/project1/requirements.txt': +# python::requirements { '/var/www/project1/requirements.txt' : # virtualenv => '/var/www/project1', # proxy => 'http://proxy.domain.com:3128', +# owner => 'appuser', +# group => 'apps', # } # define python::requirements ( From 8bcfb17c14bc5605b68f80ffb0eba740bf50d082 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Wed, 24 Oct 2018 08:58:53 -0400 Subject: [PATCH 7/9] fixed typo/indentation in gunicorn.pp, update readme for module install --- README.md | 2 +- REFERENCE.md | 2 +- manifests/gunicorn.pp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22f8ff1f..d407bdd7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ git submodule add https://github.com/stankevich/puppet-python.git /path/to/pytho OR ``` shell -puppet module install stankevich-python +puppet module install puppet-python ``` ## Usage diff --git a/REFERENCE.md b/REFERENCE.md index 732c49ba..81c49743 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -325,7 +325,7 @@ The following parameters are available in the `python::gunicorn` defined type. ##### `ensure` -Data type: `Enum['present', 'abesent']` +Data type: `Enum['present', 'absent']` diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index d15bfa78..da14dd0e 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -34,7 +34,7 @@ # } # define python::gunicorn ( - Enum['present', 'abesent'] $ensure = present, + Enum['present', 'absent'] $ensure = present, $config_dir = '/etc/gunicorn.d', $manage_config_dir = false, $virtualenv = false, @@ -51,7 +51,7 @@ $access_log_format = false, $accesslog = false, $errorlog = false, - $log_level = 'error', + $log_level = 'error', $template = 'python/gunicorn.erb', $args = [], ) { From 0e5ea07d76f09829191bb07fabba8800b50124aa Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Wed, 24 Oct 2018 09:02:54 -0400 Subject: [PATCH 8/9] readme update to point release notes to changelog --- README.md | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d407bdd7..4bb1ab8f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ puppet module install puppet-python ``` ## Usage -For class usage refer to the REFERENCE.md. If contributing, this is updated with +For class usage refer to the [Reference]("https://github.com/voxpupuli/puppet-python/blob/master/REFERENCE.md). If contributing, this is updated with ```shell bundle exec rake strings:generate\[',,,,false,true'] ``` @@ -75,24 +75,7 @@ from softwarecollections.org, set python::provider to 'rhscl' and python::versio of the collection you want to use (e.g., 'python27', 'python33', or 'rh-python34'). ## Release Notes - -**Version 1.9.8 Notes** -The `pip`, `virtualenv` and `gunicorn` parameters of `Class['python']` have changed. These parameters now accept `absent`, `present` and `latest` rather than `true` and `false`. The boolean values are still supported and are equivalent to `present` and `absent` respectively. Support for these boolean parameters is deprecated and will be removed in a later release. - -**Version 1.7.10 Notes** - -Installation of python-pip previously defaulted to `false` and was not installed. This default is now `true` and python-pip is installed. To prevent the installation of python-pip specify `pip => false` as a parameter when instantiating the `python` puppet class. - -**Version 1.1.x Notes** - -Version `1.1.x` makes several fundamental changes to the core of this module, adding some additional features, improving performance and making operations more robust in general. - -Please note that several changes have been made in `v1.1.x` which make manifests incompatible with the previous version. However, modifying your manifests to suit is trivial. Please see the notes below. - -Currently, the changes you need to make are as follows: - -* All pip definitions MUST include the owner field which specifies which user owns the virtualenv that packages will be installed in. Adding this greatly improves performance and efficiency of this module. -* You must explicitly specify pip => true in the python class if you want pip installed. As such, the pip package is now independent of the dev package and so one can exist without the other. +See [Changelog](https://github.com/voxpupuli/puppet-python/blob/master/CHANGELOG.md) ## Contributors From a990c0b91343d9a706bd8aa4848ad49c4cf309a3 Mon Sep 17 00:00:00 2001 From: Daniel Quackenbush Date: Wed, 24 Oct 2018 18:53:06 -0400 Subject: [PATCH 9/9] String to String[1] --- .DS_Store | Bin 0 -> 6148 bytes README.md | 1 + REFERENCE.md | 18 +++++++++--------- manifests/dotfile.pp | 10 +++++----- manifests/pip.pp | 38 +++++++++++++++++++------------------- 5 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0