puppet 2.7.6 → 2.7.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +168 -0
- data/conf/auth.conf +5 -4
- data/conf/redhat/puppet.spec +16 -1
- data/conf/solaris/pkginfo +2 -2
- data/conf/suse/puppet.spec +9 -3
- data/ext/upload_facts.rb +120 -0
- data/install.rb +11 -16
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +0 -3
- data/lib/puppet/application/apply.rb +0 -3
- data/lib/puppet/application/queue.rb +21 -1
- data/lib/puppet/defaults.rb +6 -4
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/feature/base.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/metadata.rb +5 -2
- data/lib/puppet/indirector/facts/inventory_service.rb +20 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/network/handler/filebucket.rb +2 -0
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/handler/master.rb +1 -0
- data/lib/puppet/network/handler/report.rb +2 -0
- data/lib/puppet/network/handler/runner.rb +1 -0
- data/lib/puppet/network/handler/status.rb +2 -0
- data/lib/puppet/network/http/mongrel/rest.rb +8 -1
- data/lib/puppet/network/http_server.rb +3 -0
- data/lib/puppet/network/http_server/mongrel.rb +129 -0
- data/lib/puppet/network/rest_authconfig.rb +12 -4
- data/lib/puppet/parameter.rb +18 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/grammar.ra +1 -1
- data/lib/puppet/parser/parser.rb +360 -350
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +6 -7
- data/lib/puppet/provider/file/windows.rb +9 -2
- data/lib/puppet/provider/group/aix.rb +8 -8
- data/lib/puppet/provider/group/groupadd.rb +1 -3
- data/lib/puppet/provider/group/ldap.rb +8 -10
- data/lib/puppet/provider/group/windows_adsi.rb +8 -2
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/macports.rb +3 -3
- data/lib/puppet/provider/package/msi.rb +12 -5
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -3
- data/lib/puppet/provider/package/ports.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +560 -0
- data/lib/puppet/provider/service/base.rb +2 -2
- data/lib/puppet/provider/service/bsd.rb +4 -3
- data/lib/puppet/provider/service/daemontools.rb +25 -25
- data/lib/puppet/provider/service/debian.rb +6 -4
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/gentoo.rb +4 -3
- data/lib/puppet/provider/service/init.rb +3 -8
- data/lib/puppet/provider/service/launchd.rb +129 -96
- data/lib/puppet/provider/service/redhat.rb +2 -3
- data/lib/puppet/provider/service/runit.rb +20 -20
- data/lib/puppet/provider/service/smf.rb +8 -7
- data/lib/puppet/provider/service/src.rb +5 -6
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +3 -5
- data/lib/puppet/provider/service/windows.rb +7 -7
- data/lib/puppet/provider/sshkey/parsed.rb +2 -3
- data/lib/puppet/provider/user/aix.rb +21 -21
- data/lib/puppet/provider/user/hpux.rb +3 -1
- data/lib/puppet/provider/user/ldap.rb +7 -7
- data/lib/puppet/provider/user/user_role_add.rb +10 -6
- data/lib/puppet/provider/user/useradd.rb +3 -1
- data/lib/puppet/provider/user/windows_adsi.rb +4 -3
- data/lib/puppet/rb_tree_map.rb +388 -0
- data/lib/puppet/reference/configuration.rb +7 -7
- data/lib/puppet/reference/indirection.rb +5 -6
- data/lib/puppet/reference/metaparameter.rb +3 -1
- data/lib/puppet/reference/network.rb +8 -8
- data/lib/puppet/reference/providers.rb +17 -21
- data/lib/puppet/reference/type.rb +12 -9
- data/lib/puppet/resource.rb +2 -5
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +70 -0
- data/lib/puppet/ssl/host.rb +6 -0
- data/lib/puppet/transaction.rb +158 -55
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/type.rb +60 -30
- data/lib/puppet/type/augeas.rb +83 -49
- data/lib/puppet/type/computer.rb +1 -1
- data/lib/puppet/type/cron.rb +11 -11
- data/lib/puppet/type/exec.rb +28 -21
- data/lib/puppet/type/file.rb +17 -7
- data/lib/puppet/type/file/content.rb +2 -2
- data/lib/puppet/type/file/ensure.rb +15 -12
- data/lib/puppet/type/file/mode.rb +30 -5
- data/lib/puppet/type/file/source.rb +11 -10
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +4 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/interface.rb +13 -10
- data/lib/puppet/type/k5login.rb +6 -6
- data/lib/puppet/type/macauthorization.rb +37 -36
- data/lib/puppet/type/maillist.rb +2 -2
- data/lib/puppet/type/mcx.rb +6 -6
- data/lib/puppet/type/mount.rb +3 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +24 -23
- data/lib/puppet/type/router.rb +4 -1
- data/lib/puppet/type/schedule.rb +52 -44
- data/lib/puppet/type/scheduled_task.rb +222 -0
- data/lib/puppet/type/selmodule.rb +10 -6
- data/lib/puppet/type/service.rb +11 -11
- data/lib/puppet/type/ssh_authorized_key.rb +2 -5
- data/lib/puppet/type/sshkey.rb +1 -1
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +10 -8
- data/lib/puppet/type/user.rb +61 -53
- data/lib/puppet/type/vlan.rb +4 -4
- data/lib/puppet/type/whit.rb +6 -2
- data/lib/puppet/type/yumrepo.rb +33 -31
- data/lib/puppet/type/zfs.rb +34 -32
- data/lib/puppet/type/zone.rb +21 -19
- data/lib/puppet/type/zpool.rb +3 -3
- data/lib/puppet/util.rb +24 -6
- data/lib/puppet/util/adsi.rb +12 -7
- data/lib/puppet/util/checksums.rb +1 -1
- data/lib/puppet/util/diff.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +2 -2
- data/lib/puppet/util/reference.rb +16 -17
- data/lib/puppet/util/settings/file_setting.rb +14 -2
- data/lib/puppet/util/windows/security.rb +96 -32
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +9 -15
- data/spec/integration/indirector/file_content/file_server_spec.rb +1 -1
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +4 -0
- data/spec/integration/provider/service/init_spec.rb +8 -2
- data/spec/integration/reference/providers_spec.rb +1 -1
- data/spec/integration/ssl/certificate_request_spec.rb +1 -2
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -2
- data/spec/integration/ssl/host_spec.rb +1 -2
- data/spec/integration/transaction_spec.rb +25 -17
- data/spec/integration/type/exec_spec.rb +77 -0
- data/spec/integration/type/file_spec.rb +322 -2
- data/spec/integration/util/windows/security_spec.rb +393 -230
- data/spec/integration/util_spec.rb +16 -0
- data/spec/lib/puppet_spec/files.rb +3 -7
- data/spec/unit/application/apply_spec.rb +0 -9
- data/spec/unit/application/inspect_spec.rb +1 -0
- data/spec/unit/configurer/downloader_spec.rb +3 -3
- data/spec/unit/face/certificate_spec.rb +6 -2
- data/spec/unit/file_bucket/dipper_spec.rb +67 -10
- data/spec/unit/file_bucket/file_spec.rb +22 -28
- data/spec/unit/file_serving/content_spec.rb +1 -1
- data/spec/unit/file_serving/metadata_spec.rb +30 -3
- data/spec/unit/indirector/facts/inventory_service_spec.rb +22 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +21 -24
- data/spec/unit/indirector/node/store_configs_spec.rb +1 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource_type/parser_spec.rb +2 -2
- data/spec/unit/indirector/rest_spec.rb +1 -1
- data/spec/unit/network/handler/ca_spec.rb +1 -1
- data/spec/unit/network/http/mongrel/rest_spec.rb +54 -25
- data/spec/unit/parameter_spec.rb +36 -0
- data/spec/unit/parser/parser_spec.rb +4 -0
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/provider/exec/windows_spec.rb +2 -8
- data/spec/unit/provider/file/posix_spec.rb +6 -0
- data/spec/unit/provider/file/windows_spec.rb +18 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -6
- data/spec/unit/provider/mount/parsed_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +2 -2
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1571 -0
- data/spec/unit/provider/service/launchd_spec.rb +143 -130
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +39 -9
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +8 -1
- data/spec/unit/rb_tree_map_spec.rb +572 -0
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/simple_graph_spec.rb +9 -9
- data/spec/unit/ssl/host_spec.rb +60 -12
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +394 -11
- data/spec/unit/type/exec_spec.rb +35 -15
- data/spec/unit/type/file/content_spec.rb +11 -10
- data/spec/unit/type/file/mode_spec.rb +73 -19
- data/spec/unit/type/file/source_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +15 -0
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/resources_spec.rb +3 -3
- data/spec/unit/type/scheduled_task_spec.rb +102 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +2 -3
- data/spec/unit/type/user_spec.rb +2 -1
- data/spec/unit/type_spec.rb +48 -4
- data/spec/unit/util/adsi_spec.rb +18 -7
- data/spec/unit/util/checksums_spec.rb +20 -2
- data/spec/unit/util/execution_stub_spec.rb +10 -5
- data/spec/unit/util/logging_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +1 -1
- data/spec/unit/util/reference_spec.rb +29 -0
- data/spec/unit/util/settings/file_setting_spec.rb +8 -2
- data/spec/unit/util_spec.rb +115 -0
- data/test/other/transactions.rb +5 -11
- data/test/ral/type/exec.rb +1 -1
- metadata +24 -11
@@ -10,7 +10,7 @@ class TerminusHelperIntegrationTester
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe Puppet::FileServing::TerminusHelper
|
13
|
+
describe Puppet::FileServing::TerminusHelper do
|
14
14
|
it "should be able to recurse on a single file" do
|
15
15
|
@path = Tempfile.new("fileset_integration")
|
16
16
|
request = Puppet::Indirector::Request.new(:metadata, :find, @path.path, :recurse => true)
|
@@ -30,24 +30,18 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with the files
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe Puppet::Indirector::DirectFileServer, " when interacting with FileServing::Fileset and the model"
|
34
|
-
|
35
|
-
@terminus = Puppet::Indirector::FileContent::File.new
|
33
|
+
describe Puppet::Indirector::DirectFileServer, " when interacting with FileServing::Fileset and the model" do
|
34
|
+
include PuppetSpec::Files
|
36
35
|
|
37
|
-
|
38
|
-
path = @path.path
|
39
|
-
@path.close!
|
40
|
-
@path = path
|
36
|
+
let(:path) { tmpdir('direct_file_server_testing') }
|
41
37
|
|
42
|
-
|
43
|
-
|
44
|
-
File.open(File.join(@path, "two"), "w") { |f| f.print "two content" }
|
38
|
+
before do
|
39
|
+
@terminus = Puppet::Indirector::FileContent::File.new
|
45
40
|
|
46
|
-
|
47
|
-
|
41
|
+
File.open(File.join(path, "one"), "w") { |f| f.print "one content" }
|
42
|
+
File.open(File.join(path, "two"), "w") { |f| f.print "two content" }
|
48
43
|
|
49
|
-
|
50
|
-
system("rm -rf #{@path}")
|
44
|
+
@request = @terminus.indirection.request(:search, "file:///#{path}", :recurse => true)
|
51
45
|
end
|
52
46
|
|
53
47
|
it "should return an instance for every file in the fileset" do
|
@@ -62,7 +56,7 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with FileServi
|
|
62
56
|
case instance.full_path
|
63
57
|
when /one/; instance.content.should == "one content"
|
64
58
|
when /two/; instance.content.should == "two content"
|
65
|
-
when
|
59
|
+
when path
|
66
60
|
else
|
67
61
|
raise "No valid key for #{instance.path.inspect}"
|
68
62
|
end
|
@@ -6,7 +6,7 @@ require 'shared_behaviours/file_server_terminus'
|
|
6
6
|
|
7
7
|
require 'puppet_spec/files'
|
8
8
|
|
9
|
-
describe Puppet::Indirector::FileContent::FileServer, " when finding files"
|
9
|
+
describe Puppet::Indirector::FileContent::FileServer, " when finding files" do
|
10
10
|
it_should_behave_like "Puppet::Indirector::FileServerTerminus"
|
11
11
|
include PuppetSpec::Files
|
12
12
|
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require 'puppet/indirector/file_metadata/file_server'
|
5
5
|
require 'shared_behaviours/file_server_terminus'
|
6
6
|
|
7
|
-
describe Puppet::Indirector::FileMetadata::FileServer, " when finding files"
|
7
|
+
describe Puppet::Indirector::FileMetadata::FileServer, " when finding files" do
|
8
8
|
it_should_behave_like "Puppet::Indirector::FileServerTerminus"
|
9
9
|
|
10
10
|
before do
|
@@ -23,6 +23,10 @@ describe "Package provider", :'fails_on_ruby_1.9.2' => true do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be able to get a list of existing packages", :fails_on_windows => true do
|
26
|
+
if provider.name == :msi
|
27
|
+
Puppet[:vardir] = tmpdir('msi_package_var_dir')
|
28
|
+
end
|
29
|
+
|
26
30
|
provider.instances.each do |package|
|
27
31
|
package.should be_instance_of(provider)
|
28
32
|
package.properties[:provider].should == provider.name
|
@@ -5,7 +5,7 @@ provider = Puppet::Type.type(:service).provider(:init)
|
|
5
5
|
|
6
6
|
describe provider, :'fails_on_ruby_1.9.2' => true do
|
7
7
|
describe "when running on FreeBSD", :if => (Facter.value(:operatingsystem) == "FreeBSD") do
|
8
|
-
it "should set its default path to include /etc/
|
8
|
+
it "should set its default path to include /etc/rc.d and /usr/local/etc/rc.d" do
|
9
9
|
provider.defpath.should == ["/etc/rc.d", "/usr/local/etc/rc.d"]
|
10
10
|
end
|
11
11
|
end
|
@@ -16,7 +16,13 @@ describe provider, :'fails_on_ruby_1.9.2' => true do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe "when
|
19
|
+
describe "when running on Archlinux", :if => (Facter.value(:operatingsystem) == "Archlinux") do
|
20
|
+
it "should set its default path to include /etc/rc.d" do
|
21
|
+
provider.defpath.should == "/etc/rc.d"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "when not running on FreeBSD, HP-UX or Archlinux", :if => (! %w{HP-UX FreeBSD Archlinux}.include?(Facter.value(:operatingsystem))) do
|
20
26
|
it "should set its default path to include /etc/init.d" do
|
21
27
|
provider.defpath.should == "/etc/init.d"
|
22
28
|
end
|
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
require 'puppet/ssl/certificate_request'
|
5
5
|
|
6
|
-
|
7
|
-
describe Puppet::SSL::CertificateRequest, :fails_on_windows => true do
|
6
|
+
describe Puppet::SSL::CertificateRequest do
|
8
7
|
include PuppetSpec::Files
|
9
8
|
|
10
9
|
before do
|
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
require 'puppet/ssl/certificate_revocation_list'
|
5
5
|
|
6
|
-
|
7
|
-
describe Puppet::SSL::CertificateRevocationList, :fails_on_windows => true do
|
6
|
+
describe Puppet::SSL::CertificateRevocationList do
|
8
7
|
include PuppetSpec::Files
|
9
8
|
|
10
9
|
before do
|
@@ -16,6 +16,14 @@ describe Puppet::Transaction do
|
|
16
16
|
catalog
|
17
17
|
end
|
18
18
|
|
19
|
+
def usr_bin_touch(path)
|
20
|
+
Puppet.features.microsoft_windows? ? "#{ENV['windir']}/system32/cmd.exe /c \"type NUL >> \"#{path}\"\"" : "/usr/bin/touch #{path}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def touch(path)
|
24
|
+
Puppet.features.microsoft_windows? ? "cmd.exe /c \"type NUL >> \"#{path}\"\"" : "touch #{path}"
|
25
|
+
end
|
26
|
+
|
19
27
|
it "should not apply generated resources if the parent resource fails" do
|
20
28
|
catalog = Puppet::Resource::Catalog.new
|
21
29
|
resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
|
@@ -131,11 +139,11 @@ describe Puppet::Transaction do
|
|
131
139
|
|
132
140
|
# Verify that one component requiring another causes the contained
|
133
141
|
# resources in the requiring component to get refreshed.
|
134
|
-
it "should propagate events from a contained resource through its container to its dependent container's contained resources"
|
142
|
+
it "should propagate events from a contained resource through its container to its dependent container's contained resources" do
|
135
143
|
transaction = nil
|
136
144
|
file = Puppet::Type.type(:file).new :path => tmpfile("event_propagation"), :ensure => :present
|
137
145
|
execfile = File.join(tmpdir("exec_event"), "exectestingness2")
|
138
|
-
exec = Puppet::Type.type(:exec).new :command =>
|
146
|
+
exec = Puppet::Type.type(:exec).new :command => touch(execfile), :path => ENV['PATH']
|
139
147
|
catalog = mk_catalog(file)
|
140
148
|
|
141
149
|
fcomp = Puppet::Type.type(:component).new(:name => "Foo[file]")
|
@@ -155,7 +163,7 @@ describe Puppet::Transaction do
|
|
155
163
|
end
|
156
164
|
|
157
165
|
# Make sure that multiple subscriptions get triggered.
|
158
|
-
it "should propagate events to all dependent resources"
|
166
|
+
it "should propagate events to all dependent resources" do
|
159
167
|
path = tmpfile("path")
|
160
168
|
file1 = tmpfile("file1")
|
161
169
|
file2 = tmpfile("file2")
|
@@ -167,14 +175,14 @@ describe Puppet::Transaction do
|
|
167
175
|
|
168
176
|
exec1 = Puppet::Type.type(:exec).new(
|
169
177
|
:path => ENV["PATH"],
|
170
|
-
:command =>
|
178
|
+
:command => touch(file1),
|
171
179
|
:refreshonly => true,
|
172
180
|
:subscribe => Puppet::Resource.new(:file, path)
|
173
181
|
)
|
174
182
|
|
175
183
|
exec2 = Puppet::Type.type(:exec).new(
|
176
184
|
:path => ENV["PATH"],
|
177
|
-
:command =>
|
185
|
+
:command => touch(file2),
|
178
186
|
:refreshonly => true,
|
179
187
|
:subscribe => Puppet::Resource.new(:file, path)
|
180
188
|
)
|
@@ -185,7 +193,7 @@ describe Puppet::Transaction do
|
|
185
193
|
FileTest.should be_exist(file2)
|
186
194
|
end
|
187
195
|
|
188
|
-
it "should not let one failed refresh result in other refreshes failing"
|
196
|
+
it "should not let one failed refresh result in other refreshes failing" do
|
189
197
|
path = tmpfile("path")
|
190
198
|
newfile = tmpfile("file")
|
191
199
|
file = Puppet::Type.type(:file).new(
|
@@ -195,7 +203,7 @@ describe Puppet::Transaction do
|
|
195
203
|
|
196
204
|
exec1 = Puppet::Type.type(:exec).new(
|
197
205
|
:path => ENV["PATH"],
|
198
|
-
:command => "
|
206
|
+
:command => touch(File.expand_path("/this/cannot/possibly/exist")),
|
199
207
|
:logoutput => true,
|
200
208
|
:refreshonly => true,
|
201
209
|
:subscribe => file,
|
@@ -204,7 +212,7 @@ describe Puppet::Transaction do
|
|
204
212
|
|
205
213
|
exec2 = Puppet::Type.type(:exec).new(
|
206
214
|
:path => ENV["PATH"],
|
207
|
-
:command =>
|
215
|
+
:command => touch(newfile),
|
208
216
|
:logoutput => true,
|
209
217
|
:refreshonly => true,
|
210
218
|
:subscribe => [file, exec1],
|
@@ -218,7 +226,7 @@ describe Puppet::Transaction do
|
|
218
226
|
FileTest.should be_exists(newfile)
|
219
227
|
end
|
220
228
|
|
221
|
-
it "should still trigger skipped resources", :'fails_on_ruby_1.9.2' => true
|
229
|
+
it "should still trigger skipped resources", :'fails_on_ruby_1.9.2' => true do
|
222
230
|
catalog = mk_catalog
|
223
231
|
catalog.add_resource(*Puppet::Type.type(:schedule).mkdefaultschedules)
|
224
232
|
|
@@ -233,8 +241,8 @@ describe Puppet::Transaction do
|
|
233
241
|
fname = tmpfile("exec")
|
234
242
|
|
235
243
|
exec = Puppet::Type.type(:exec).new(
|
236
|
-
:name =>
|
237
|
-
:path => "/usr/bin:/bin",
|
244
|
+
:name => touch(fname),
|
245
|
+
:path => Puppet.features.microsoft_windows? ? "#{ENV['windir']}/system32" : "/usr/bin:/bin",
|
238
246
|
:schedule => "monthly",
|
239
247
|
:subscribe => Puppet::Resource.new("file", file.name)
|
240
248
|
)
|
@@ -270,10 +278,10 @@ describe Puppet::Transaction do
|
|
270
278
|
FileTest.should be_exists(fname)
|
271
279
|
end
|
272
280
|
|
273
|
-
it "should not attempt to evaluate resources with failed dependencies"
|
281
|
+
it "should not attempt to evaluate resources with failed dependencies" do
|
274
282
|
|
275
283
|
exec = Puppet::Type.type(:exec).new(
|
276
|
-
:command => "/bin/mkdir /this/path/cannot/possibly/exist",
|
284
|
+
:command => "#{File.expand_path('/bin/mkdir')} /this/path/cannot/possibly/exist",
|
277
285
|
:title => "mkdir"
|
278
286
|
)
|
279
287
|
|
@@ -298,22 +306,22 @@ describe Puppet::Transaction do
|
|
298
306
|
FileTest.should_not be_exists(file2[:path])
|
299
307
|
end
|
300
308
|
|
301
|
-
it "should not trigger subscribing resources on failure"
|
309
|
+
it "should not trigger subscribing resources on failure" do
|
302
310
|
file1 = tmpfile("file1")
|
303
311
|
file2 = tmpfile("file2")
|
304
312
|
|
305
313
|
create_file1 = Puppet::Type.type(:exec).new(
|
306
|
-
:command =>
|
314
|
+
:command => usr_bin_touch(file1)
|
307
315
|
)
|
308
316
|
|
309
317
|
exec = Puppet::Type.type(:exec).new(
|
310
|
-
:command => "/bin/mkdir /this/path/cannot/possibly/exist",
|
318
|
+
:command => "#{File.expand_path('/bin/mkdir')} /this/path/cannot/possibly/exist",
|
311
319
|
:title => "mkdir",
|
312
320
|
:notify => create_file1
|
313
321
|
)
|
314
322
|
|
315
323
|
create_file2 = Puppet::Type.type(:exec).new(
|
316
|
-
:command =>
|
324
|
+
:command => usr_bin_touch(file2),
|
317
325
|
:subscribe => exec
|
318
326
|
)
|
319
327
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'puppet_spec/files'
|
5
|
+
|
6
|
+
describe Puppet::Type.type(:exec) do
|
7
|
+
include PuppetSpec::Files
|
8
|
+
|
9
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
10
|
+
let(:path) { tmpfile('exec_provider') }
|
11
|
+
let(:command) { "ruby -e 'File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }'" }
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
catalog.host_config = false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should execute the command" do
|
18
|
+
exec = described_class.new :command => command, :path => ENV['PATH']
|
19
|
+
|
20
|
+
catalog.add_resource exec
|
21
|
+
catalog.apply
|
22
|
+
|
23
|
+
File.read(path).should == 'foo'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not execute the command if onlyif returns non-zero" do
|
27
|
+
exec = described_class.new(
|
28
|
+
:command => command,
|
29
|
+
:onlyif => "ruby -e 'exit 44'",
|
30
|
+
:path => ENV['PATH']
|
31
|
+
)
|
32
|
+
|
33
|
+
catalog.add_resource exec
|
34
|
+
catalog.apply
|
35
|
+
|
36
|
+
File.should_not be_exist(path)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should execute the command if onlyif returns zero" do
|
40
|
+
exec = described_class.new(
|
41
|
+
:command => command,
|
42
|
+
:onlyif => "ruby -e 'exit 0'",
|
43
|
+
:path => ENV['PATH']
|
44
|
+
)
|
45
|
+
|
46
|
+
catalog.add_resource exec
|
47
|
+
catalog.apply
|
48
|
+
|
49
|
+
File.read(path).should == 'foo'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should execute the command if unless returns non-zero" do
|
53
|
+
exec = described_class.new(
|
54
|
+
:command => command,
|
55
|
+
:unless => "ruby -e 'exit 45'",
|
56
|
+
:path => ENV['PATH']
|
57
|
+
)
|
58
|
+
|
59
|
+
catalog.add_resource exec
|
60
|
+
catalog.apply
|
61
|
+
|
62
|
+
File.read(path).should == 'foo'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should not execute the command if unless returns zero" do
|
66
|
+
exec = described_class.new(
|
67
|
+
:command => command,
|
68
|
+
:unless => "ruby -e 'exit 0'",
|
69
|
+
:path => ENV['PATH']
|
70
|
+
)
|
71
|
+
|
72
|
+
catalog.add_resource exec
|
73
|
+
catalog.apply
|
74
|
+
|
75
|
+
File.should_not be_exist(path)
|
76
|
+
end
|
77
|
+
end
|
@@ -17,6 +17,10 @@ describe Puppet::Type.type(:file) do
|
|
17
17
|
let(:path) { tmpfile('file_testing') }
|
18
18
|
|
19
19
|
if Puppet.features.posix?
|
20
|
+
def set_mode(mode, file)
|
21
|
+
File.chmod(mode, file)
|
22
|
+
end
|
23
|
+
|
20
24
|
def get_mode(file)
|
21
25
|
File.lstat(file).mode
|
22
26
|
end
|
@@ -33,6 +37,10 @@ describe Puppet::Type.type(:file) do
|
|
33
37
|
extend Puppet::Util::Windows::Security
|
34
38
|
end
|
35
39
|
|
40
|
+
def set_mode(mode, file)
|
41
|
+
SecurityHelper.set_mode(mode, file)
|
42
|
+
end
|
43
|
+
|
36
44
|
def get_mode(file)
|
37
45
|
SecurityHelper.get_mode(file)
|
38
46
|
end
|
@@ -92,6 +100,255 @@ describe Puppet::Type.type(:file) do
|
|
92
100
|
|
93
101
|
get_group(path).should == group
|
94
102
|
end
|
103
|
+
|
104
|
+
describe "when setting mode" do
|
105
|
+
describe "for directories" do
|
106
|
+
let(:path) { tmpdir('dir_mode') }
|
107
|
+
|
108
|
+
it "should set executable bits for newly created directories" do
|
109
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :directory, :mode => 0600)
|
110
|
+
catalog.apply
|
111
|
+
|
112
|
+
(get_mode(path) & 07777).should == 0700
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should set executable bits for existing readable directories" do
|
116
|
+
File.should be_directory(path)
|
117
|
+
set_mode(0600, path)
|
118
|
+
|
119
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :directory, :mode => 0644)
|
120
|
+
catalog.apply
|
121
|
+
|
122
|
+
(get_mode(path) & 07777).should == 0755
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should not set executable bits for unreadable directories" do
|
126
|
+
begin
|
127
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :directory, :mode => 0300)
|
128
|
+
catalog.apply
|
129
|
+
|
130
|
+
(get_mode(path) & 07777).should == 0300
|
131
|
+
ensure
|
132
|
+
# so we can cleanup
|
133
|
+
set_mode(0700, path)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should set user, group, and other executable bits" do
|
138
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :directory, :mode => 0664)
|
139
|
+
catalog.apply
|
140
|
+
|
141
|
+
(get_mode(path) & 07777).should == 0775
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should set executable bits when overwriting a non-executable file" do
|
145
|
+
FileUtils.rmdir(path)
|
146
|
+
FileUtils.touch(path)
|
147
|
+
set_mode(0444, path)
|
148
|
+
|
149
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :directory, :mode => 0666, :backup => false)
|
150
|
+
catalog.apply
|
151
|
+
|
152
|
+
(get_mode(path) & 07777).should == 0777
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "for files" do
|
157
|
+
let(:path) { tmpfile('file_mode') }
|
158
|
+
|
159
|
+
it "should not set executable bits" do
|
160
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :file, :mode => 0666)
|
161
|
+
catalog.apply
|
162
|
+
|
163
|
+
(get_mode(path) & 07777).should == 0666
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should not set executable bits when replacing an executable directory (#10365)" do
|
167
|
+
pending("bug #10365")
|
168
|
+
|
169
|
+
FileUtils.mkdir(path)
|
170
|
+
set_mode(0777, path)
|
171
|
+
|
172
|
+
catalog.add_resource described_class.new(:path => path, :ensure => :file, :mode => 0666, :backup => false, :force => true)
|
173
|
+
catalog.apply
|
174
|
+
|
175
|
+
(get_mode(path) & 07777).should == 0666
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "for links", :unless => Puppet.features.microsoft_windows? do
|
180
|
+
let(:link) { tmpfile('link_mode') }
|
181
|
+
|
182
|
+
describe "when managing links" do
|
183
|
+
let(:target) { tmpfile('target') }
|
184
|
+
|
185
|
+
before :each do
|
186
|
+
FileUtils.touch(target)
|
187
|
+
File.chmod(0444, target)
|
188
|
+
|
189
|
+
File.symlink(target, link)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should not set the executable bit on the link nor the target" do
|
193
|
+
catalog.add_resource described_class.new(:path => link, :ensure => :link, :mode => 0666, :target => target, :links => :manage)
|
194
|
+
catalog.apply
|
195
|
+
|
196
|
+
(File.stat(link).mode & 07777) == 0666
|
197
|
+
(File.lstat(target).mode & 07777) == 0444
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should ignore dangling symlinks (#6856)" do
|
201
|
+
File.delete(target)
|
202
|
+
|
203
|
+
catalog.add_resource described_class.new(:path => link, :ensure => :link, :mode => 0666, :target => target, :links => :manage)
|
204
|
+
catalog.apply
|
205
|
+
|
206
|
+
File.should_not be_exist(link)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "when following links" do
|
211
|
+
it "should ignore dangling symlinks (#6856)" do
|
212
|
+
target = tmpfile('dangling')
|
213
|
+
|
214
|
+
FileUtils.touch(target)
|
215
|
+
File.symlink(target, link)
|
216
|
+
File.delete(target)
|
217
|
+
|
218
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
|
219
|
+
catalog.apply
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "to a directory" do
|
223
|
+
let(:target) { tmpdir('dir_target') }
|
224
|
+
|
225
|
+
before :each do
|
226
|
+
File.chmod(0600, target)
|
227
|
+
|
228
|
+
File.symlink(target, link)
|
229
|
+
end
|
230
|
+
|
231
|
+
after :each do
|
232
|
+
File.chmod(0750, target)
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "that is readable" do
|
236
|
+
it "should set the executable bits when creating the destination (#10315)" do
|
237
|
+
pending "bug #10315"
|
238
|
+
|
239
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
|
240
|
+
catalog.apply
|
241
|
+
|
242
|
+
(get_mode(path) & 07777).should == 0777
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should set the executable bits when overwriting the destination (#10315)" do
|
246
|
+
pending "bug #10315"
|
247
|
+
|
248
|
+
FileUtils.touch(path)
|
249
|
+
|
250
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
|
251
|
+
catalog.apply
|
252
|
+
|
253
|
+
(get_mode(path) & 07777).should == 0777
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe "that is not readable" do
|
258
|
+
before :each do
|
259
|
+
set_mode(0300, target)
|
260
|
+
end
|
261
|
+
|
262
|
+
# so we can cleanup
|
263
|
+
after :each do
|
264
|
+
set_mode(0700, target)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should not set executable bits when creating the destination (#10315)" do
|
268
|
+
pending "bug #10315"
|
269
|
+
|
270
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
|
271
|
+
catalog.apply
|
272
|
+
|
273
|
+
(get_mode(path) & 07777).should == 0666
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should not set executable bits when overwriting the destination" do
|
277
|
+
FileUtils.touch(path)
|
278
|
+
|
279
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
|
280
|
+
catalog.apply
|
281
|
+
|
282
|
+
(get_mode(path) & 07777).should == 0666
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "to a file" do
|
288
|
+
let(:target) { tmpfile('file_target') }
|
289
|
+
|
290
|
+
it "should create the file, not a symlink (#2817, #10315)" do
|
291
|
+
pending "bug #2817, #10315"
|
292
|
+
|
293
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
|
294
|
+
catalog.apply
|
295
|
+
|
296
|
+
File.should be_file(path)
|
297
|
+
(get_mode(path) & 07777) == 0600
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should overwrite the file" do
|
301
|
+
FileUtils.touch(path)
|
302
|
+
|
303
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
|
304
|
+
catalog.apply
|
305
|
+
|
306
|
+
File.should be_file(path)
|
307
|
+
(get_mode(path) & 07777) == 0600
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe "to a link to a directory" do
|
312
|
+
let(:real_target) { tmpdir('real_target') }
|
313
|
+
let(:target) { tmpfile('target') }
|
314
|
+
|
315
|
+
before :each do
|
316
|
+
File.chmod(0666, real_target)
|
317
|
+
|
318
|
+
# link -> target -> real_target
|
319
|
+
File.symlink(real_target, target)
|
320
|
+
File.symlink(target, link)
|
321
|
+
end
|
322
|
+
|
323
|
+
after :each do
|
324
|
+
File.chmod(0750, real_target)
|
325
|
+
end
|
326
|
+
|
327
|
+
describe "when following all links" do
|
328
|
+
it "should create the destination and apply executable bits (#10315)" do
|
329
|
+
pending "bug #10315"
|
330
|
+
|
331
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
|
332
|
+
catalog.apply
|
333
|
+
|
334
|
+
File.should be_directory(path)
|
335
|
+
(get_mode(path) & 07777) == 0777
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should overwrite the destination and apply executable bits" do
|
339
|
+
FileUtils.mkdir(path)
|
340
|
+
|
341
|
+
catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
|
342
|
+
catalog.apply
|
343
|
+
|
344
|
+
File.should be_directory(path)
|
345
|
+
(get_mode(path) & 07777) == 0777
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
95
352
|
end
|
96
353
|
|
97
354
|
describe "when writing files" do
|
@@ -101,9 +358,9 @@ describe Puppet::Type.type(:file) do
|
|
101
358
|
catalog.add_resource file
|
102
359
|
catalog.add_resource filebucket
|
103
360
|
|
104
|
-
File.open(file[:path], "
|
361
|
+
File.open(file[:path], "wb") { |f| f.puts "bar" }
|
105
362
|
|
106
|
-
md5 = Digest::MD5.hexdigest(
|
363
|
+
md5 = Digest::MD5.hexdigest(Puppet::Util.binread(file[:path]))
|
107
364
|
|
108
365
|
catalog.apply
|
109
366
|
|
@@ -695,6 +952,69 @@ describe Puppet::Type.type(:file) do
|
|
695
952
|
File.should_not be_exist(path)
|
696
953
|
end
|
697
954
|
|
955
|
+
describe "when sourcing" do
|
956
|
+
let(:source) {
|
957
|
+
source = tmpfile("source_default_values")
|
958
|
+
File.open(source, "w") { |f| f.puts "yay" }
|
959
|
+
source
|
960
|
+
}
|
961
|
+
|
962
|
+
it "should apply the source metadata values" do
|
963
|
+
set_mode(0770, source)
|
964
|
+
|
965
|
+
file = described_class.new(
|
966
|
+
:path => path,
|
967
|
+
:ensure => :file,
|
968
|
+
:source => source,
|
969
|
+
:backup => false
|
970
|
+
)
|
971
|
+
|
972
|
+
catalog.add_resource file
|
973
|
+
catalog.apply
|
974
|
+
|
975
|
+
get_owner(path).should == get_owner(source)
|
976
|
+
get_group(path).should == get_group(source)
|
977
|
+
(get_mode(path) & 07777).should == 0770
|
978
|
+
end
|
979
|
+
|
980
|
+
it "should override the default metadata values" do
|
981
|
+
set_mode(0770, source)
|
982
|
+
|
983
|
+
file = described_class.new(
|
984
|
+
:path => path,
|
985
|
+
:ensure => :file,
|
986
|
+
:source => source,
|
987
|
+
:backup => false,
|
988
|
+
:mode => 0440
|
989
|
+
)
|
990
|
+
|
991
|
+
catalog.add_resource file
|
992
|
+
catalog.apply
|
993
|
+
|
994
|
+
(get_mode(path) & 07777).should == 0440
|
995
|
+
end
|
996
|
+
|
997
|
+
describe "on Windows systems", :if => Puppet.features.microsoft_windows? do
|
998
|
+
it "should provide valid default values when ACLs are not supported" do
|
999
|
+
Puppet::Util::Windows::Security.stubs(:supports_acl?).with(source).returns false
|
1000
|
+
|
1001
|
+
file = described_class.new(
|
1002
|
+
:path => path,
|
1003
|
+
:ensure => :file,
|
1004
|
+
:source => source,
|
1005
|
+
:backup => false
|
1006
|
+
)
|
1007
|
+
|
1008
|
+
catalog.add_resource file
|
1009
|
+
catalog.apply
|
1010
|
+
|
1011
|
+
get_owner(path).should == 'S-1-5-32-544'
|
1012
|
+
get_group(path).should == 'S-1-0-0'
|
1013
|
+
get_mode(path).should == 0644
|
1014
|
+
end
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
|
698
1018
|
describe "when purging files" do
|
699
1019
|
before do
|
700
1020
|
sourcedir = tmpfile("purge_source")
|