Skip to content

Commit 89e511c

Browse files
author
Joshua Spence
committed
Various tidying up
Various tidying up after pull request voxpupuli#241.
1 parent 78d0c09 commit 89e511c

File tree

7 files changed

+84
-42
lines changed

7 files changed

+84
-42
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ puppet module install stankevich-python
5050

5151
Installs and manages python, python-pip, python-dev, python-virtualenv and Gunicorn.
5252

53+
**ensure** - Desired installation state for the Python package. Options are absent, present and latest. Default: present
54+
5355
**version** - Python version to install. Default: system default
5456

55-
**pip** - Install python-pip. Default: true
57+
**pip** - Desired installation state for the python-pip package. Options are absent, present and latest. Default: present
5658

57-
**dev** - Install python-dev. Default: false
59+
**dev** - Desired installation state for the python-dev package. Options are absent, present and latest. Default: present
5860

59-
**virtualenv** - Install python-virtualenv. Default: false
61+
**virtualenv** - Desired installation state for the virtualenv package. Options are absent, present and latest. Default: present
6062

61-
**gunicorn** - Install Gunicorn. Default: false
63+
**gunicorn** - Desired installation state for Gunicorn. Options are absent, present and latest. Default: present
6264

6365
**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true
6466

@@ -67,10 +69,10 @@ Installs and manages python, python-pip, python-dev, python-virtualenv and Gunic
6769
```puppet
6870
class { 'python' :
6971
version => 'system',
70-
pip => true,
71-
dev => true,
72-
virtualenv => true,
73-
gunicorn => true,
72+
pip => 'present',
73+
dev => 'present',
74+
virtualenv => 'present',
75+
gunicorn => 'present',
7476
}
7577
```
7678

@@ -306,6 +308,9 @@ of the collection you want to use (e.g., 'python27', 'python33', or 'rh-python34
306308
307309
## Release Notes
308310
311+
**Version 1.9.8 Notes**
312+
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.
313+
309314
**Version 1.7.10 Notes**
310315

311316
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.

manifests/init.pp

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#
55
# === Parameters
66
#
7+
# [*ensure*]
8+
# Desired installation state for the Python package. Valid options are absent,
9+
# present and latest. Default: present
10+
#
711
# [*version*]
812
# Python version to install. Beware that valid values for this differ a) by
913
# the provider you choose and b) by the osfamily/operatingsystem you are using.
@@ -17,24 +21,31 @@
1721
# package, if available on your osfamily.
1822
#
1923
# [*pip*]
20-
# Install python-pip. Default: true
24+
# Desired installation state for python-pip. Boolean values are deprecated.
25+
# Default: present
26+
# Allowed values: 'absent', 'present', 'latest'
2127
#
2228
# [*dev*]
23-
# Install python-dev. Default: false
29+
# Desired installation state for python-dev. Boolean values are deprecated.
30+
# Default: absent
31+
# Allowed values: 'absent', 'present', 'latest'
2432
#
2533
# [*virtualenv*]
26-
# Install python-virtualenv. Default: false, also accepts 'pip' which will
27-
# install latest virtualenv from pip rather than package manager
34+
# Desired installation state for python-virtualenv. Boolean values are
35+
# deprecated. Default: absent
36+
# Allowed values: 'absent', 'present', 'latest
2837
#
2938
# [*gunicorn*]
30-
# Install Gunicorn. Default: false
39+
# Desired installation state for Gunicorn. Boolean values are deprecated.
40+
# Default: absent
41+
# Allowed values: 'absent', 'present', 'latest'
3142
#
3243
# [*manage_gunicorn*]
3344
# Allow Installation / Removal of Gunicorn. Default: true
3445
#
3546
# [*provider*]
36-
# What provider to use for installation of the packages, except gunicorn.
37-
# Default: system default provider
47+
# What provider to use for installation of the packages, except gunicorn and
48+
# Python itself. Default: system default provider
3849
# Allowed values: 'pip'
3950
#
4051
# [*use_epel*]
@@ -44,10 +55,10 @@
4455
#
4556
# class { 'python':
4657
# version => 'system',
47-
# pip => true,
48-
# dev => true,
49-
# virtualenv => true,
50-
# gunicorn => true,
58+
# pip => 'present',
59+
# dev => 'present',
60+
# virtualenv => 'present',
61+
# gunicorn => 'present',
5162
# }
5263
#
5364
# === Authors
@@ -85,7 +96,31 @@
8596

8697
validate_re($ensure, ['^(absent|present|latest)$'])
8798
validate_re($version, concat(['system', 'pypy'], $valid_versions))
88-
validate_bool($gunicorn)
99+
100+
if $pip == false or $pip == true {
101+
warning('Use of boolean values for the $pip parameter is deprecated')
102+
} else {
103+
validate_re($pip, ['^(absent|present|latest)$'])
104+
}
105+
106+
if $virtualenv == false or $virtualenv == true {
107+
warning('Use of boolean values for the $virtualenv parameter is deprecated')
108+
} else {
109+
validate_re($virtualenv, ['^(absent|present|latest)$'])
110+
}
111+
112+
if $virtualenv == false or $virtualenv == true {
113+
warning('Use of boolean values for the $virtualenv parameter is deprecated')
114+
} else {
115+
validate_re($virtualenv, ['^(absent|present|latest)$'])
116+
}
117+
118+
if $gunicorn == false or $gunicorn == true {
119+
warning('Use of boolean values for the $gunicorn parameter is deprecated')
120+
} else {
121+
validate_re($gunicorn, ['^(absent|present|latest)$'])
122+
}
123+
89124
validate_bool($manage_gunicorn)
90125
validate_bool($use_epel)
91126

manifests/install.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
provider => 'pip',
7171
}
7272
Package <| title == 'virtualenv' |> {
73+
name => 'virtualenv',
7374
provider => 'pip',
7475
}
7576
}
@@ -180,7 +181,8 @@
180181
if $python::manage_gunicorn {
181182
$gunicorn_ensure = $python::gunicorn ? {
182183
true => present,
183-
default => absent,
184+
false => absent,
185+
default => $python::gunicorn,
184186
}
185187
package { 'gunicorn': ensure => $gunicorn_ensure }
186188
}

