File tree Expand file tree Collapse file tree 8 files changed +151
-0
lines changed
fixtures/cookbooks/osl-resources-test/recipes Expand file tree Collapse file tree 8 files changed +151
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ source 'https://supermarket.chef.io'
2
2
3
3
solver :ruby , :required
4
4
5
+ cookbook 'osl-repos' , git :
'[email protected] :osuosl-cookbooks/osl-repos'
5
6
cookbook 'osl-resources-test' , path : 'test/fixtures/cookbooks/osl-resources-test'
6
7
7
8
metadata
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ suites:
43
43
- name : osl_packagecloud_repo
44
44
run_list :
45
45
- recipe[osl-resources-test::osl_packagecloud_repo]
46
+ - name : osl_python
47
+ run_list :
48
+ - recipe[osl-resources-test::osl_python]
46
49
- name : osl_route
47
50
excludes :
48
51
- debian-11
Original file line number Diff line number Diff line change @@ -78,6 +78,56 @@ def osl_local_ipv6?
78
78
local
79
79
end
80
80
81
+ def osl_python_packages
82
+ case node [ 'platform_family' ]
83
+ when 'rhel'
84
+ case node [ 'platform_version' ] . to_i
85
+ when 8
86
+ %w(
87
+ python2
88
+ python2-devel
89
+ python2-pip
90
+ python2-setuptools
91
+ python2-virtualenv
92
+ python3-pip
93
+ python3-setuptools
94
+ python3-virtualenv
95
+ python36
96
+ python36-devel
97
+ )
98
+ when 7
99
+ %w(
100
+ python
101
+ python2-pip
102
+ python3
103
+ python3-devel
104
+ python3-pip
105
+ python3-setuptools
106
+ python-devel
107
+ python-setuptools
108
+ python-virtualenv
109
+ )
110
+ end
111
+ when 'debian'
112
+ case node [ 'platform_version' ] . to_i
113
+ when 11
114
+ %w(
115
+ python3
116
+ python3-dev
117
+ python3-pip
118
+ python3-setuptools
119
+ python3-virtualenv
120
+ python3-wheel
121
+ python2-dev
122
+ python-pip-whl
123
+ python-setuptools
124
+ virtualenv
125
+ python-wheel-common
126
+ )
127
+ end
128
+ end
129
+ end
130
+
81
131
private
82
132
83
133
def osl_local_ip
Original file line number Diff line number Diff line change 9
9
version '1.2.4'
10
10
11
11
depends 'line'
12
+ depends 'osl-repos'
12
13
13
14
supports 'centos' , '~> 7.0'
14
15
supports 'centos_stream' , '~> 8.0'
Original file line number Diff line number Diff line change
1
+ resource_name :osl_python
2
+ provides :osl_python
3
+ unified_mode true
4
+
5
+ default_action :install
6
+
7
+ action :install do
8
+ if platform_family? ( 'rhel' ) && node [ 'platform_version' ] . to_i < 8
9
+ include_recipe 'osl-repos::epel'
10
+ end
11
+
12
+ package 'install python packages' do
13
+ package_name osl_python_packages
14
+ end
15
+
16
+ # Debian 11 does not ship with pip2
17
+ if platform_family? ( 'debian' )
18
+ get_pip = ::File . join ( Chef ::Config [ :file_cache_path ] , 'get-pip.py' )
19
+
20
+ remote_file get_pip do
21
+ source 'https://bootstrap.pypa.io/pip/2.7/get-pip.py'
22
+ not_if { ::File . exist? ( '/usr/local/bin/pip2' ) }
23
+ end
24
+
25
+ execute "python2 #{ get_pip } " do
26
+ creates '/usr/local/bin/pip2'
27
+ end
28
+
29
+ link '/usr/bin/pip2' do
30
+ to '/usr/local/bin/pip2'
31
+ end
32
+ end
33
+ end
Original file line number Diff line number Diff line change
1
+ osl_python 'default'
Original file line number Diff line number Diff line change
1
+ control 'osl_python' do
2
+ title 'Verify python is configured'
3
+
4
+ os_family = os . family
5
+ os_release = os . release . to_i
6
+
7
+ case os_family
8
+ when 'redhat'
9
+ case os_release
10
+ when 8
11
+ packages = %w(
12
+ python2
13
+ python2-devel
14
+ python2-pip
15
+ python2-setuptools
16
+ python2-virtualenv
17
+ python3-pip
18
+ python3-setuptools
19
+ python3-virtualenv
20
+ python36
21
+ python36-devel
22
+ )
23
+ when 7
24
+ packages = %w(
25
+ python
26
+ python2-pip
27
+ python3
28
+ python3-devel
29
+ python3-pip
30
+ python3-setuptools
31
+ python-devel
32
+ python-setuptools
33
+ python-virtualenv
34
+ )
35
+ end
36
+ when 'debian'
37
+ case os_release
38
+ when 11
39
+ packages = %w(
40
+ python3
41
+ python3-dev
42
+ python3-pip
43
+ python3-setuptools
44
+ python3-virtualenv
45
+ python3-wheel
46
+ python2-dev
47
+ python-pip-whl
48
+ python-setuptools
49
+ virtualenv
50
+ python-wheel-common
51
+ )
52
+ end
53
+ end
54
+
55
+ packages . each do |pkg |
56
+ describe package pkg do
57
+ it { should be_installed }
58
+ end
59
+ end
60
+ end
Original file line number Diff line number Diff line change
1
+ ---
2
+ name : osl_python
You can’t perform that action at this time.
0 commit comments