File tree 7 files changed +63
-18
lines changed
7 files changed +63
-18
lines changed Original file line number Diff line number Diff line change 10
10
11
11
* [ ` python ` ] ( #python ) : Installs and manages python, python-dev and gunicorn.
12
12
* [ ` python::install::dev ` ] ( #python--install--dev ) : Installs python development packages
13
+ * [ ` python::install::venv ` ] ( #python--install--venv ) : Installs python virtualenv packages
13
14
* [ ` python::pip::bootstrap ` ] ( #python--pip--bootstrap ) : allow to bootstrap pip when python is managed from other module
14
15
15
16
#### Private Classes
@@ -294,6 +295,10 @@ Default value: `'/opt/python'`
294
295
295
296
Installs python development packages
296
297
298
+ ### <a name =" python--install--venv " ></a >` python::install::venv `
299
+
300
+ Installs python virtualenv packages
301
+
297
302
### <a name =" python--pip--bootstrap " ></a >` python::pip::bootstrap `
298
303
299
304
allow to bootstrap pip when python is managed from other module
Original file line number Diff line number Diff line change 32
32
}
33
33
34
34
if $python::manage_venv_package {
35
- # #
36
- # # CentOS has no extra package for venv
37
- # #
38
- unless $facts [' os' ][' family' ] == ' RedHat' {
39
- package { 'python-venv' :
40
- ensure => $python::venv ,
41
- name => " ${python} -venv" ,
42
- require => Package[' python' ],
43
- }
44
- }
35
+ contain python::install::venv
45
36
}
46
37
47
38
case $python::provider {
Original file line number Diff line number Diff line change
1
+ # @summary Installs python virtualenv packages
2
+ class python::install::venv {
3
+ include python
4
+
5
+ # Main python package bundle venv on some operating systems
6
+ unless $facts [' os' ][' family' ] in [' Archlinux' , ' FreeBSD' , ' RedHat' ] {
7
+ package { 'python-venv' :
8
+ ensure => $python::venv ,
9
+ name => " ${python::install::python} -venv" ,
10
+ require => Package[' python' ],
11
+ }
12
+ }
13
+ }
Original file line number Diff line number Diff line change 40
40
}
41
41
$manage_venv_package = $facts [' os' ][' family' ] ? {
42
42
' Archlinux' => false ,
43
+ ' FreeBSD' => false ,
44
+ ' RedHat' => false ,
43
45
default => true ,
44
46
}
45
47
}
Original file line number Diff line number Diff line change 36
36
Python::Venv::PipVersion $pip_version = ' latest' ,
37
37
) {
38
38
include python
39
+ include python::install::venv
39
40
40
41
if $ensure == ' present' {
41
42
$python_version = $version ? {
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'python::install::venv' do
6
+ on_supported_os . each do |os , facts |
7
+ context "on #{ os } " do
8
+ let :facts do
9
+ facts
10
+ end
11
+
12
+ context 'with default settings' do
13
+ if %w[ Archlinux FreeBSD RedHat ] . include? ( facts [ :os ] [ 'family' ] )
14
+ it { is_expected . not_to contain_package ( 'python-venv' ) }
15
+ else
16
+ it { is_expected . to contain_package ( 'python-venv' ) . with ( ensure : 'absent' ) }
17
+ end
18
+ end
19
+
20
+ context 'when ensuring venv is setup' do
21
+ let ( :pre_condition ) do
22
+ <<~PP
23
+ class { 'python':
24
+ venv => present,
25
+ }
26
+ PP
27
+ end
28
+
29
+ if %w[ Archlinux FreeBSD RedHat ] . include? ( facts [ :os ] [ 'family' ] )
30
+ it { is_expected . not_to contain_package ( 'python-venv' ) }
31
+ else
32
+ it { is_expected . to contain_package ( 'python-venv' ) . with ( ensure : 'present' ) }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
Original file line number Diff line number Diff line change 23
23
it { is_expected . to contain_package ( 'pip' ) }
24
24
end
25
25
26
- if %w[ Archlinux RedHat ] . include? ( facts [ :os ] [ 'family' ] )
27
- it { is_expected . not_to contain_package ( 'python- venv' ) }
26
+ if %w[ Archlinux FreeBSD RedHat ] . include? ( facts [ :os ] [ 'family' ] )
27
+ it { is_expected . not_to contain_class ( 'python::install:: venv' ) }
28
28
else
29
- it { is_expected . to contain_package ( 'python- venv' ) }
29
+ it { is_expected . to contain_class ( 'python::install:: venv' ) }
30
30
end
31
31
end
32
32
44
44
it { is_expected . not_to contain_package ( 'python' ) }
45
45
it { is_expected . not_to contain_package ( 'python-dev' ) }
46
46
it { is_expected . not_to contain_package ( 'pip' ) }
47
- it { is_expected . not_to contain_package ( 'python- venv' ) }
47
+ it { is_expected . not_to contain_class ( 'python::install:: venv' ) }
48
48
end
49
49
50
50
context 'with packages present' do
51
51
let :params do
52
52
{
53
53
manage_pip_package : true ,
54
- manage_venv_package : true ,
55
54
pip : 'present' ,
56
- venv : 'present'
57
55
}
58
56
end
59
57
60
58
it { is_expected . to compile . with_all_deps }
61
59
it { is_expected . to contain_package ( 'pip' ) . with ( ensure : 'present' ) }
62
-
63
- it { is_expected . to contain_package ( 'python-venv' ) . with ( ensure : 'present' ) } unless facts [ :os ] [ 'family' ] == 'RedHat'
64
60
end
65
61
66
62
case facts [ :os ] [ 'family' ]
You can’t perform that action at this time.
0 commit comments