Skip to content

Commit b519893

Browse files
authored
Merge pull request #500 from tdukaric/choose_to_manage_packages
Add option for not managing python and virtualenv packages.
2 parents fe96d62 + a6b8f4d commit b519893

File tree

5 files changed

+112
-29
lines changed

5 files changed

+112
-29
lines changed

REFERENCE.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,30 @@ The default umask for invoked exec calls.
155155

156156
Default value: `undef`
157157

158+
##### `manage_python_package`
159+
160+
Data type: `Boolean`
161+
162+
163+
164+
Default value: $python::params::manage_python_package
165+
166+
##### `manage_virtualenv_package`
167+
168+
Data type: `Boolean`
169+
170+
171+
172+
Default value: $python::params::manage_virtualenv_package
173+
174+
##### `manage_pip_package`
175+
176+
Data type: `Boolean`
177+
178+
179+
180+
Default value: $python::params::manage_pip_package
181+
158182
##### `gunicorn_package_name`
159183

160184
Data type: `Any`
@@ -277,6 +301,14 @@ Proxy server to use for outbound connections.
277301

278302
Default value: `undef`
279303

304+
##### `exec_provider`
305+
306+
Data type: `String[1]`
307+
308+
309+
310+
Default value: 'shell'
311+
280312
## Defined types
281313

282314
### python::dotfile
@@ -746,6 +778,14 @@ Data type: `Array[String]`
746778

747779
Default value: ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin']
748780

781+
##### `exec_provider`
782+
783+
Data type: `String[1]`
784+
785+
786+
787+
Default value: 'shell'
788+
749789
### python::pyvenv
750790

751791
Create a Python3 virtualenv using pyvenv.

manifests/init.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
Enum['absent', 'present', 'latest'] $virtualenv = $python::params::virtualenv,
4444
Enum['absent', 'present', 'latest'] $gunicorn = $python::params::gunicorn,
4545
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,
4649
$gunicorn_package_name = $python::params::gunicorn_package_name,
4750
Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']] $provider = $python::params::provider,
4851
$valid_versions = $python::params::valid_versions,

manifests/install.pp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,29 @@
5050
}
5151
}
5252

53-
package { 'python':
54-
ensure => $python::ensure,
55-
name => $python,
53+
if $python::manage_python_package {
54+
package { 'python':
55+
ensure => $python::ensure,
56+
name => $python,
57+
}
5658
}
5759

58-
package { 'virtualenv':
59-
ensure => $venv_ensure,
60-
name => "${python}-virtualenv",
61-
require => Package['python'],
60+
if $python::manage_virtualenv_package {
61+
package { 'virtualenv':
62+
ensure => $venv_ensure,
63+
name => "${python}-virtualenv",
64+
require => Package['python'],
65+
}
6266
}
6367

6468
case $python::provider {
6569
'pip': {
6670

67-
package { 'pip':
68-
ensure => $pip_ensure,
69-
require => Package['python'],
71+
if $python::manage_pip_package {
72+
package { 'pip':
73+
ensure => $pip_ensure,
74+
require => Package['python'],
75+
}
7076
}
7177

7278
if $pythondev {
@@ -205,10 +211,12 @@
205211
version => 'pip3',
206212
}
207213
} else {
208-
package { 'python-pip':
209-
ensure => $pip_ensure,
210-
require => Package['python'],
211-
provider => 'yum',
214+
if $python::manage_pip_package {
215+
package { 'python-pip':
216+
ensure => $pip_ensure,
217+
require => Package['python'],
218+
provider => 'yum',
219+
}
212220
}
213221
}
214222
if $pythondev {
@@ -222,9 +230,11 @@
222230

223231
}
224232
default: {
225-
package { 'pip':
226-
ensure => $pip_ensure,
227-
require => Package['python'],
233+
if $python::manage_pip_package {
234+
package { 'pip':
235+
ensure => $pip_ensure,
236+
require => Package['python'],
237+
}
228238
}
229239
if $pythondev {
230240
package { 'python-dev':
@@ -242,8 +252,8 @@
242252
if $pip_ensure != 'absent' {
243253
if $python::use_epel == true {
244254
include 'epel'
245-
Class['epel'] -> Package['pip']
246-
Class['epel'] -> Package['python']
255+
if $python::manage_pip_package { Class['epel'] -> Package['pip'] }
256+
if $python::manage_python_package { Class['epel'] -> Package['python'] }
247257
}
248258
}
249259
if ($venv_ensure != 'absent') and ($facts['os']['release']['full'] =~ /^6/) {

manifests/params.pp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
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-
$provider = undef
15-
$valid_versions = undef
16-
$manage_scl = true
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
1720

1821
if $facts['os']['family'] == 'RedHat' {
1922
if $facts['os']['name'] != 'Fedora' {

spec/classes/python_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@
88
facts
99
end
1010

11+
context 'with defaults' do
12+
it { is_expected.to compile.with_all_deps }
13+
it { is_expected.to contain_class('python::install') }
14+
it { is_expected.to contain_class('python::params') }
15+
it { is_expected.to contain_class('python::config') }
16+
it { is_expected.to contain_package('python') }
17+
it { is_expected.to contain_package('virtualenv') }
18+
it { is_expected.to contain_package('pip') }
19+
end
20+
21+
context 'without managing things' do
22+
let :params do
23+
{
24+
manage_python_package: false,
25+
manage_virtualenv_package: false,
26+
manage_pip_package: false
27+
}
28+
end
29+
30+
it { is_expected.to compile.with_all_deps }
31+
it { is_expected.not_to contain_package('python') }
32+
it { is_expected.not_to contain_package('virtualenv') }
33+
it { is_expected.not_to contain_package('pip') }
34+
end
35+
1136
case facts[:os]['family']
1237
when 'Debian'
1338

@@ -37,9 +62,11 @@
3762
context 'true' do
3863
let(:params) { { dev: 'present' } }
3964

65+
it { is_expected.to compile.with_all_deps }
4066
it { is_expected.to contain_package('python-dev').with_ensure('present') }
4167
end
4268
context 'empty/default' do
69+
it { is_expected.to compile.with_all_deps }
4370
it { is_expected.to contain_package('python-dev').with_ensure('absent') }
4471
end
4572
end

0 commit comments

Comments
 (0)