forked from voxpupuli/puppet-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.pp
More file actions
95 lines (89 loc) · 2.8 KB
/
init.pp
File metadata and controls
95 lines (89 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# == Class: python
#
# Installs and manages python, python-dev, python-virtualenv and Gunicorn.
#
# === Parameters
#
# [*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
# 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.
#
# [*pip*]
# Install python-pip. Default: true
#
# [*dev*]
# Install python-dev. Default: false
#
# [*virtualenv*]
# Install python-virtualenv. Default: false, also accepts 'pip' which will
# install latest virtualenv from pip rather than package manager
#
# [*gunicorn*]
# Install Gunicorn. Default: false
#
# [*manage_gunicorn*]
# Allow Installation / Removal of Gunicorn. Default: true
#
# [*provider*]
# What provider to use for installation of the packages, except gunicorn.
# Default: system default provider
# Allowed values: 'pip'
#
# === Examples
#
# class { 'python':
# version => 'system',
# pip => true,
# dev => true,
# virtualenv => true,
# gunicorn => true,
# }
#
# === Authors
#
# Sergey Stankevich
#
class python (
$version = $python::params::version,
$pip = $python::params::pip,
$dev = $python::params::dev,
$virtualenv = $python::params::virtualenv,
$gunicorn = $python::params::gunicorn,
$manage_gunicorn = $python::params::manage_gunicorn,
$provider = $python::params::provider,
$valid_versions = $python::params::valid_versions,
) inherits python::params{
# validate inputs
if $provider != undef {
validate_re($provider, ['^pip$'], 'Only "pip" is a valid provider besides the system default.')
}
if $provider == 'pip' {
validate_re($version, ['^(2\.[4-7]\.\d|3\.\d\.\d)$','^system$'])
# this will only be checked if not pip, every other string would be rejected by provider check
} else {
validate_re($version, concat(['system', 'pypy'], $valid_versions))
}
validate_bool($pip)
validate_bool($dev)
validate_bool($virtualenv)
validate_bool($gunicorn)
validate_bool($manage_gunicorn)
# Module compatibility check
$compatible = [ 'Debian', 'RedHat']
if ! ($::osfamily in $compatible) {
fail("Module is not compatible with ${::operatingsystem}")
}
# Anchor pattern to contain dependencies
anchor { 'python::begin': } ->
class { 'python::install': } ->
class { 'python::config': } ->
anchor { 'python::end': }
}