manifests/params.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
class python::params {
66
$ensure = 'present'
77
$version = 'system'
8-
$pip = true
9-
$dev = false
10-
$virtualenv = false
11-
$gunicorn = false
8+
$pip = 'present'
9+
$dev = 'absent'
10+
$virtualenv = 'absent'
11+
$gunicorn = 'absent'
1212
$manage_gunicorn = true
1313
$provider = undef
1414
$valid_versions = $::osfamily ? {

spec/acceptance/facts_test_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
install_python = <<-EOS
77
class { 'python' :
88
version => 'system',
9-
pip => true,
10-
virtualenv => true,
9+
pip => 'present',
10+
virtualenv => 'present',
1111
}
1212
EOS
1313

spec/acceptance/virtualenv_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
pp = <<-EOS
99
class { 'python' :
1010
version => 'system',
11-
pip => true,
12-
virtualenv => true,
11+
pip => 'present',
12+
virtualenv => 'present',
1313
}
1414
->
1515
python::virtualenv { 'venv' :
16-
ensure => present,
16+
ensure => 'present',
1717
systempkgs => false,
18-
venv_dir => '/opt/venv',
19-
owner => 'root',
20-
group => 'root',
18+
venv_dir => '/opt/venv',
19+
owner => 'root',
20+
group => 'root',
2121
}
2222
->
2323
python::pip { 'rpyc' :
24-
ensure => '3.2.3',
24+
ensure => '3.2.3',
2525
virtualenv => '/opt/venv',
2626
}
2727
EOS

spec/classes/python_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
describe "with python::dev" do
2727
context "true" do
28-
let (:params) {{ :dev => true }}
28+
let (:params) {{ :dev => 'present' }}
2929
it { is_expected.to contain_package("python-dev").with_ensure('present') }
3030
end
3131
context "empty/default" do
@@ -83,7 +83,7 @@
8383

8484
describe "with python::dev" do
8585
context "true" do
86-
let (:params) {{ :dev => true }}
86+
let (:params) {{ :dev => 'present' }}
8787
it { is_expected.to contain_package("python-dev").with_ensure('present') }
8888
end
8989
context "default/empty" do
@@ -114,7 +114,7 @@
114114

115115
describe "with python::dev" do
116116
context "true" do
117-
let (:params) {{ :dev => true }}
117+
let (:params) {{ :dev => 'present' }}
118118
it { is_expected.to contain_package("python-dev").with_ensure('present') }
119119
end
120120
context "empty/default" do
@@ -157,7 +157,7 @@
157157

158158
describe "with python::virtualenv" do
159159
context "true" do
160-
let (:params) {{ :provider => '', :virtualenv => true }}
160+
let (:params) {{ :provider => '', :virtualenv => 'present' }}
161161
it { is_expected.to contain_package("virtualenv").with_ensure('present') }
162162
end
163163
end
@@ -173,7 +173,7 @@
173173

174174
describe "with python::dev" do
175175
context "true" do
176-
let (:params) {{ :dev => true }}
176+
let (:params) {{ :dev => 'present' }}
177177
it { is_expected.to contain_package("python-dev").with_ensure('present') }
178178
end
179179
context "default/empty" do
@@ -204,7 +204,7 @@
204204

205205
describe "with python::dev" do
206206
context "true" do
207-
let (:params) {{ :dev => true }}
207+
let (:params) {{ :dev => 'present' }}
208208
it { is_expected.to contain_package("python-dev").with_ensure('present') }
209209
end
210210
context "empty/default" do
@@ -247,7 +247,7 @@
247247

248248
describe "with python::virtualenv" do
249249
context "true" do
250-
let (:params) {{ :provider => '', :virtualenv => true }}
250+
let (:params) {{ :provider => '', :virtualenv => 'present' }}
251251
it { is_expected.to contain_package("virtualenv").with_ensure('present') }
252252
end
253253
end
@@ -263,7 +263,7 @@
263263

264264
describe "with python::dev" do
265265
context "true" do
266-
let (:params) {{ :dev => true }}
266+
let (:params) {{ :dev => 'present' }}
267267
it { is_expected.to contain_package("python-dev").with_ensure('present') }
268268
end
269269
context "default/empty" do

0 commit comments

Comments
 (0)