Skip to content

Commit 7520a85

Browse files
committed
fix parameter lists of manifests and puppet code style/lint/indent
1 parent 4c44d18 commit 7520a85

File tree

17 files changed

+479
-426
lines changed

17 files changed

+479
-426
lines changed

REFERENCE.md

Lines changed: 241 additions & 208 deletions
Large diffs are not rendered by default.

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Python::Virtualenv <| |> -> Python::Pip <| |>
1313

1414
if $python::manage_gunicorn {
15-
if $python::gunicorn != 'absent' {
15+
unless $python::gunicorn == 'absent' {
1616
Class['python::install'] -> Python::Gunicorn <| |>
1717

1818
Python::Gunicorn <| |> ~> Service['gunicorn']

manifests/dotfile.pp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
#
2525
define python::dotfile (
2626
Enum['absent', 'present'] $ensure = 'present',
27-
String[1] $filename = $title,
28-
String[1] $owner = 'root',
29-
String[1] $group = 'root',
30-
Stdlib::Filemode $mode = '0644',
31-
Hash $config = {},
27+
Stdlib::Absolutepath $filename = $title,
28+
String[1] $owner = 'root',
29+
String[1] $group = 'root',
30+
Stdlib::Filemode $mode = '0644',
31+
Hash $config = {},
3232
) {
3333
$parent_dir = dirname($filename)
3434

manifests/gunicorn.pp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@
3434
# }
3535
#
3636
define python::gunicorn (
37-
Stdlib::Absolutepath $dir,
38-
Enum['present', 'absent'] $ensure = present,
39-
$config_dir = '/etc/gunicorn.d',
40-
$manage_config_dir = false,
41-
$virtualenv = false,
42-
Enum['wsgi', 'django'] $mode = 'wsgi',
43-
$bind = false,
44-
$environment = false,
45-
$owner = 'www-data',
46-
$group = 'www-data',
47-
$appmodule = 'app:app',
48-
$osenv = false,
49-
$timeout = 30,
50-
$workers = false,
51-
$access_log_format = false,
52-
$accesslog = false,
53-
$errorlog = false,
54-
Enum['debug', 'info', 'warning', 'error', 'critical'] $log_level = 'error',
55-
$template = 'python/gunicorn.erb',
56-
$args = [],
37+
Stdlib::Absolutepath $dir,
38+
Enum['present', 'absent'] $ensure = present,
39+
Stdlib::Absolutepath $config_dir = '/etc/gunicorn.d',
40+
Booloean $manage_config_dir = false,
41+
Variant[Boolean,Stdlib::Absolutepath] $virtualenv = false,
42+
Enum['wsgi', 'django'] $mode = 'wsgi',
43+
Variant[String[1],Boolean] $bind = false,
44+
Variant[String[1],Boolean] $environment = false,
45+
String[1] $owner = 'www-data',
46+
String[1] $group = 'www-data',
47+
String[1] $appmodule = 'app:app',
48+
Variant[Boolean,Hash] $osenv = false,
49+
Integer $timeout = 30,
50+
Variant[Boolean,Integer] $workers = false,
51+
Variant[Boolean,String[1]] $access_log_format = false,
52+
Variant[Boolean,Stdlib::Absolutepath] $accesslog = false,
53+
Variant[Boolean,Stdlib::Absolutepath] $errorlog = false,
54+
Python::Loglevel $log_level = 'error',
55+
String[1] $template = 'python/gunicorn.erb',
56+
Array $args = [],
5757
) {
5858
if $manage_config_dir {
5959
file { $config_dir:
@@ -62,6 +62,7 @@
6262
owner => 'root',
6363
group => 'root',
6464
}
65+
6566
file { "${config_dir}/${name}":
6667
ensure => $ensure,
6768
mode => '0644',

manifests/init.pp

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,57 +36,45 @@
3636
# }
3737
#
3838
class python (
39-
Enum['absent', 'present', 'latest'] $ensure = $python::params::ensure,
40-
$version = $python::params::version,
41-
Enum['absent', 'present', 'latest'] $pip = $python::params::pip,
42-
Enum['absent', 'present', 'latest'] $dev = $python::params::dev,
43-
Enum['absent', 'present', 'latest'] $virtualenv = $python::params::virtualenv,
44-
Enum['absent', 'present', 'latest'] $gunicorn = $python::params::gunicorn,
45-
Boolean $manage_gunicorn = $python::params::manage_gunicorn,
46-
Boolean $manage_python_package = $python::params::manage_python_package,
47-
Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package,
48-
Boolean $manage_pip_package = $python::params::manage_pip_package,
49-
$gunicorn_package_name = $python::params::gunicorn_package_name,
50-
Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']] $provider = $python::params::provider,
51-
$valid_versions = $python::params::valid_versions,
52-
Hash $python_pips = {},
53-
Hash $python_virtualenvs = {},
54-
Hash $python_pyvenvs = {},
55-
Hash $python_requirements = {},
56-
Hash $python_dotfiles = {},
57-
Boolean $use_epel = $python::params::use_epel,
58-
$rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
59-
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
60-
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
61-
Boolean $manage_scl = $python::params::manage_scl,
62-
Optional[Pattern[/[0-7]{1,4}/]] $umask = undef,
39+
Python::Package::Ensure $ensure = $python::params::ensure,
40+
Python::Version $version = $python::params::version,
41+
Python::Package::Ensure $pip = $python::params::pip,
42+
Python::Package::Ensure $dev = $python::params::dev,
43+
Python::Package::Ensure $virtualenv = $python::params::virtualenv,
44+
Python::Package::Ensure $gunicorn = $python::params::gunicorn,
45+
Boolean $manage_gunicorn = $python::params::manage_gunicorn,
46+
Boolean $manage_python_package = $python::params::manage_python_package,
47+
Boolean $manage_virtualenv_package = $python::params::manage_virtualenv_package,
48+
Boolean $manage_pip_package = $python::params::manage_pip_package,
49+
String[1] $gunicorn_package_name = $python::params::gunicorn_package_name,
50+
Optional[Python::Provider] $provider = $python::params::provider,
51+
Hash $python_pips = {},
52+
Hash $python_virtualenvs = {},
53+
Hash $python_pyvenvs = {},
54+
Hash $python_requirements = {},
55+
Hash $python_dotfiles = {},
56+
Boolean $use_epel = $python::params::use_epel,
57+
Boolean $rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
58+
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
59+
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
60+
Boolean $manage_scl = $python::params::manage_scl,
61+
Optional[Python::Umask] $umask = undef,
6362
) inherits python::params {
6463
$exec_prefix = $provider ? {
6564
'scl' => "/usr/bin/scl enable ${version} -- ",
6665
'rhscl' => "/usr/bin/scl enable ${version} -- ",
6766
default => '',
6867
}
6968

70-
unless $version =~ Pattern[/\A(python)?[0-9](\.?[0-9])*/,
71-
/\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] {
72-
fail("version needs to be pypy, system or a version string like '36', '3.6' or 'python3.6' )")
73-
}
74-
75-
# Module compatibility check
76-
$compatible = ['Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX']
77-
if ! ($facts['os']['family'] in $compatible) {
78-
fail("Module is not compatible with ${facts['os']['name']}")
79-
}
80-
8169
contain python::install
8270
contain python::config
8371

8472
Class['python::install']
8573
-> Class['python::config']
8674

8775
# Set default umask.
88-
if $umask != undef {
89-
Exec { umask => $umask }
76+
exec { default:
77+
umask => $umask
9078
}
9179

9280
# Allow hiera configuration of python resources

manifests/install.pp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
if $venv_ensure == 'present' {
3838
$dev_ensure = 'present'
39+
3940
unless $python::dev {
4041
# Error: python2-devel is needed by (installed) python-virtualenv-15.1.0-2.el7.noarch
4142
# Python dev is required for virtual environment, but python environment is not required for python dev.
@@ -83,14 +84,15 @@
8384
# Respect the $pip_ensure setting
8485
unless $pip_ensure == 'absent' {
8586
# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
86-
include 'python::pip::bootstrap'
87+
include python::pip::bootstrap
8788

8889
Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>
8990

9091
Package <| title == 'pip' |> {
9192
name => 'pip',
9293
provider => 'pip',
9394
}
95+
9496
if $pythondev {
9597
Package <| title == 'virtualenv' |> {
9698
name => 'virtualenv',
@@ -119,6 +121,7 @@
119121
ensure => $install_scl_repo_package,
120122
before => Package['scl-utils'],
121123
}
124+
122125
package { 'scl-utils':
123126
ensure => 'present',
124127
before => Package['python'],
@@ -131,14 +134,10 @@
131134
}
132135
}
133136

134-
# This gets installed as a dependency anyway
135-
# package { "${python::version}-python-virtualenv":
136-
# ensure => $venv_ensure,
137-
# require => Package['scl-utils'],
138-
# }
139137
package { "${python}-scldevel":
140138
ensure => $dev_ensure,
141139
}
140+
142141
if $pip_ensure != 'absent' {
143142
exec { 'python-scl-pip-install':
144143
command => "${python::exec_prefix}easy_install pip",
@@ -151,6 +150,7 @@
151150
# rhscl is RedHat SCLs from softwarecollections.org
152151
if $python::rhscl_use_public_repository {
153152
$scl_package = "rhscl-${python::version}-epel-${facts['os']['release']['major']}-${facts['os']['architecture']}"
153+
154154
package { $scl_package:
155155
source => "https://www.softwarecollections.org/en/scls/rhscl/${python::version}/epel-${facts['os']['release']['major']}-${facts['os']['architecture']}/download/${scl_package}.noarch.rpm",
156156
provider => 'rpm',
@@ -181,8 +181,7 @@
181181
-> Package <| tag == 'python-scl-package' |>
182182
}
183183

184-
Package <| tag == 'python-scl-package' |>
185-
-> Package <| tag == 'python-pip-package' |>
184+
Package <| tag == 'python-scl-package' |> -> Package <| tag == 'python-pip-package' |>
186185
}
187186
'anaconda': {
188187
$installer_path = '/var/tmp/anaconda_installer.sh'
@@ -217,6 +216,7 @@
217216
}
218217
}
219218
}
219+
220220
if $pythondev {
221221
package { 'python-dev':
222222
ensure => $dev_ensure,
@@ -233,6 +233,7 @@
233233
require => Package['python'],
234234
}
235235
}
236+
236237
if $pythondev {
237238
package { 'python-dev':
238239
ensure => $dev_ensure,
@@ -245,18 +246,12 @@
245246

246247
case $facts['os']['family'] {
247248
'RedHat': {
248-
if $pip_ensure != 'absent' {
249-
if $python::use_epel == true {
250-
include 'epel'
251-
if $python::manage_pip_package { Class['epel'] -> Package['pip'] }
252-
if $python::manage_python_package { Class['epel'] -> Package['python'] }
253-
}
249+
if $pip_ensure != 'absent' and $python::use_epel and ($python::manage_pip_package or $python::manage_python_package) {
250+
require epel
254251
}
255-
if ($venv_ensure != 'absent') and ($facts['os']['release']['full'] =~ /^6/) {
256-
if $python::use_epel == true {
257-
include 'epel'
258-
Class['epel'] -> Package['virtualenv']
259-
}
252+
253+
if $venv_ensure != 'absent' and $facts['os']['release']['full'] =~ /^6/ and $python::use_epel {
254+
require epel
260255
}
261256

262257
$virtualenv_package = "${python}-virtualenv"
@@ -278,19 +273,19 @@
278273

279274
if String($python::version) =~ /^python3/ {
280275
$pip_category = undef
281-
$pip_package = "${python}-pip"
276+
$pip_package = "${python}-pip"
282277
$pip_provider = $python.regsubst(/^.*python3\.?/,'pip3.').regsubst(/\.$/,'')
283278
} elsif ($facts['os']['family'] == 'RedHat') and (versioncmp($facts['os']['release']['major'], '7') >= 0) {
284279
$pip_category = undef
285-
$pip_package = 'python2-pip'
280+
$pip_package = 'python2-pip'
286281
$pip_provider = pip2
287282
} elsif $facts['os']['family'] == 'Gentoo' {
288283
$pip_category = 'dev-python'
289-
$pip_package = 'pip'
284+
$pip_package = 'pip'
290285
$pip_provider = 'pip'
291286
} else {
292287
$pip_category = undef
293-
$pip_package = 'python-pip'
288+
$pip_package = 'python-pip'
294289
$pip_provider = 'pip'
295290
}
296291

manifests/params.pp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,32 @@
44
# The python Module default configuration settings.
55
#
66
class python::params {
7-
$ensure = 'present'
8-
$version = 'system'
9-
$pip = 'present'
10-
$dev = 'absent'
11-
$virtualenv = 'absent'
12-
$gunicorn = 'absent'
13-
$manage_gunicorn = true
14-
$manage_python_package = true
15-
$manage_virtualenv_package = true
16-
$manage_pip_package = true
17-
$provider = undef
18-
$valid_versions = undef
19-
$manage_scl = true
7+
# Module compatibility check
8+
unless $facts['os']['family'] in ['Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX',] {
9+
fail("Module is not compatible with ${facts['os']['name']}")
10+
}
11+
12+
$ensure = 'present'
13+
$version = 'system'
14+
$pip = 'present'
15+
$dev = 'absent'
16+
$virtualenv = 'absent'
17+
$gunicorn = 'absent'
18+
$manage_gunicorn = true
19+
$manage_python_package = true
20+
$manage_virtualenv_package = true
21+
$manage_pip_package = true
22+
$provider = undef
23+
$valid_versions = undef
24+
$manage_scl = true
25+
$rhscl_use_public_repository = true
26+
$anaconda_installer_url = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh'
27+
$anaconda_install_path = '/opt/python'
2028

21-
if $facts['os']['family'] == 'RedHat' {
22-
if $facts['os']['name'] != 'Fedora' {
23-
$use_epel = true
24-
} else {
25-
$use_epel = false
26-
}
29+
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
30+
$use_epel = true
2731
} else {
28-
$use_epel = false
32+
$use_epel = false
2933
}
3034

3135
$group = $facts['os']['family'] ? {
@@ -34,17 +38,12 @@
3438
}
3539

3640
$pip_lookup_path = $facts['os']['family'] ? {
37-
'AIX' => ['/bin', '/usr/bin', '/usr/local/bin', '/opt/freeware/bin/'],
38-
default => ['/bin', '/usr/bin', '/usr/local/bin']
41+
'AIX' => ['/bin', '/usr/bin', '/usr/local/bin', '/opt/freeware/bin/',],
42+
default => ['/bin', '/usr/bin', '/usr/local/bin',]
3943
}
4044

4145
$gunicorn_package_name = $facts['os']['family'] ? {
4246
'RedHat' => 'python-gunicorn',
4347
default => 'gunicorn',
4448
}
45-
46-
$rhscl_use_public_repository = true
47-
48-
$anaconda_installer_url = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh'
49-
$anaconda_install_path = '/opt/python'
5049
}

0 commit comments

Comments
 (0)