Skip to content

Commit

Permalink
fix parameter lists of manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
crazymind1337 committed Nov 17, 2020
1 parent 4c44d18 commit e0a2a46
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 298 deletions.
378 changes: 202 additions & 176 deletions REFERENCE.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions manifests/dotfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#
define python::dotfile (
Enum['absent', 'present'] $ensure = 'present',
String[1] $filename = $title,
String[1] $owner = 'root',
String[1] $group = 'root',
Stdlib::Filemode $mode = '0644',
Hash $config = {},
String[1] $filename = $title,
String[1] $owner = 'root',
String[1] $group = 'root',
Stdlib::Filemode $mode = '0644',
Hash $config = {},
) {
$parent_dir = dirname($filename)

Expand Down
40 changes: 20 additions & 20 deletions manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@
# }
#
define python::gunicorn (
Stdlib::Absolutepath $dir,
Enum['present', 'absent'] $ensure = present,
$config_dir = '/etc/gunicorn.d',
$manage_config_dir = false,
$virtualenv = false,
Enum['wsgi', 'django'] $mode = 'wsgi',
$bind = false,
$environment = false,
$owner = 'www-data',
$group = 'www-data',
$appmodule = 'app:app',
$osenv = false,
$timeout = 30,
$workers = false,
$access_log_format = false,
$accesslog = false,
$errorlog = false,
Enum['debug', 'info', 'warning', 'error', 'critical'] $log_level = 'error',
$template = 'python/gunicorn.erb',
$args = [],
Stdlib::Absolutepath $dir,
Enum['present', 'absent'] $ensure = present,
Stdlib::Absolutepath $config_dir = '/etc/gunicorn.d',
Booloean $manage_config_dir = false,
Variant[Boolean,Stdlib::Absolutepath] $virtualenv = false,
Enum['wsgi', 'django'] $mode = 'wsgi',
Variant[String[1],Boolean] $bind = false,
Variant[String[1],Boolean] $environment = false,
String[1] $owner = 'www-data',
String[1] $group = 'www-data',
String[1] $appmodule = 'app:app',
Variant[Boolean,Hash] $osenv = false,
Integer $timeout = 30,
Variant[Boolean,Integer] $workers = false,
Variant[Boolean,String[1]] $access_log_format = false,
Variant[Boolean,Stdlib::Absolutepath] $accesslog = false,
Variant[Boolean,Stdlib::Absolutepath] $errorlog = false,
Python::Loglevel $log_level = 'error',
String[1] $template = 'python/gunicorn.erb',
Array $args = [],
) {
if $manage_config_dir {
file { $config_dir:
Expand Down
52 changes: 23 additions & 29 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,36 @@
# }
#
class python (
Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure,
$version = $python::params::version,
Enum['absent', 'present', 'latest'] $pip = $python::params::pip,
Enum['absent', 'present', 'latest'] $dev = $python::params::dev,
Enum['absent', 'present', 'latest'] $virtualenv = $python::params::virtualenv,
Enum['absent', 'present', 'latest'] $gunicorn = $python::params::gunicorn,
Boolean $manage_gunicorn = $python::params::manage_gunicorn,
Boolean $manage_python_package = $python::params::manage_python_package,
Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package,
Boolean $manage_pip_package = $python::params::manage_pip_package,
$gunicorn_package_name = $python::params::gunicorn_package_name,
Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']] $provider = $python::params::provider,
$valid_versions = $python::params::valid_versions,
Hash $python_pips = {},
Hash $python_virtualenvs = {},
Hash $python_pyvenvs = {},
Hash $python_requirements = {},
Hash $python_dotfiles = {},
Boolean $use_epel = $python::params::use_epel,
$rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
Boolean $manage_scl = $python::params::manage_scl,
Optional[Pattern[/[0-7]{1,4}/]] $umask = undef,
Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure,
Python::Version $version = $python::params::version,
Enum['absent', 'present', 'latest'] $pip = $python::params::pip,
Enum['absent', 'present', 'latest'] $dev = $python::params::dev,
Enum['absent', 'present', 'latest'] $virtualenv = $python::params::virtualenv,
Enum['absent', 'present', 'latest'] $gunicorn = $python::params::gunicorn,
Boolean $manage_gunicorn = $python::params::manage_gunicorn,
Boolean $manage_python_package = $python::params::manage_python_package,
Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package,
Boolean $manage_pip_package = $python::params::manage_pip_package,
Strng[1] $gunicorn_package_name = $python::params::gunicorn_package_name,
Optional[Python::Provider] $provider = $python::params::provider,
Hash $python_pips = {},
Hash $python_virtualenvs = {},
Hash $python_pyvenvs = {},
Hash $python_requirements = {},
Hash $python_dotfiles = {},
Boolean $use_epel = $python::params::use_epel,
Boolean $rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
Boolean $manage_scl = $python::params::manage_scl,
Optional[Python::Umask] $umask = undef,
) inherits python::params {
$exec_prefix = $provider ? {
'scl' => "/usr/bin/scl enable ${version} -- ",
'rhscl' => "/usr/bin/scl enable ${version} -- ",
default => '',
}

unless $version =~ Pattern[/\A(python)?[0-9](\.?[0-9])*/,
/\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] {
fail("version needs to be pypy, system or a version string like '36', '3.6' or 'python3.6' )")
}

# Module compatibility check
$compatible = ['Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX']
if ! ($facts['os']['family'] in $compatible) {
Expand Down
40 changes: 20 additions & 20 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@
# }
#
define python::pip (
String $pkgname = $name,
Variant[Enum[present, absent, latest], String[1]] $ensure = present,
Variant[Enum['system'], Stdlib::Absolutepath] $virtualenv = 'system',
String[1] $pip_provider = 'pip',
Variant[Boolean, String] $url = false,
String[1] $owner = 'root',
$group = getvar('python::params::group'),
$umask = undef,
$index = false,
Optional[Stdlib::HTTPUrl] $proxy = undef,
$egg = false,
Boolean $editable = false,
$environment = [],
$extras = [],
String $install_args = '',
String $uninstall_args = '',
Numeric $timeout = 1800,
String[1] $log_dir = '/tmp',
Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
String[1] $exec_provider = 'shell',
String[1] $pkgname = $name,
Variant[Enum[present, absent, latest], String[1]] $ensure = present,
Variant[Enum['system'], Stdlib::Absolutepath] $virtualenv = 'system',
String[1] $pip_provider = 'pip',
Variant[Boolean, String] $url = false,
String[1] $owner = 'root',
Optional[String[1]] $group = getvar('python::params::group'),
Optional[Python::Umask] $umask = undef,
Variant[Boolean,String[1]] $index = false,
Optional[Stdlib::HTTPUrl] $proxy = undef,
Any $egg = false,
Boolean $editable = false,
Array $environment = [],
Array $extras = [],
String $install_args = '',
String $uninstall_args = '',
Numeric $timeout = 1800,
String[1] $log_dir = '/tmp',
Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
String[1] $exec_provider = 'shell',
) {
$python_provider = getparam(Class['python'], 'provider')
$python_version = getparam(Class['python'], 'version')
Expand Down
10 changes: 5 additions & 5 deletions manifests/pip/bootstrap.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
# @param manage_python if python module will manage deps
# @param http_proxy Proxy server to use for outbound connections.
#
# @example
# @example
# class { 'python::pip::bootstrap':
# version => 'pip',
# }
class python::pip::bootstrap (
Enum['pip', 'pip3'] $version = 'pip',
Variant[Boolean, String] $manage_python = false,
Optional[Stdlib::HTTPUrl] $http_proxy = undef,
String[1] $exec_provider = 'shell',
Enum['pip', 'pip3'] $version = 'pip',
Variant[Boolean, String] $manage_python = false,
Optional[Stdlib::HTTPUrl] $http_proxy = undef,
String[1] $exec_provider = 'shell',
) inherits python::params {
if $manage_python {
include python
Expand Down
18 changes: 9 additions & 9 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
# }
#
define python::pyvenv (
$ensure = present,
$version = 'system',
$systempkgs = false,
$venv_dir = $name,
$owner = 'root',
$group = 'root',
$mode = '0755',
$path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'],
$environment = [],
$ensure = present,
$version = 'system',
$systempkgs = false,
$venv_dir = $name,
$owner = 'root',
$group = 'root',
$mode = '0755',
$path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'],
$environment = [],
) {
include python

Expand Down
30 changes: 15 additions & 15 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@
# }
#
define python::requirements (
$requirements = $name,
$virtualenv = 'system',
Enum['pip', 'pip3'] $pip_provider = 'pip',
$owner = 'root',
$group = 'root',
Optional[Stdlib::HTTPUrl] $proxy = undef,
$src = false,
$environment = [],
$forceupdate = false,
$cwd = undef,
$extra_pip_args = '',
$manage_requirements = true,
$fix_requirements_owner = true,
$log_dir = '/tmp',
$timeout = 1800,
String[1] $requirements = $name,
Variant[Enum['system'],Stdlib::Absolutepath] $virtualenv = 'system',
Enum['pip', 'pip3'] $pip_provider = 'pip',
String[1] $owner = 'root',
String[1] $group = 'root',
Optional[Stdlib::HTTPUrl] $proxy = undef,
Any $src = false,
Array $environment = [],
Boolean $forceupdate = false,
Stdlib::Absolutepath $cwd = undef,
String $extra_pip_args = '',
Boolean $manage_requirements = true,
Boolean $fix_requirements_owner = true,
Stdlib::Absolutepath $log_dir = '/tmp',
Integer $timeout = 1800,
) {
include python

Expand Down
38 changes: 19 additions & 19 deletions manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@
# }
#
define python::virtualenv (
$ensure = 'present',
$version = 'system',
$requirements = false,
$systempkgs = false,
$venv_dir = $name,
$ensure_venv_dir = true,
$distribute = true,
$index = false,
$owner = 'root',
$group = 'root',
$mode = '0755',
Optional[Stdlib::HTTPUrl] $proxy = undef,
$environment = [],
$path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'],
$cwd = undef,
$timeout = 1800,
$pip_args = '',
$extra_pip_args = '',
$virtualenv = undef,
$ensure = 'present',
$version = 'system',
$requirements = false,
$systempkgs = false,
$venv_dir = $name,
$ensure_venv_dir = true,
$distribute = true,
$index = false,
$owner = 'root',
$group = 'root',
$mode = '0755',
$proxy = undef,
$environment = [],
$path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'],
$cwd = undef,
$timeout = 1800,
$pip_args = '',
$extra_pip_args = '',
$virtualenv = undef,
) {
include python
$python_provider = getparam(Class['python'], 'provider')
Expand Down
3 changes: 3 additions & 0 deletions types/loglevel.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @summary A version type to match all valid versions for python
#
type Python::Loglevel = Enum['debug', 'info', 'warning', 'error', 'critical']
3 changes: 3 additions & 0 deletions types/provider.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @summary A version type to match all valid versions for python
#
type Python::Provider = Enum['pip', 'scl', 'rhscl', 'anaconda', '']
3 changes: 3 additions & 0 deletions types/umask.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @summary A version type to match all valid versions for python
#
type Python::Umask = Pattern[/[0-7]{1,4}/]
8 changes: 8 additions & 0 deletions types/version.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @summary A version type to match all valid versions for python
#
type Python::Version = Pattern[
/\A(python)?[0-9](\.?[0-9])*/,
/\Apypy\Z/,
/\Asystem\Z/,
/\Arh-python[0-9]{2}(?:-python)?\Z/
]

0 comments on commit e0a2a46

Please sign in to comment.