chef-utils 18.0.161 → 18.0.169

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/Rakefile +15 -15
  4. data/chef-utils.gemspec +50 -50
  5. data/lib/chef-utils/dist.rb +154 -154
  6. data/lib/chef-utils/dsl/architecture.rb +150 -150
  7. data/lib/chef-utils/dsl/cloud.rb +155 -155
  8. data/lib/chef-utils/dsl/default_paths.rb +60 -60
  9. data/lib/chef-utils/dsl/introspection.rb +134 -134
  10. data/lib/chef-utils/dsl/os.rb +58 -58
  11. data/lib/chef-utils/dsl/path_sanity.rb +39 -39
  12. data/lib/chef-utils/dsl/platform.rb +387 -387
  13. data/lib/chef-utils/dsl/platform_family.rb +360 -360
  14. data/lib/chef-utils/dsl/platform_version.rb +41 -41
  15. data/lib/chef-utils/dsl/service.rb +112 -112
  16. data/lib/chef-utils/dsl/train_helpers.rb +87 -87
  17. data/lib/chef-utils/dsl/virtualization.rb +272 -272
  18. data/lib/chef-utils/dsl/which.rb +123 -123
  19. data/lib/chef-utils/dsl/windows.rb +86 -86
  20. data/lib/chef-utils/internal.rb +114 -114
  21. data/lib/chef-utils/mash.rb +263 -263
  22. data/lib/chef-utils/parallel_map.rb +131 -131
  23. data/lib/chef-utils/version.rb +20 -20
  24. data/lib/chef-utils/version_string.rb +160 -160
  25. data/lib/chef-utils.rb +53 -53
  26. data/spec/spec_helper.rb +100 -100
  27. data/spec/unit/dsl/architecture_spec.rb +151 -151
  28. data/spec/unit/dsl/cloud_spec.rb +93 -93
  29. data/spec/unit/dsl/dsl_spec.rb +34 -34
  30. data/spec/unit/dsl/introspection_spec.rb +201 -201
  31. data/spec/unit/dsl/os_spec.rb +175 -175
  32. data/spec/unit/dsl/path_sanity_spec.rb +86 -86
  33. data/spec/unit/dsl/platform_family_spec.rb +235 -235
  34. data/spec/unit/dsl/platform_spec.rb +252 -252
  35. data/spec/unit/dsl/service_spec.rb +117 -117
  36. data/spec/unit/dsl/virtualization_spec.rb +75 -75
  37. data/spec/unit/dsl/which_spec.rb +171 -171
  38. data/spec/unit/dsl/windows_spec.rb +84 -84
  39. data/spec/unit/mash_spec.rb +51 -51
  40. data/spec/unit/parallel_map_spec.rb +156 -156
  41. metadata +3 -3
