diff --git a/REFERENCE.md b/REFERENCE.md index d08c17ac..817b86c0 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -28,11 +28,11 @@ ### Data types -* [`Python::Loglevel`](#pythonloglevel): A version type to match all valid loglevels for python -* [`Python::Package::Ensure`](#pythonpackageensure): A version type to match all valid package ensures for python -* [`Python::Provider`](#pythonprovider): A version type to match all valid provider for python -* [`Python::Umask`](#pythonumask): A version type to match valid umask for python -* [`Python::Version`](#pythonversion): A version type to match all valid versions for python +* [`Python::Loglevel`](#pythonloglevel): Match all valid loglevels for python +* [`Python::Package::Ensure`](#pythonpackageensure): Match all valid package ensures for python +* [`Python::Provider`](#pythonprovider): Match all valid provider for python +* [`Python::Umask`](#pythonumask): Match valid umask for python +* [`Python::Version`](#pythonversion): Match all valid versions for python ## Classes @@ -116,6 +116,14 @@ Desired installation state for the virtualenv package Default value: `$python::params::virtualenv` +##### `venv` + +Data type: `Python::Package::Ensure` + +Desired installation state for the virtualenv package + +Default value: `$python::params::venv` + ##### `gunicorn` Data type: `Python::Package::Ensure` @@ -164,11 +172,17 @@ The default umask for invoked exec calls. Default value: ``undef`` +##### `manage_gunicorn` + +manage the state for package gunicorn + +Default value: `$python::params::manage_gunicorn` + ##### `manage_python_package` Data type: `Boolean` - +manage the state for package python Default value: `$python::params::manage_python_package` @@ -176,15 +190,23 @@ Default value: `$python::params::manage_python_package` Data type: `Boolean` - +manage the state for package virtualenv Default value: `$python::params::manage_virtualenv_package` -##### `manage_pip_package` +##### `manage_venv_package` Data type: `Boolean` +manage the state for package venv + +Default value: `$python::params::manage_venv_package` + +##### `manage_pip_package` + +Data type: `Boolean` +manage the state for package pip Default value: `$python::params::manage_pip_package` @@ -1202,31 +1224,31 @@ Default value: ``undef`` ### `Python::Loglevel` -A version type to match all valid loglevels for python +Match all valid loglevels for python Alias of `Enum['debug', 'info', 'warning', 'error', 'critical']` ### `Python::Package::Ensure` -A version type to match all valid package ensures for python +Match all valid package ensures for python Alias of `Enum['absent', 'present', 'latest']` ### `Python::Provider` -A version type to match all valid provider for python +Match all valid provider for python Alias of `Enum['pip', 'scl', 'rhscl', 'anaconda', '']` ### `Python::Umask` -A version type to match valid umask for python +Match valid umask for python Alias of `Pattern[/[0-7]{1,4}/]` ### `Python::Version` -A version type to match all valid versions for python +Match all valid versions for python Alias of `Pattern[/\A(python)?[0-9](\.?[0-9])*/, /\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/]` diff --git a/manifests/init.pp b/manifests/init.pp index 74c13d66..ff93ff1f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,12 +12,18 @@ # @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 venv 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. # @param manage_scl Whether to manage core SCL packages or not. # @param umask The default umask for invoked exec calls. +# @param manage_gunicorn manage the state for package gunicorn +# @param manage_python_package manage the state for package python +# @param manage_virtualenv_package manage the state for package virtualenv +# @param manage_venv_package manage the state for package venv +# @param manage_pip_package manage the state for package pip # # @example install python from system python # class { 'python': @@ -41,10 +47,12 @@ Python::Package::Ensure $pip = $python::params::pip, Python::Package::Ensure $dev = $python::params::dev, Python::Package::Ensure $virtualenv = $python::params::virtualenv, + Python::Package::Ensure $venv = $python::params::venv, Python::Package::Ensure $gunicorn = $python::params::gunicorn, Boolean $manage_gunicorn = $python::params::manage_gunicorn, Boolean $manage_python_package = $python::params::manage_python_package, Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package, + Boolean $manage_venv_package = $python::params::manage_venv_package, Boolean $manage_pip_package = $python::params::manage_pip_package, String[1] $gunicorn_package_name = $python::params::gunicorn_package_name, Optional[Python::Provider] $provider = $python::params::provider, diff --git a/manifests/install.pp b/manifests/install.pp index cc8b1411..b4d9b9b0 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -22,19 +22,7 @@ 'Gentoo' => undef, } - $pip_ensure = $python::pip ? { - true => 'present', - false => 'absent', - default => $python::pip, - } - - $venv_ensure = $python::virtualenv ? { - true => 'present', - false => 'absent', - default => $python::virtualenv, - } - - if $venv_ensure == 'present' { + if $python::virtualenv == 'present' { $dev_ensure = 'present' unless $python::dev { @@ -59,17 +47,25 @@ if $python::manage_virtualenv_package { package { 'virtualenv': - ensure => $venv_ensure, + ensure => $python::virtualenv, name => "${python}-virtualenv", require => Package['python'], } } + if $python::manage_venv_package { + package { 'python-venv': + ensure => $python::venv, + name => "${python}-venv", + require => Package['python'], + } + } + case $python::provider { 'pip': { if $python::manage_pip_package { package { 'pip': - ensure => $pip_ensure, + ensure => $python::pip, require => Package['python'], } } @@ -81,8 +77,8 @@ } } - # Respect the $pip_ensure setting - unless $pip_ensure == 'absent' { + # Respect the $python::pip setting + unless $python::pip == 'absent' { # Install pip without pip, see https://pip.pypa.io/en/stable/installing/. include python::pip::bootstrap @@ -129,7 +125,7 @@ Package['scl-utils'] -> Package["${python}-scldevel"] - if $pip_ensure != 'absent' { + if $python::pip != 'absent' { Package['scl-utils'] -> Exec['python-scl-pip-install'] } } @@ -138,7 +134,7 @@ ensure => $dev_ensure, } - if $pip_ensure != 'absent' { + if $python::pip != 'absent' { exec { 'python-scl-pip-install': command => "${python::exec_prefix}easy_install pip", path => ['/usr/bin', '/bin'], @@ -172,7 +168,7 @@ } package { "${python}-python-pip": - ensure => $pip_ensure, + ensure => $python::pip, tag => 'python-pip-package', } @@ -210,7 +206,7 @@ } else { if $python::manage_pip_package { package { 'python-pip': - ensure => $pip_ensure, + ensure => $python::pip, require => Package['python'], provider => 'yum', } @@ -229,7 +225,7 @@ default: { if $python::manage_pip_package { package { 'pip': - ensure => $pip_ensure, + ensure => $python::pip, require => Package['python'], } } @@ -246,11 +242,11 @@ case $facts['os']['family'] { 'RedHat': { - if $pip_ensure != 'absent' and $python::use_epel and ($python::manage_pip_package or $python::manage_python_package) { + if $python::pip != 'absent' and $python::use_epel and ($python::manage_pip_package or $python::manage_python_package) { require epel } - if $venv_ensure != 'absent' and $facts['os']['release']['full'] =~ /^6/ and $python::use_epel { + if $python::virtualenv != 'absent' and $facts['os']['release']['full'] =~ /^6/ and $python::use_epel { require epel } diff --git a/manifests/params.pp b/manifests/params.pp index 89a5ccce..2768efbe 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,10 +13,12 @@ $pip = 'present' $dev = 'absent' $virtualenv = 'absent' + $venv = 'absent' $gunicorn = 'absent' $manage_gunicorn = true $manage_python_package = true $manage_virtualenv_package = true + $manage_venv_package = true $manage_pip_package = true $provider = undef $valid_versions = undef diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index 92712bdd..dea30732 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -23,7 +23,8 @@ { manage_python_package: false, manage_virtualenv_package: false, - manage_pip_package: false + manage_pip_package: false, + manage_venv_package: false } end @@ -31,6 +32,7 @@ it { is_expected.not_to contain_package('python') } it { is_expected.not_to contain_package('virtualenv') } it { is_expected.not_to contain_package('pip') } + it { is_expected.not_to contain_package('python-venv') } end case facts[:os]['family'] diff --git a/types/loglevel.pp b/types/loglevel.pp index 3cdb653d..849c2236 100644 --- a/types/loglevel.pp +++ b/types/loglevel.pp @@ -1,3 +1,3 @@ -# @summary A version type to match all valid loglevels for python +# @summary Match all valid loglevels for python # type Python::Loglevel = Enum['debug', 'info', 'warning', 'error', 'critical'] diff --git a/types/package/ensure.pp b/types/package/ensure.pp index 1eb13b82..34189e4b 100644 --- a/types/package/ensure.pp +++ b/types/package/ensure.pp @@ -1,3 +1,3 @@ -# @summary A version type to match all valid package ensures for python +# @summary Match all valid package ensures for python # type Python::Package::Ensure = Enum['absent', 'present', 'latest'] diff --git a/types/provider.pp b/types/provider.pp index 8c7dfd65..68fd7ff6 100644 --- a/types/provider.pp +++ b/types/provider.pp @@ -1,3 +1,3 @@ -# @summary A version type to match all valid provider for python +# @summary Match all valid provider for python # type Python::Provider = Enum['pip', 'scl', 'rhscl', 'anaconda', ''] diff --git a/types/umask.pp b/types/umask.pp index 11296cd0..39038093 100644 --- a/types/umask.pp +++ b/types/umask.pp @@ -1,3 +1,3 @@ -# @summary A version type to match valid umask for python +# @summary Match valid umask for python # type Python::Umask = Pattern[/[0-7]{1,4}/] diff --git a/types/version.pp b/types/version.pp index e0023aef..5bbcaaa8 100644 --- a/types/version.pp +++ b/types/version.pp @@ -1,4 +1,4 @@ -# @summary A version type to match all valid versions for python +# @summary Match all valid versions for python # type Python::Version = Pattern[ /\A(python)?[0-9](\.?[0-9])*/,