vanagon 0.15.10 → 0.15.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vanagon/component.rb +0 -1
- data/lib/vanagon/component/dsl.rb +16 -20
- data/lib/vanagon/platform.rb +0 -32
- data/lib/vanagon/platform/dsl.rb +2 -18
- data/lib/vanagon/project.rb +6 -6
- data/resources/deb/postinst.erb +13 -18
- data/resources/deb/postrm.erb +6 -6
- data/resources/deb/prerm.erb +8 -12
- data/resources/rpm/project.spec.erb +11 -11
- data/spec/lib/vanagon/component/dsl_spec.rb +8 -45
- data/spec/lib/vanagon/platform_spec.rb +0 -80
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd7f47d8b1278c31171ea168f3fd9c256852fa60
|
4
|
+
data.tar.gz: 5d8fe77d2118bcc5d504d63af7579f51ca6a1551
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ba4af17ff65f15b90a8c79944e32251986978b3c90102827fb978a9b2aee0ffec071041d7fd44b622b6c237edcc2a698776389c4cddf2049f9104dab8bbccc
|
7
|
+
data.tar.gz: 372a532f5eedc4efbd2f33c830c1a3835a91218a737d61c5359f37fd96a3de8cbf78674574972473377304e0c2030c7c259240753b3a9a4b231e29b78ae53acd
|
data/lib/vanagon/component.rb
CHANGED
@@ -163,40 +163,36 @@ class Vanagon
|
|
163
163
|
#
|
164
164
|
# @param service_file [String] path to the service file relative to the source
|
165
165
|
# @param default_file [String] path to the default file relative to the source
|
166
|
-
# @param
|
167
|
-
#
|
168
|
-
#
|
169
|
-
|
170
|
-
|
171
|
-
init_system = options[:init_system] || @component.platform.servicetype
|
172
|
-
servicedir = @component.platform.get_service_dir(init_system)
|
173
|
-
|
174
|
-
case init_system
|
166
|
+
# @param service_name [String] name of the service
|
167
|
+
# @param service_type [String] type of the service (network, application, system, etc)
|
168
|
+
# @param link_target [String] executable service file should be linked to
|
169
|
+
def install_service(service_file, default_file = nil, service_name = @component.name, service_type: nil, link_target: nil) # rubocop:disable Metrics/AbcSize
|
170
|
+
case @component.platform.servicetype
|
175
171
|
when "sysv"
|
176
|
-
target_service_file = File.join(servicedir, service_name)
|
172
|
+
target_service_file = File.join(@component.platform.servicedir, service_name)
|
177
173
|
target_default_file = File.join(@component.platform.defaultdir, service_name)
|
178
174
|
target_mode = '0755'
|
179
175
|
default_mode = '0644'
|
180
176
|
when "systemd"
|
181
|
-
target_service_file = File.join(servicedir, "#{service_name}.service")
|
177
|
+
target_service_file = File.join(@component.platform.servicedir, "#{service_name}.service")
|
182
178
|
target_default_file = File.join(@component.platform.defaultdir, service_name)
|
183
179
|
target_mode = '0644'
|
184
180
|
default_mode = '0644'
|
185
181
|
when "launchd"
|
186
|
-
target_service_file = File.join(servicedir, "#{service_name}.plist")
|
182
|
+
target_service_file = File.join(@component.platform.servicedir, "#{service_name}.plist")
|
187
183
|
target_mode = '0644'
|
188
184
|
default_mode = '0644'
|
189
185
|
when "smf"
|
190
|
-
target_service_file = File.join(servicedir,
|
186
|
+
target_service_file = File.join(@component.platform.servicedir, service_type.to_s, "#{service_name}.xml")
|
191
187
|
target_default_file = File.join(@component.platform.defaultdir, service_name)
|
192
188
|
target_mode = '0644'
|
193
189
|
default_mode = '0755'
|
194
190
|
when "aix"
|
195
|
-
@component.service
|
191
|
+
@component.service = OpenStruct.new(:name => service_name, :service_command => File.read(service_file).chomp)
|
196
192
|
# Return here because there is no file to install, just a string read in
|
197
193
|
return
|
198
194
|
when "windows"
|
199
|
-
@component.service
|
195
|
+
@component.service = OpenStruct.new(\
|
200
196
|
:bindir_id => "#{service_name.gsub(/[^A-Za-z0-9]/, '').upcase}BINDIR", \
|
201
197
|
:service_file => service_file, \
|
202
198
|
:component_group_id => "#{service_name.gsub(/[^A-Za-z0-9]/, '')}Component"\
|
@@ -204,13 +200,13 @@ class Vanagon
|
|
204
200
|
# return here as we are just collecting the name of the service file to put into the harvest filter list.
|
205
201
|
return
|
206
202
|
else
|
207
|
-
fail "Don't know how to install the #{
|
203
|
+
fail "Don't know how to install the #{@component.platform.servicetype}. Please teach #install_service how to do this."
|
208
204
|
end
|
209
205
|
|
210
206
|
# Install the service and default files
|
211
|
-
if
|
212
|
-
install_file(service_file,
|
213
|
-
link
|
207
|
+
if link_target
|
208
|
+
install_file(service_file, link_target, mode: target_mode)
|
209
|
+
link link_target, target_service_file
|
214
210
|
else
|
215
211
|
install_file(service_file, target_service_file, mode: target_mode)
|
216
212
|
end
|
@@ -221,7 +217,7 @@ class Vanagon
|
|
221
217
|
end
|
222
218
|
|
223
219
|
# Register the service for use in packaging
|
224
|
-
@component.service
|
220
|
+
@component.service = OpenStruct.new(:name => service_name, :service_file => target_service_file, :type => service_type)
|
225
221
|
end
|
226
222
|
|
227
223
|
# Copies a file from source to target during the install phase of the component
|
data/lib/vanagon/platform.rb
CHANGED
@@ -32,9 +32,6 @@ class Vanagon
|
|
32
32
|
# Where does a given platform expect to find init scripts/service files?
|
33
33
|
# e.g. /etc/init.d, /usr/lib/systemd/system
|
34
34
|
attr_accessor :servicedir
|
35
|
-
# Array of OpenStructs containing the servicetype and the corresponding
|
36
|
-
# servicedir
|
37
|
-
attr_accessor :servicetypes
|
38
35
|
# Where does a given platform's init system expect to find
|
39
36
|
# something resembling 'defaults' files. Most likely to apply
|
40
37
|
# to Linux systems that use SysV-ish, upstart, or systemd init systems.
|
@@ -242,7 +239,6 @@ class Vanagon
|
|
242
239
|
# Our first attempt at defining metadata about a platform
|
243
240
|
@cross_compiled ||= false
|
244
241
|
@valid_operators ||= ['<', '>', '<=', '>=', '=']
|
245
|
-
@servicetypes = []
|
246
242
|
end
|
247
243
|
|
248
244
|
def shell # rubocop:disable Lint/DuplicateMethods
|
@@ -534,33 +530,5 @@ class Vanagon
|
|
534
530
|
def validate_operator(operator_string)
|
535
531
|
valid_operators.include?(operator_string)
|
536
532
|
end
|
537
|
-
|
538
|
-
# Get all configured service types (added through plat.servicetype)
|
539
|
-
# @return array of service types, empty array if none have been configured
|
540
|
-
def get_service_types
|
541
|
-
if @servicetypes.any?
|
542
|
-
@servicetypes.flat_map(&:servicetype).compact
|
543
|
-
elsif @servicetype
|
544
|
-
[@servicetype]
|
545
|
-
else
|
546
|
-
[]
|
547
|
-
end
|
548
|
-
end
|
549
|
-
|
550
|
-
# Get configured service dir (added through plat.servicedir, or plat.servicetype 'foo', servicedir: 'bar')
|
551
|
-
# @param servicetype the service type you want the service dir for (optional)
|
552
|
-
# @raises VanagonError if more than one service dir is found
|
553
|
-
def get_service_dir(servicetype = '')
|
554
|
-
if @servicetypes.empty?
|
555
|
-
return @servicedir
|
556
|
-
end
|
557
|
-
servicedir = @servicetypes.select { |s| s.servicetype.include?(servicetype) }.flat_map(&:servicedir).compact
|
558
|
-
|
559
|
-
if servicedir.size > 1
|
560
|
-
raise Vanagon::Error, "You can only have one service dir for each service type. Found '#{servicedir.join(',')}' for service type #{servicetype}"
|
561
|
-
end
|
562
|
-
|
563
|
-
servicedir.first
|
564
|
-
end
|
565
533
|
end
|
566
534
|
end
|
data/lib/vanagon/platform/dsl.rb
CHANGED
@@ -9,7 +9,6 @@ require 'vanagon/platform/solaris_10'
|
|
9
9
|
require 'vanagon/platform/solaris_11'
|
10
10
|
require 'vanagon/platform/windows'
|
11
11
|
require 'securerandom'
|
12
|
-
require 'ostruct'
|
13
12
|
require 'uri'
|
14
13
|
|
15
14
|
class Vanagon
|
@@ -219,11 +218,6 @@ class Vanagon
|
|
219
218
|
# @param dir [String] Directory where service files live on the platform
|
220
219
|
def servicedir(dir)
|
221
220
|
@platform.servicedir = dir
|
222
|
-
|
223
|
-
# Add to the servicetypes array if we haven't already
|
224
|
-
if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty?
|
225
|
-
@platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir)
|
226
|
-
end
|
227
221
|
end
|
228
222
|
|
229
223
|
# Set the directory where default or sysconfig files live for the platform
|
@@ -236,18 +230,8 @@ class Vanagon
|
|
236
230
|
# Set the servicetype for the platform so that services can be installed correctly.
|
237
231
|
#
|
238
232
|
# @param type [String] service type for the platform ('sysv' for example)
|
239
|
-
|
240
|
-
|
241
|
-
if servicedir
|
242
|
-
@platform.servicetypes << OpenStruct.new(:servicetype => type, :servicedir => servicedir)
|
243
|
-
else
|
244
|
-
@platform.servicetype = type
|
245
|
-
end
|
246
|
-
|
247
|
-
# Add to the servicetypes array if we haven't already
|
248
|
-
if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty?
|
249
|
-
@platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir)
|
250
|
-
end
|
233
|
+
def servicetype(type)
|
234
|
+
@platform.servicetype = type
|
251
235
|
end
|
252
236
|
|
253
237
|
# Set the list of possible host to perform a build on (when not using
|
data/lib/vanagon/project.rb
CHANGED
@@ -293,14 +293,10 @@ class Vanagon
|
|
293
293
|
# will return nil
|
294
294
|
#
|
295
295
|
# @param [string] name of service to grab
|
296
|
-
# @return [@component.service obj] specific service
|
297
|
-
# if there's more than one
|
296
|
+
# @return [@component.service obj] specific service
|
298
297
|
def get_service(name)
|
299
298
|
components.each do |component|
|
300
299
|
if component.name == name
|
301
|
-
if component.service.size == 1
|
302
|
-
return component.service.first
|
303
|
-
end
|
304
300
|
return component.service
|
305
301
|
end
|
306
302
|
end
|
@@ -747,7 +743,11 @@ class Vanagon
|
|
747
743
|
sum: settings_sha1_uri,
|
748
744
|
sum_type: 'sha1')
|
749
745
|
source.fetch
|
750
|
-
|
746
|
+
yaml_path = source.file
|
747
|
+
if source_type == :http
|
748
|
+
yaml_path = File.join(working_directory, source.file)
|
749
|
+
end
|
750
|
+
@settings.merge!(YAML.safe_load(File.read(yaml_path), [Symbol]))
|
751
751
|
end
|
752
752
|
end
|
753
753
|
end
|
data/resources/deb/postinst.erb
CHANGED
@@ -2,23 +2,18 @@
|
|
2
2
|
<%- get_services.each do |service| -%>
|
3
3
|
# switch based on systemd vs systemv
|
4
4
|
#
|
5
|
-
<%- if
|
6
|
-
if [ -
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
systemctl try-restart <%= service.name %>.service >/dev/null || :
|
11
|
-
fi
|
5
|
+
<%- if @platform.servicetype == "systemd" -%>
|
6
|
+
if [ -z "$2" ]; then
|
7
|
+
systemctl enable <%= service.name %>.service >/dev/null || :
|
8
|
+
else
|
9
|
+
systemctl try-restart <%= service.name %>.service >/dev/null || :
|
12
10
|
fi
|
13
|
-
<%-
|
14
|
-
|
15
|
-
|
16
|
-
if [ -x "<%= service.service_file %>" ]; then
|
17
|
-
update-rc.d <%= service.name %> defaults > /dev/null
|
11
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
12
|
+
if [ -x "<%= service.service_file %>" ]; then
|
13
|
+
update-rc.d <%= service.name %> defaults > /dev/null
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
fi
|
15
|
+
if [ -n "$2" ]; then
|
16
|
+
invoke-rc.d <%= service.name %> condrestart || true
|
22
17
|
fi
|
23
18
|
fi
|
24
19
|
<%- end -%>
|
@@ -32,17 +27,17 @@ fi
|
|
32
27
|
|
33
28
|
# Set up any specific permissions needed...
|
34
29
|
<%- (get_directories + get_configfiles + get_files).select { |pathname| pathname.has_overrides? }.uniq.each do |file_or_directory| -%>
|
35
|
-
<%= "chmod '#{file_or_directory.mode}' '#{file_or_directory.path}'
|
30
|
+
<%= "chmod '#{file_or_directory.mode}' '#{file_or_directory.path}'" if file_or_directory.mode %>
|
36
31
|
<%- if file_or_directory.owner -%>
|
37
32
|
if getent passwd '<%= file_or_directory.owner %>' &> /dev/null; then
|
38
|
-
chown '<%= file_or_directory.owner %>' '<%= file_or_directory.path %>'
|
33
|
+
chown '<%= file_or_directory.owner %>' '<%= file_or_directory.path %>'
|
39
34
|
else
|
40
35
|
echo "Error updating '<%= file_or_directory.path %>': user '<%= file_or_directory.owner %>' does not exist."
|
41
36
|
fi
|
42
37
|
<%- end -%>
|
43
38
|
<%- if file_or_directory.group -%>
|
44
39
|
if getent group '<%= file_or_directory.group %>' &> /dev/null; then
|
45
|
-
chgrp '<%= file_or_directory.group %>' '<%= file_or_directory.path %>'
|
40
|
+
chgrp '<%= file_or_directory.group %>' '<%= file_or_directory.path %>'
|
46
41
|
else
|
47
42
|
echo "Error updating '<%= file_or_directory.path %>': group '<%= file_or_directory.group %>' does not exist."
|
48
43
|
fi
|
data/resources/deb/postrm.erb
CHANGED
@@ -13,11 +13,11 @@ fi
|
|
13
13
|
<%- get_services.each do |service| -%>
|
14
14
|
# switch based on systemd vs systemv
|
15
15
|
#
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
fi
|
16
|
+
<%- if @platform.servicetype == "systemd" -%>
|
17
|
+
systemctl daemon-reload >/dev/null 2>&1 || :
|
18
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
19
|
+
if [ "$1" = "purge" ] ; then
|
20
|
+
update-rc.d <%= service.name %> remove > /dev/null
|
22
21
|
fi
|
22
|
+
<%- end -%>
|
23
23
|
<%- end -%>
|
data/resources/deb/prerm.erb
CHANGED
@@ -13,19 +13,15 @@ fi
|
|
13
13
|
<%- get_services.each do |service| -%>
|
14
14
|
# switch based on systemd vs systemv
|
15
15
|
#
|
16
|
-
<%- if
|
17
|
-
if [
|
18
|
-
|
19
|
-
|
20
|
-
systemctl stop <%= service.name %>.service > /dev/null 2>&1 || :
|
21
|
-
fi
|
16
|
+
<%- if @platform.servicetype == "systemd" -%>
|
17
|
+
if [ "$1" = remove ]; then
|
18
|
+
systemctl --no-reload disable <%= service.name %>.service > /dev/null 2>&1 || :
|
19
|
+
systemctl stop <%= service.name %>.service > /dev/null 2>&1 || :
|
22
20
|
fi
|
23
|
-
|
24
|
-
<%-
|
25
|
-
if [
|
26
|
-
|
27
|
-
invoke-rc.d <%= service.name %> stop || true
|
28
|
-
fi
|
21
|
+
|
22
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
23
|
+
if [ -x "<%= service.service_file %>" ] && [ "$1" = remove ]; then
|
24
|
+
invoke-rc.d <%= service.name %> stop || true
|
29
25
|
fi
|
30
26
|
<%- end -%>
|
31
27
|
<%- end -%>
|
@@ -76,7 +76,7 @@ Requires(post): /bin/touch
|
|
76
76
|
<%- end -%>
|
77
77
|
|
78
78
|
<%- if has_services? -%>
|
79
|
-
<%- if @platform.
|
79
|
+
<%- if @platform.servicetype == "systemd" -%>
|
80
80
|
<%- if @platform.is_sles? -%>
|
81
81
|
BuildRequires: systemd
|
82
82
|
%{?systemd_requires}
|
@@ -86,7 +86,7 @@ Requires(post): systemd
|
|
86
86
|
Requires(preun): systemd
|
87
87
|
Requires(postun): systemd
|
88
88
|
<%- end -%>
|
89
|
-
<%- elsif @platform.
|
89
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
90
90
|
<%- if @platform.is_sles? -%>
|
91
91
|
Requires: aaa_base
|
92
92
|
<%- elsif @platform.is_linux? -%>
|
@@ -230,15 +230,15 @@ fi
|
|
230
230
|
<%- get_services.each do |service| -%>
|
231
231
|
# switch based on systemd vs systemv vs smf vs aix
|
232
232
|
#
|
233
|
-
<%- if @platform.
|
233
|
+
<%- if @platform.servicetype == "systemd" -%>
|
234
234
|
<%- if @platform.is_sles? -%>
|
235
235
|
%service_add_post <%= service.name %>.service
|
236
236
|
<%- else -%>
|
237
237
|
%systemd_post <%= service.name %>.service
|
238
238
|
<%- end -%>
|
239
|
-
<%- elsif @platform.
|
239
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
240
240
|
chkconfig --add <%= service.name %> >/dev/null 2>&1 || :
|
241
|
-
<%- elsif @platform.
|
241
|
+
<%- elsif @platform.servicetype == "aix" -%>
|
242
242
|
if /usr/bin/lssrc -s <%= service.name -%> > /dev/null 2>&1; then
|
243
243
|
/usr/bin/chssys -s <%= service.name -%> -p <%= service.service_command -%> -w 7 -S -n 15 -f 9 > /dev/null 2>&1 || :
|
244
244
|
else
|
@@ -279,17 +279,17 @@ fi
|
|
279
279
|
<%- get_services.each do |service| -%>
|
280
280
|
# switch based on systemd vs systemv vs smf vs aix
|
281
281
|
#
|
282
|
-
<%- if @platform.
|
282
|
+
<%- if @platform.servicetype == "systemd" -%>
|
283
283
|
<%- if @platform.is_sles? -%>
|
284
284
|
%service_del_postun <%= service.name %>.service
|
285
285
|
<%- else -%>
|
286
286
|
%systemd_postun_with_restart <%= service.name %>.service
|
287
287
|
<%- end -%>
|
288
|
-
<%- elsif @platform.
|
288
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
289
289
|
if [ "$1" -eq 1 ]; then
|
290
290
|
/sbin/service <%= service.name %> condrestart || :
|
291
291
|
fi
|
292
|
-
<%- elsif @platform.
|
292
|
+
<%- elsif @platform.servicetype == "aix" -%>
|
293
293
|
if [ "$1" -eq 0 ]; then
|
294
294
|
/usr/bin/rmssys -s <%= service.name -%> > /dev/null 2>&1 || :
|
295
295
|
/usr/sbin/rmitab <%= service.name -%> > /dev/null 2>&1 || :
|
@@ -310,18 +310,18 @@ if [ "$1" -eq 0 ] ; then
|
|
310
310
|
fi
|
311
311
|
|
312
312
|
<%- get_services.each do |service| -%>
|
313
|
-
<%- if @platform.
|
313
|
+
<%- if @platform.servicetype == "systemd" -%>
|
314
314
|
<%- if @platform.is_sles? -%>
|
315
315
|
%service_del_preun <%= service.name %>.service
|
316
316
|
<%- else -%>
|
317
317
|
%systemd_preun <%= service.name %>.service
|
318
318
|
<%- end -%>
|
319
|
-
<%- elsif @platform.
|
319
|
+
<%- elsif @platform.servicetype == "sysv" -%>
|
320
320
|
if [ "$1" -eq 0 ]; then
|
321
321
|
/sbin/service <%= service.name %> stop >/dev/null 2>&1 || :
|
322
322
|
chkconfig --del <%= service.name %> || :
|
323
323
|
fi
|
324
|
-
<%- elsif @platform.
|
324
|
+
<%- elsif @platform.servicetype == "aix" -%>
|
325
325
|
# stop the service only on a real uninstall, not on upgrades
|
326
326
|
if [ "$1" -eq 0 ] ; then
|
327
327
|
/usr/bin/stopsrc -s <%= service.name -%> > /dev/null 2>&1 || :
|
@@ -33,16 +33,6 @@ end" }
|
|
33
33
|
plat._platform
|
34
34
|
}
|
35
35
|
|
36
|
-
let (:dummy_platform_sysv_or_systemd) {
|
37
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
38
|
-
plat.instance_eval("platform 'debian-8-x86_64' do |plat|
|
39
|
-
plat.servicetype 'sysv', servicedir: '/etc/init.d'
|
40
|
-
plat.servicetype 'systemd', servicedir: '/usr/lib/systemd/system'
|
41
|
-
plat.defaultdir '/etc/default'
|
42
|
-
end")
|
43
|
-
plat._platform
|
44
|
-
}
|
45
|
-
|
46
36
|
let (:dummy_platform_smf) {
|
47
37
|
plat = Vanagon::Platform::DSL.new('debian-11-i386')
|
48
38
|
plat.instance_eval("platform 'debian-11-i386' do |plat|
|
@@ -577,15 +567,15 @@ end" }
|
|
577
567
|
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/etc/init.d/service-test', mode: '0755'))
|
578
568
|
|
579
569
|
# The component should now have a service registered
|
580
|
-
expect(comp._component.service.
|
570
|
+
expect(comp._component.service.name).to eq('service-test')
|
581
571
|
end
|
582
572
|
|
583
573
|
it 'reads from a file when the OS is AIX for services' do
|
584
574
|
comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_aix)
|
585
575
|
comp.install_service('spec/fixtures/component/mcollective.service', nil, 'mcollective')
|
586
|
-
expect(comp._component.service.
|
587
|
-
expect(comp._component.service.
|
588
|
-
expect(comp._component.service.
|
576
|
+
expect(comp._component.service.name).to eq('mcollective')
|
577
|
+
expect(comp._component.service.service_command).to include('/opt/puppetlabs/puppet/bin/ruby')
|
578
|
+
expect(comp._component.service.service_command).not_to include("\n")
|
589
579
|
end
|
590
580
|
|
591
581
|
it 'adds the correct command to the install for the component for systemd platforms' do
|
@@ -604,34 +594,7 @@ end" }
|
|
604
594
|
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/usr/lib/systemd/system/service-test.service', mode: '0644'))
|
605
595
|
|
606
596
|
# The component should now have a service registered
|
607
|
-
expect(comp._component.service.
|
608
|
-
end
|
609
|
-
|
610
|
-
it 'adds the correct command when installing both systemd and sysv' do
|
611
|
-
comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_sysv_or_systemd)
|
612
|
-
comp.install_service('component-client.init', 'component-client.sysconfig', init_system: 'sysv')
|
613
|
-
comp.install_service('component-client.service', 'component-client.sysconfig', init_system: 'systemd')
|
614
|
-
# Look for servicedir creation and copy - sysv
|
615
|
-
expect(comp._component.install).to include("install -d '/etc/init.d'")
|
616
|
-
expect(comp._component.install).to include("cp -p 'component-client.init' '/etc/init.d/service-test'")
|
617
|
-
|
618
|
-
# Look for servicedir creation and copy - systemd
|
619
|
-
expect(comp._component.install).to include("install -d '/usr/lib/systemd/system'")
|
620
|
-
expect(comp._component.install).to include("cp -p 'component-client.service' '/usr/lib/systemd/system/service-test.service'")
|
621
|
-
|
622
|
-
# Look for defaultdir creation and copy
|
623
|
-
expect(comp._component.install).to include("install -d '/etc/default'")
|
624
|
-
expect(comp._component.install).to include("cp -p 'component-client.sysconfig' '/etc/default/service-test'")
|
625
|
-
|
626
|
-
# Look for files and configfiles - sysv
|
627
|
-
expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/etc/default/service-test'))
|
628
|
-
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/etc/init.d/service-test', mode: '0755'))
|
629
|
-
|
630
|
-
# Look for files and configfiles - systemd
|
631
|
-
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/usr/lib/systemd/system/service-test.service', mode: '0644'))
|
632
|
-
|
633
|
-
# The component should now have a service registered
|
634
|
-
expect(comp._component.service.flat_map(&:name).compact).to include('service-test')
|
597
|
+
expect(comp._component.service.name).to eq('service-test')
|
635
598
|
end
|
636
599
|
|
637
600
|
it 'adds the correct command to the install for smf services using a service_type' do
|
@@ -650,7 +613,7 @@ end" }
|
|
650
613
|
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/var/svc/manifest/network/service-test.xml', mode: '0644'))
|
651
614
|
|
652
615
|
# The component should now have a service registered
|
653
|
-
expect(comp._component.service.
|
616
|
+
expect(comp._component.service.name).to eq('service-test')
|
654
617
|
end
|
655
618
|
|
656
619
|
it 'adds the correct command to the install for smf services' do
|
@@ -669,7 +632,7 @@ end" }
|
|
669
632
|
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/var/svc/manifest/service-test.xml', mode: '0644'))
|
670
633
|
|
671
634
|
# The component should now have a service registered
|
672
|
-
expect(comp._component.service.
|
635
|
+
expect(comp._component.service.name).to eq('service-test')
|
673
636
|
end
|
674
637
|
|
675
638
|
it 'installs the file as a link when link_target is specified' do
|
@@ -690,7 +653,7 @@ end" }
|
|
690
653
|
expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/etc/init.d/service-test'))
|
691
654
|
|
692
655
|
# The component should now have a service registered
|
693
|
-
expect(comp._component.service.
|
656
|
+
expect(comp._component.service.name).to eq('service-test')
|
694
657
|
end
|
695
658
|
end
|
696
659
|
|
@@ -1,33 +1,6 @@
|
|
1
1
|
require 'vanagon/platform'
|
2
2
|
|
3
3
|
describe "Vanagon::Platform" do
|
4
|
-
let(:deb_platform_just_servicedir) { "platform 'debian-test-fixture' do |plat|
|
5
|
-
plat.servicedir '/etc/init.d'
|
6
|
-
end
|
7
|
-
"}
|
8
|
-
let(:deb_platform_just_servicetype) { "platform 'debian-test-fixture' do |plat|
|
9
|
-
plat.servicetype 'sysv'
|
10
|
-
end
|
11
|
-
"}
|
12
|
-
let(:deb_platform_multi_servicetypes) { "platform 'debian-test-fixture' do |plat|
|
13
|
-
plat.servicetype 'sysv', servicedir: '/etc/init.d'
|
14
|
-
plat.servicetype 'systemd', servicedir: '/lib/systemd/system'
|
15
|
-
end
|
16
|
-
"}
|
17
|
-
let(:deb_platform_no_service) { "platform 'debian-test-fixture' do |plat|
|
18
|
-
end
|
19
|
-
"}
|
20
|
-
let(:deb_platform_servicetype) { "platform 'debian-test-fixture' do |plat|
|
21
|
-
plat.servicetype 'sysv'
|
22
|
-
plat.servicedir '/etc/init.d'
|
23
|
-
end
|
24
|
-
"}
|
25
|
-
let(:deb_platform_bad_servicedir_block) { "platform 'debian-test-fixture' do |plat|
|
26
|
-
plat.servicetype 'sysv', servicedir: '/etc/init.d'
|
27
|
-
plat.servicetype 'sysv', servicedir: '/etc/rc.d'
|
28
|
-
end
|
29
|
-
"}
|
30
|
-
|
31
4
|
let(:platforms) do
|
32
5
|
[
|
33
6
|
{
|
@@ -199,57 +172,4 @@ describe "Vanagon::Platform" do
|
|
199
172
|
end
|
200
173
|
end
|
201
174
|
end
|
202
|
-
|
203
|
-
describe "#get_service_type" do
|
204
|
-
it "returns plat.servicetype if that's the only thing set" do
|
205
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
206
|
-
plat.instance_eval(deb_platform_just_servicetype)
|
207
|
-
expect(plat._platform.get_service_types).to include('sysv')
|
208
|
-
end
|
209
|
-
|
210
|
-
it "returns from servicetypes if that's set" do
|
211
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
212
|
-
plat.instance_eval(deb_platform_servicetype)
|
213
|
-
expect(plat._platform.get_service_types).to include('sysv')
|
214
|
-
end
|
215
|
-
|
216
|
-
it "returns multiples if there's more than one" do
|
217
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
218
|
-
plat.instance_eval(deb_platform_multi_servicetypes)
|
219
|
-
expect(plat._platform.get_service_types).to include('sysv')
|
220
|
-
expect(plat._platform.get_service_types).to include('systemd')
|
221
|
-
end
|
222
|
-
|
223
|
-
it "returns an empty array if nothing is set" do
|
224
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
225
|
-
plat.instance_eval(deb_platform_no_service)
|
226
|
-
expect(plat._platform.get_service_types.size).to eq(0)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe "#get_service_dir" do
|
231
|
-
it "returns plat.servicedir if that's the only thing set" do
|
232
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
233
|
-
plat.instance_eval(deb_platform_just_servicedir)
|
234
|
-
expect(plat._platform.get_service_dir).to eq('/etc/init.d')
|
235
|
-
end
|
236
|
-
|
237
|
-
it "returns servicedirs set via servicetype" do
|
238
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
239
|
-
plat.instance_eval(deb_platform_servicetype)
|
240
|
-
expect(plat._platform.get_service_dir).to eq('/etc/init.d')
|
241
|
-
end
|
242
|
-
|
243
|
-
it "returns the servicedir based on servicetype" do
|
244
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
245
|
-
plat.instance_eval(deb_platform_multi_servicetypes)
|
246
|
-
expect(plat._platform.get_service_dir('systemd')).to eq('/lib/systemd/system')
|
247
|
-
end
|
248
|
-
|
249
|
-
it "fails if there are >1 servicedir for a service type" do
|
250
|
-
plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
|
251
|
-
plat.instance_eval(deb_platform_bad_servicedir_block)
|
252
|
-
expect { plat._platform.get_service_dir('sysv') }.to raise_error(Vanagon::Error)
|
253
|
-
end
|
254
|
-
end
|
255
175
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|