@@ -1,117 +1,117 @@
1
- # frozen_string_literal: true
2
- #
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- RSpec.describe ChefUtils::DSL::Service do
22
- class ServiceTestClass
23
- include ChefUtils::DSL::Service
24
- end
25
-
26
- let(:test_instance) { ServiceTestClass.new }
27
-
28
- context "#debianrcd?" do
29
- it "is true if the binary is installed" do
30
- expect(File).to receive(:exist?).with("/usr/sbin/update-rc.d").and_return(true)
31
- expect(test_instance.debianrcd?).to be true
32
- end
33
- it "is false if the binary is not installed" do
34
- expect(File).to receive(:exist?).with("/usr/sbin/update-rc.d").and_return(false)
35
- expect(test_instance.debianrcd?).to be false
36
- end
37
- end
38
-
39
- context "#invokercd?" do
40
- it "is true if the binary is installed" do
41
- expect(File).to receive(:exist?).with("/usr/sbin/invoke-rc.d").and_return(true)
42
- expect(test_instance.invokercd?).to be true
43
- end
44
- it "is false if the binary is not installed" do
45
- expect(File).to receive(:exist?).with("/usr/sbin/invoke-rc.d").and_return(false)
46
- expect(test_instance.invokercd?).to be false
47
- end
48
- end
49
-
50
- context "#upstart?" do
51
- it "is true if the binary is installed" do
52
- expect(File).to receive(:exist?).with("/sbin/initctl").and_return(true)
53
- expect(test_instance.upstart?).to be true
54
- end
55
- it "is false if the binary is not installed" do
56
- expect(File).to receive(:exist?).with("/sbin/initctl").and_return(false)
57
- expect(test_instance.upstart?).to be false
58
- end
59
- end
60
-
61
- context "#insserv?" do
62
- it "is true if the binary is installed" do
63
- expect(File).to receive(:exist?).with("/sbin/insserv").and_return(true)
64
- expect(test_instance.insserv?).to be true
65
- end
66
- it "is false if the binary is not installed" do
67
- expect(File).to receive(:exist?).with("/sbin/insserv").and_return(false)
68
- expect(test_instance.insserv?).to be false
69
- end
70
- end
71
-
72
- context "#redhatrcd?" do
73
- it "is true if the binary is installed" do
74
- expect(File).to receive(:exist?).with("/sbin/chkconfig").and_return(true)
75
- expect(test_instance.redhatrcd?).to be true
76
- end
77
- it "is false if the binary is not installed" do
78
- expect(File).to receive(:exist?).with("/sbin/chkconfig").and_return(false)
79
- expect(test_instance.redhatrcd?).to be false
80
- end
81
- end
82
-
83
- context "#service_script_exist?" do
84
- it "is true if the type is :initd and /etc/init.d script exists" do
85
- expect(File).to receive(:exist?).with("/etc/init.d/example").and_return(true)
86
- expect(test_instance.service_script_exist?(:initd, "example")).to be true
87
- end
88
- it "is false if the type is :initd and /etc/init.d script does not exist" do
89
- expect(File).to receive(:exist?).with("/etc/init.d/example").and_return(false)
90
- expect(test_instance.service_script_exist?(:initd, "example")).to be false
91
- end
92
- it "is true if the type is :upstart and /etc/init script exists" do
93
- expect(File).to receive(:exist?).with("/etc/init/example.conf").and_return(true)
94
- expect(test_instance.service_script_exist?(:upstart, "example")).to be true
95
- end
96
- it "is false if the type is :upstart and /etc/init script does not exist" do
97
- expect(File).to receive(:exist?).with("/etc/init/example.conf").and_return(false)
98
- expect(test_instance.service_script_exist?(:upstart, "example")).to be false
99
- end
100
- it "is true if the type is :xinetd and /etc/xinetd.d script exists" do
101
- expect(File).to receive(:exist?).with("/etc/xinetd.d/example").and_return(true)
102
- expect(test_instance.service_script_exist?(:xinetd, "example")).to be true
103
- end
104
- it "is false if the type is :xinetd and /etc/xinetd.d script does not exist" do
105
- expect(File).to receive(:exist?).with("/etc/xinetd.d/example").and_return(false)
106
- expect(test_instance.service_script_exist?(:xinetd, "example")).to be false
107
- end
108
- it "is true if the type is :etc_rcd and /etc/rc.d script exists" do
109
- expect(File).to receive(:exist?).with("/etc/rc.d/example").and_return(true)
110
- expect(test_instance.service_script_exist?(:etc_rcd, "example")).to be true
111
- end
112
- it "is false if the type is :etc_rcd and /etc/rc.d script does not exist" do
113
- expect(File).to receive(:exist?).with("/etc/rc.d/example").and_return(false)
114
- expect(test_instance.service_script_exist?(:etc_rcd, "example")).to be false
115
- end
116
- end
117
- end
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+
21
+ RSpec.describe ChefUtils::DSL::Service do
22
+ class ServiceTestClass
23
+ include ChefUtils::DSL::Service
24
+ end
25
+
26
+ let(:test_instance) { ServiceTestClass.new }
27
+
28
+ context "#debianrcd?" do
29
+ it "is true if the binary is installed" do
30
+ expect(File).to receive(:exist?).with("/usr/sbin/update-rc.d").and_return(true)
31
+ expect(test_instance.debianrcd?).to be true
32
+ end
33
+ it "is false if the binary is not installed" do
34
+ expect(File).to receive(:exist?).with("/usr/sbin/update-rc.d").and_return(false)
35
+ expect(test_instance.debianrcd?).to be false
36
+ end
37
+ end
38
+
39
+ context "#invokercd?" do
40
+ it "is true if the binary is installed" do
41
+ expect(File).to receive(:exist?).with("/usr/sbin/invoke-rc.d").and_return(true)
42
+ expect(test_instance.invokercd?).to be true
43
+ end
44
+ it "is false if the binary is not installed" do
45
+ expect(File).to receive(:exist?).with("/usr/sbin/invoke-rc.d").and_return(false)
46
+ expect(test_instance.invokercd?).to be false
47
+ end
48
+ end
49
+
50
+ context "#upstart?" do
51
+ it "is true if the binary is installed" do
52
+ expect(File).to receive(:exist?).with("/sbin/initctl").and_return(true)
53
+ expect(test_instance.upstart?).to be true
54
+ end
55
+ it "is false if the binary is not installed" do
56
+ expect(File).to receive(:exist?).with("/sbin/initctl").and_return(false)
57
+ expect(test_instance.upstart?).to be false
58
+ end
59
+ end
60
+
61
+ context "#insserv?" do
62
+ it "is true if the binary is installed" do
63
+ expect(File).to receive(:exist?).with("/sbin/insserv").and_return(true)
64
+ expect(test_instance.insserv?).to be true
65
+ end
66
+ it "is false if the binary is not installed" do
67
+ expect(File).to receive(:exist?).with("/sbin/insserv").and_return(false)
68
+ expect(test_instance.insserv?).to be false
69
+ end
70
+ end
71
+
72
+ context "#redhatrcd?" do
73
+ it "is true if the binary is installed" do
74
+ expect(File).to receive(:exist?).with("/sbin/chkconfig").and_return(true)
75
+ expect(test_instance.redhatrcd?).to be true
76
+ end
77
+ it "is false if the binary is not installed" do
78
+ expect(File).to receive(:exist?).with("/sbin/chkconfig").and_return(false)
79
+ expect(test_instance.redhatrcd?).to be false
80
+ end
81
+ end
82
+
83
+ context "#service_script_exist?" do
84
+ it "is true if the type is :initd and /etc/init.d script exists" do
85
+ expect(File).to receive(:exist?).with("/etc/init.d/example").and_return(true)
86
+ expect(test_instance.service_script_exist?(:initd, "example")).to be true
87
+ end
88
+ it "is false if the type is :initd and /etc/init.d script does not exist" do
89
+ expect(File).to receive(:exist?).with("/etc/init.d/example").and_return(false)
90
+ expect(test_instance.service_script_exist?(:initd, "example")).to be false
91
+ end
92
+ it "is true if the type is :upstart and /etc/init script exists" do
93
+ expect(File).to receive(:exist?).with("/etc/init/example.conf").and_return(true)
94
+ expect(test_instance.service_script_exist?(:upstart, "example")).to be true
95
+ end
96
+ it "is false if the type is :upstart and /etc/init script does not exist" do
97
+ expect(File).to receive(:exist?).with("/etc/init/example.conf").and_return(false)
98
+ expect(test_instance.service_script_exist?(:upstart, "example")).to be false
99
+ end
100
+ it "is true if the type is :xinetd and /etc/xinetd.d script exists" do
101
+ expect(File).to receive(:exist?).with("/etc/xinetd.d/example").and_return(true)
102
+ expect(test_instance.service_script_exist?(:xinetd, "example")).to be true
103
+ end
104
+ it "is false if the type is :xinetd and /etc/xinetd.d script does not exist" do
105
+ expect(File).to receive(:exist?).with("/etc/xinetd.d/example").and_return(false)
106
+ expect(test_instance.service_script_exist?(:xinetd, "example")).to be false
107
+ end
108
+ it "is true if the type is :etc_rcd and /etc/rc.d script exists" do
109
+ expect(File).to receive(:exist?).with("/etc/rc.d/example").and_return(true)
110
+ expect(test_instance.service_script_exist?(:etc_rcd, "example")).to be true
111
+ end
112
+ it "is false if the type is :etc_rcd and /etc/rc.d script does not exist" do
113
+ expect(File).to receive(:exist?).with("/etc/rc.d/example").and_return(false)
114
+ expect(test_instance.service_script_exist?(:etc_rcd, "example")).to be false
115
+ end
116
+ end
117
+ end
@@ -1,75 +1,75 @@
1
- # frozen_string_literal: true
2
- #
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
- require "fauxhai"
21
-
22
- def virtualization_reports_true_for(*args, node:)
23
- args.each do |method|
24
- it "reports true for #{method}" do
25
- expect(described_class.send(method, node)).to be true
26
- end
27
- end
28
- (VIRTUALIZATION_HELPERS - args).each do |method|
29
- it "reports false for #{method}" do
30
- expect(described_class.send(method, node)).to be false
31
- end
32
- end
33
- end
34
-
35
- RSpec.describe ChefUtils::DSL::Virtualization do
36
- ( HELPER_MODULES - [ described_class ] ).each do |klass|
37
- it "does not have methods that collide with #{klass}" do
38
- expect((klass.methods - Module.methods) & VIRTUALIZATION_HELPERS).to be_empty
39
- end
40
- end
41
-
42
- VIRTUALIZATION_HELPERS.each do |helper|
43
- it "has the #{helper} in the ChefUtils module" do
44
- expect(ChefUtils).to respond_to(helper)
45
- end
46
- end
47
-
48
- context "on kvm" do
49
- virtualization_reports_true_for(:guest?, :virtual?, :kvm?, node: { "virtualization" => { "system" => "kvm", "role" => "guest" } })
50
- virtualization_reports_true_for(:hypervisor?, :physical?, :kvm_host?, node: { "virtualization" => { "system" => "kvm", "role" => "host" } })
51
- end
52
- context "on lxc" do
53
- virtualization_reports_true_for(:guest?, :virtual?, :lxc?, node: { "virtualization" => { "system" => "lxc", "role" => "guest" } })
54
- virtualization_reports_true_for(:hypervisor?, :physical?, :lxc_host?, node: { "virtualization" => { "system" => "lxc", "role" => "host" } })
55
- end
56
- context "on parallels" do
57
- virtualization_reports_true_for(:guest?, :virtual?, :parallels?, node: { "virtualization" => { "system" => "parallels", "role" => "guest" } })
58
- virtualization_reports_true_for(:hypervisor?, :physical?, :parallels_host?, node: { "virtualization" => { "system" => "parallels", "role" => "host" } })
59
- end
60
- context "on virtualbox" do
61
- virtualization_reports_true_for(:guest?, :virtual?, :virtualbox?, :vbox?, node: { "virtualization" => { "system" => "vbox", "role" => "guest" } })
62
- virtualization_reports_true_for(:hypervisor?, :physical?, :vbox_host?, node: { "virtualization" => { "system" => "vbox", "role" => "host" } })
63
- end
64
- context "on vmware" do
65
- virtualization_reports_true_for(:guest?, :virtual?, :vmware?, node: { "virtualization" => { "system" => "vmware", "role" => "guest" } })
66
- virtualization_reports_true_for(:hypervisor?, :physical?, :vmware_host?, node: { "virtualization" => { "system" => "vmware", "role" => "host" } })
67
- end
68
- context "on openvz" do
69
- virtualization_reports_true_for(:guest?, :virtual?, :openvz?, node: { "virtualization" => { "system" => "openvz", "role" => "guest" } })
70
- virtualization_reports_true_for(:hypervisor?, :physical?, :openvz_host?, node: { "virtualization" => { "system" => "openvz", "role" => "host" } })
71
- end
72
- context "on metal which is not a virt host" do
73
- virtualization_reports_true_for(:physical?, node: {} )
74
- end
75
- end
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+ require "fauxhai"
21
+
22
+ def virtualization_reports_true_for(*args, node:)
23
+ args.each do |method|
24
+ it "reports true for #{method}" do
25
+ expect(described_class.send(method, node)).to be true
26
+ end
27
+ end
28
+ (VIRTUALIZATION_HELPERS - args).each do |method|
29
+ it "reports false for #{method}" do
30
+ expect(described_class.send(method, node)).to be false
31
+ end
32
+ end
33
+ end
34
+
35
+ RSpec.describe ChefUtils::DSL::Virtualization do
36
+ ( HELPER_MODULES - [ described_class ] ).each do |klass|
37
+ it "does not have methods that collide with #{klass}" do
38
+ expect((klass.methods - Module.methods) & VIRTUALIZATION_HELPERS).to be_empty
39
+ end
40
+ end
41
+
42
+ VIRTUALIZATION_HELPERS.each do |helper|
43
+ it "has the #{helper} in the ChefUtils module" do
44
+ expect(ChefUtils).to respond_to(helper)
45
+ end
46
+ end
47
+
48
+ context "on kvm" do
49
+ virtualization_reports_true_for(:guest?, :virtual?, :kvm?, node: { "virtualization" => { "system" => "kvm", "role" => "guest" } })
50
+ virtualization_reports_true_for(:hypervisor?, :physical?, :kvm_host?, node: { "virtualization" => { "system" => "kvm", "role" => "host" } })
51
+ end
52
+ context "on lxc" do
53
+ virtualization_reports_true_for(:guest?, :virtual?, :lxc?, node: { "virtualization" => { "system" => "lxc", "role" => "guest" } })
54
+ virtualization_reports_true_for(:hypervisor?, :physical?, :lxc_host?, node: { "virtualization" => { "system" => "lxc", "role" => "host" } })
55
+ end
56
+ context "on parallels" do
57
+ virtualization_reports_true_for(:guest?, :virtual?, :parallels?, node: { "virtualization" => { "system" => "parallels", "role" => "guest" } })
58
+ virtualization_reports_true_for(:hypervisor?, :physical?, :parallels_host?, node: { "virtualization" => { "system" => "parallels", "role" => "host" } })
59
+ end
60
+ context "on virtualbox" do
61
+ virtualization_reports_true_for(:guest?, :virtual?, :virtualbox?, :vbox?, node: { "virtualization" => { "system" => "vbox", "role" => "guest" } })
62
+ virtualization_reports_true_for(:hypervisor?, :physical?, :vbox_host?, node: { "virtualization" => { "system" => "vbox", "role" => "host" } })
63
+ end
64
+ context "on vmware" do
65
+ virtualization_reports_true_for(:guest?, :virtual?, :vmware?, node: { "virtualization" => { "system" => "vmware", "role" => "guest" } })
66
+ virtualization_reports_true_for(:hypervisor?, :physical?, :vmware_host?, node: { "virtualization" => { "system" => "vmware", "role" => "host" } })
67
+ end
68
+ context "on openvz" do
69
+ virtualization_reports_true_for(:guest?, :virtual?, :openvz?, node: { "virtualization" => { "system" => "openvz", "role" => "guest" } })
70
+ virtualization_reports_true_for(:hypervisor?, :physical?, :openvz_host?, node: { "virtualization" => { "system" => "openvz", "role" => "host" } })
71
+ end
72
+ context "on metal which is not a virt host" do
73
+ virtualization_reports_true_for(:physical?, node: {} )
74
+ end
75
+ end