chef 11.6.0 → 11.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +6 -14
- data/Rakefile +12 -4
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +4 -4
- data/distro/common/html/chef-shell.1.html +4 -4
- data/distro/common/html/chef-solo.8.html +4 -4
- data/distro/common/html/chef-solr.8.html +5 -5
- data/distro/common/html/knife-bootstrap.1.html +4 -4
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +4 -4
- data/distro/common/html/knife-cookbook-site.1.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +4 -4
- data/distro/common/html/knife-data-bag.1.html +4 -4
- data/distro/common/html/knife-environment.1.html +4 -4
- data/distro/common/html/knife-exec.1.html +4 -4
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +4 -4
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +4 -4
- data/distro/common/html/knife-ssh.1.html +4 -4
- data/distro/common/html/knife-status.1.html +4 -4
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +4 -4
- data/distro/common/man/man1/chef-shell.1 +1 -1
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +0 -99
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +0 -168
- data/distro/common/man/man1/knife-exec.1 +1 -1
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +1 -1
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +4 -1
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api/file.rb +7 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/changelog +5 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/control +13 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/files +1 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/changelog +11 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/control +13 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/files +1 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test_1.0-1_amd64.changes +22 -0
- data/spec/data/apt/chef-integration-test_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test_1.0.orig.tar.gz +0 -0
- data/spec/data/apt/chef-integration-test_1.1-1_amd64.changes +22 -0
- data/spec/data/apt/chef-integration-test_1.1-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test_1.1.orig.tar.gz +0 -0
- data/spec/data/apt/var/www/apt/conf/distributions +7 -0
- data/spec/data/apt/var/www/apt/conf/incoming +4 -0
- data/spec/data/apt/var/www/apt/conf/pulls +3 -0
- data/spec/data/apt/var/www/apt/db/checksums.db +0 -0
- data/spec/data/apt/var/www/apt/db/contents.cache.db +0 -0
- data/spec/data/apt/var/www/apt/db/packages.db +0 -0
- data/spec/data/apt/var/www/apt/db/references.db +0 -0
- data/spec/data/apt/var/www/apt/db/release.caches.db +0 -0
- data/spec/data/apt/var/www/apt/db/version +4 -0
- data/spec/data/apt/var/www/apt/dists/sid/Release +19 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages +16 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gz +0 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release +5 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages +0 -0
- data/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb +0 -0
- data/spec/data/cookbooks/preseed/files/default/preseed-file.seed +1 -0
- data/spec/data/cookbooks/preseed/templates/default/preseed-template.seed +1 -0
- data/spec/functional/provider/remote_file/cache_control_data_spec.rb +101 -0
- data/spec/functional/resource/package_spec.rb +297 -0
- data/spec/functional/resource/user_spec.rb +6 -14
- data/spec/spec_helper.rb +29 -0
- data/spec/support/shared/functional/file_resource.rb +37 -0
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +41 -0
- metadata +101 -43
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Origin: localhost
|
|
2
|
+
Label: apt repository
|
|
3
|
+
Codename: sid
|
|
4
|
+
Date: Thu, 30 Sep 2010 16:33:01 UTC
|
|
5
|
+
Architectures: amd64
|
|
6
|
+
Components: main
|
|
7
|
+
Description: Apt repository
|
|
8
|
+
MD5Sum:
|
|
9
|
+
92ed2cc14e37e9ab23466b27857d29ac 596 main/binary-amd64/Packages
|
|
10
|
+
c7726773341137b71cc971d44ddec4f5 394 main/binary-amd64/Packages.gz
|
|
11
|
+
46cd71c965ce0813c94ef78c836cc7d3 104 main/binary-amd64/Release
|
|
12
|
+
SHA1:
|
|
13
|
+
cde25071c5fcee59cee8dcd773ca419dcb40d946 596 main/binary-amd64/Packages
|
|
14
|
+
ce04daff75d4b27371d691d645282b198045544a 394 main/binary-amd64/Packages.gz
|
|
15
|
+
91ca9531e3afa7a540cabdc6030c6f75d315fec7 104 main/binary-amd64/Release
|
|
16
|
+
SHA256:
|
|
17
|
+
af601ce143f33405425746462973adc0fda3aceb381d1c739851b95ee0814ca3 596 main/binary-amd64/Packages
|
|
18
|
+
15e98119705a08018d4583caabc91d36ba12e6f1c8af0f799a3ec8ca5bfaa80d 394 main/binary-amd64/Packages.gz
|
|
19
|
+
098c599ac5b0a98785336afb2bc9c47002570ffa07dd62321c6f70b9fdb74325 104 main/binary-amd64/Release
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Package: chef-integration-test
|
|
2
|
+
Version: 1.1-1
|
|
3
|
+
Architecture: amd64
|
|
4
|
+
Maintainer: Joshua Timberman <Joshua Timberman <joshua@opscode.com>>
|
|
5
|
+
Installed-Size: 32
|
|
6
|
+
Homepage: http://tickets.opscode.com
|
|
7
|
+
Priority: extra
|
|
8
|
+
Section: ruby
|
|
9
|
+
Filename: pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb
|
|
10
|
+
Size: 1722
|
|
11
|
+
SHA256: 84e2f087f7e11d1b73743007ecfc6b8b34e03f6917c0993b35c0758ee59702c1
|
|
12
|
+
SHA1: 43c5653a9a5b9419849173a4ec3a9855cf0327a3
|
|
13
|
+
MD5sum: 4b05bace483dbca54efc21f97ee47e1d
|
|
14
|
+
Description: Chef integration tests for APT in Cucumber
|
|
15
|
+
This package is used for cucumber integration testing in Chef.
|
|
16
|
+
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chef-integration-test chef-integration-test/sample-var string "hello world"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chef-integration-test chef-integration-test/sample-var string "<%= node[:preseed_value] -%>"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Adam Edwards (<adamed@opscode.com>)
|
|
3
|
+
# Copyright:: Copyright (c) 2013 Opscode, 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 'uri'
|
|
21
|
+
|
|
22
|
+
describe Chef::Provider::RemoteFile::CacheControlData do
|
|
23
|
+
|
|
24
|
+
before do
|
|
25
|
+
@original_config = Chef::Config.hash_dup
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
after do
|
|
29
|
+
Chef::Config.configuration = @original_config if @original_config
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
before(:each) do
|
|
33
|
+
Chef::Config[:file_cache_path] = Dir.mktmpdir
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after(:each) do
|
|
37
|
+
FileUtils.rm_rf(Chef::Config[:file_cache_path])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
let(:uri) { URI.parse("http://www.bing.com/robots.txt") }
|
|
41
|
+
|
|
42
|
+
describe "when the cache control data save method is invoked" do
|
|
43
|
+
|
|
44
|
+
subject(:cache_control_data) do
|
|
45
|
+
Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# the checksum of the file last we fetched it.
|
|
49
|
+
let(:file_checksum) { "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }
|
|
50
|
+
|
|
51
|
+
let(:etag) { "\"a-strong-identifier\"" }
|
|
52
|
+
let(:mtime) { "Thu, 01 Aug 2013 08:16:32 GMT" }
|
|
53
|
+
|
|
54
|
+
before do
|
|
55
|
+
cache_control_data.etag = etag
|
|
56
|
+
cache_control_data.mtime = mtime
|
|
57
|
+
cache_control_data.checksum = file_checksum
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "writes data to the cache" do
|
|
61
|
+
cache_control_data.save
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "writes the data to the cache and the same data can be read back" do
|
|
65
|
+
cache_control_data.save
|
|
66
|
+
saved_cache_control_data = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
|
|
67
|
+
saved_cache_control_data.etag.should == cache_control_data.etag
|
|
68
|
+
saved_cache_control_data.mtime.should == cache_control_data.mtime
|
|
69
|
+
saved_cache_control_data.checksum.should == cache_control_data.checksum
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Cover the very long remote file path case -- see CHEF-4422 where
|
|
73
|
+
# local cache file names generated from the long uri exceeded
|
|
74
|
+
# local file system path limits resulting in exceptions from
|
|
75
|
+
# file system API's on both Windows and Unix systems.
|
|
76
|
+
context "when the length of the uri exceeds the path length limits for the local file system" do
|
|
77
|
+
let(:uri_exceeds_file_system_limit) do
|
|
78
|
+
URI.parse("http://www.bing.com/" + ('0' * 1024))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
let(:uri) { uri_exceeds_file_system_limit }
|
|
82
|
+
|
|
83
|
+
it "writes data to the cache" do
|
|
84
|
+
lambda do
|
|
85
|
+
cache_control_data.save
|
|
86
|
+
end.should_not raise_error
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "writes the data to the cache and the same data can be read back" do
|
|
90
|
+
cache_control_data.save
|
|
91
|
+
saved_cache_control_data = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
|
|
92
|
+
saved_cache_control_data.etag.should == cache_control_data.etag
|
|
93
|
+
saved_cache_control_data.mtime.should == cache_control_data.mtime
|
|
94
|
+
saved_cache_control_data.checksum.should == cache_control_data.checksum
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
|
4
|
+
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
|
5
|
+
# License:: Apache License, Version 2.0
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'spec_helper'
|
|
21
|
+
require 'webrick'
|
|
22
|
+
|
|
23
|
+
module AptServer
|
|
24
|
+
def enable_testing_apt_source
|
|
25
|
+
File.open("/etc/apt/sources.list.d/chef-integration-test.list", "w+") do |f|
|
|
26
|
+
f.puts "deb http://localhost:9000/ sid main"
|
|
27
|
+
end
|
|
28
|
+
# Magic to update apt cache for only our repo
|
|
29
|
+
shell_out!("apt-get update " +
|
|
30
|
+
'-o Dir::Etc::sourcelist="sources.list.d/chef-integration-test.list" ' +
|
|
31
|
+
'-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def disable_testing_apt_source
|
|
35
|
+
FileUtils.rm("/etc/apt/sources.list.d/chef-integration-test.list")
|
|
36
|
+
rescue Errno::ENOENT
|
|
37
|
+
puts("Attempted to remove integration test from /etc/apt/sources.list.d but it didn't exist")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def tcp_test_port(hostname, port)
|
|
41
|
+
tcp_socket = TCPSocket.new(hostname, port)
|
|
42
|
+
true
|
|
43
|
+
rescue Errno::ETIMEDOUT
|
|
44
|
+
false
|
|
45
|
+
rescue Errno::ECONNREFUSED
|
|
46
|
+
false
|
|
47
|
+
ensure
|
|
48
|
+
tcp_socket && tcp_socket.close
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def apt_server
|
|
52
|
+
@apt_server ||= WEBrick::HTTPServer.new(
|
|
53
|
+
:Port => 9000,
|
|
54
|
+
:DocumentRoot => apt_data_dir + "/var/www/apt",
|
|
55
|
+
# Make WEBrick quiet, comment out for debug.
|
|
56
|
+
:Logger => Logger.new(StringIO.new),
|
|
57
|
+
:AccessLog => [ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ]
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def run_apt_server
|
|
62
|
+
apt_server.start
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def start_apt_server
|
|
66
|
+
@apt_server_thread = Thread.new do
|
|
67
|
+
run_apt_server
|
|
68
|
+
end
|
|
69
|
+
until tcp_test_port("localhost", 9000) do
|
|
70
|
+
if @apt_server_thread.alive?
|
|
71
|
+
sleep 1
|
|
72
|
+
else
|
|
73
|
+
@apt_server_thread.join
|
|
74
|
+
raise "apt server failed to start"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def stop_apt_server
|
|
80
|
+
apt_server.shutdown
|
|
81
|
+
@apt_server_thread.join
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def apt_data_dir
|
|
85
|
+
File.join(CHEF_SPEC_DATA, "apt")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
metadata = { :unix_only => true,
|
|
90
|
+
:requires_root => true,
|
|
91
|
+
:provider => {:package => Chef::Provider::Package::Apt},
|
|
92
|
+
:arch => "x86_64" # test packages are 64bit
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
describe Chef::Resource::Package, metadata do
|
|
96
|
+
include Chef::Mixin::ShellOut
|
|
97
|
+
|
|
98
|
+
def chef_test_dpkg_installed?
|
|
99
|
+
shell_out("dpkg -l chef-integration-test").status.success?
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def dpkg_should_be_installed(pkg_name)
|
|
103
|
+
shell_out!("dpkg -l #{pkg_name}")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
context "with a remote package source" do
|
|
108
|
+
|
|
109
|
+
include AptServer
|
|
110
|
+
|
|
111
|
+
before(:all) do
|
|
112
|
+
# Disable mixlib-shellout live streams
|
|
113
|
+
Chef::Log.level = :warn
|
|
114
|
+
start_apt_server
|
|
115
|
+
enable_testing_apt_source
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
after(:all) do
|
|
119
|
+
stop_apt_server
|
|
120
|
+
disable_testing_apt_source
|
|
121
|
+
shell_out!("apt-get clean")
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
after do
|
|
126
|
+
shell_out!("dpkg -r chef-integration-test")
|
|
127
|
+
shell_out("dpkg --clear-avail")
|
|
128
|
+
shell_out!("apt-get clean")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
let(:node) do
|
|
132
|
+
n = Chef::Node.new
|
|
133
|
+
n.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
|
|
134
|
+
n
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
let(:events) do
|
|
138
|
+
Chef::EventDispatch::Dispatcher.new
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# TODO: lots of duplication from client.rb;
|
|
142
|
+
# All of this must be setup for preseed files to get found
|
|
143
|
+
let(:cookbook_collection) do
|
|
144
|
+
cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks")
|
|
145
|
+
cl = Chef::CookbookLoader.new(cookbook_path)
|
|
146
|
+
cl.load_cookbooks
|
|
147
|
+
Chef::Cookbook::FileVendor.on_create do |manifest|
|
|
148
|
+
Chef::Cookbook::FileSystemFileVendor.new(manifest, cookbook_path)
|
|
149
|
+
end
|
|
150
|
+
Chef::CookbookCollection.new(cl)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
let(:run_context) do
|
|
154
|
+
Chef::RunContext.new(node, cookbook_collection, events)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def base_resource
|
|
158
|
+
r = Chef::Resource::Package.new("chef-integration-test", run_context)
|
|
159
|
+
# The apt repository in the spec data is not gpg signed, so we need to
|
|
160
|
+
# force apt to accept the package:
|
|
161
|
+
r.options("--force-yes")
|
|
162
|
+
r
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
let(:package_resource) do
|
|
166
|
+
base_resource
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# it "results in a usable apt server" do
|
|
170
|
+
# shell_out!("apt-get install -q -y --force-yes chef-integration-test ", :env => { "DEBIAN_FRONTEND" => "noninteractive" })
|
|
171
|
+
# shell_out!("dpkg -l chef-integration-test")
|
|
172
|
+
# end
|
|
173
|
+
|
|
174
|
+
context "when the package is not yet installed" do
|
|
175
|
+
it "installs the package with action :install" do
|
|
176
|
+
package_resource.run_action(:install)
|
|
177
|
+
shell_out!("dpkg -l chef-integration-test")
|
|
178
|
+
package_resource.should be_updated_by_last_action
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it "installs the package for action :upgrade" do
|
|
182
|
+
package_resource.run_action(:upgrade)
|
|
183
|
+
shell_out!("dpkg -l chef-integration-test")
|
|
184
|
+
package_resource.should be_updated_by_last_action
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "does nothing for action :remove" do
|
|
188
|
+
package_resource.run_action(:remove)
|
|
189
|
+
shell_out!("dpkg -l chef-integration-test", :returns => [1])
|
|
190
|
+
package_resource.should_not be_updated_by_last_action
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it "does nothing for action :purge" do
|
|
194
|
+
package_resource.run_action(:purge)
|
|
195
|
+
shell_out!("dpkg -l chef-integration-test", :returns => [1])
|
|
196
|
+
package_resource.should_not be_updated_by_last_action
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
context "and a not-available package version is specified" do
|
|
200
|
+
let(:package_resource) do
|
|
201
|
+
r = base_resource
|
|
202
|
+
r.version("2.0")
|
|
203
|
+
r
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it "raises a reasonable error for action :install" do
|
|
207
|
+
expect do
|
|
208
|
+
package_resource.run_action(:install)
|
|
209
|
+
end.to raise_error(Chef::Exceptions::Exec)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
describe "when preseeding the install" do
|
|
215
|
+
|
|
216
|
+
let(:file_cache_path) { Dir.mktmpdir }
|
|
217
|
+
|
|
218
|
+
before do
|
|
219
|
+
@old_config = Chef::Config.configuration.dup
|
|
220
|
+
Chef::Config[:file_cache_path] = file_cache_path
|
|
221
|
+
debconf_reset = 'chef-integration-test chef-integration-test/sample-var string "INVALID"'
|
|
222
|
+
shell_out!("echo #{debconf_reset} |debconf-set-selections")
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
after do
|
|
226
|
+
FileUtils.rm_rf(file_cache_path)
|
|
227
|
+
Chef::Config.configuration = @old_config
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
context "with a preseed file" do
|
|
231
|
+
|
|
232
|
+
let(:package_resource) do
|
|
233
|
+
r = base_resource
|
|
234
|
+
r.cookbook_name = "preseed"
|
|
235
|
+
r.response_file("preseed-file.seed")
|
|
236
|
+
r
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it "preseeds the package, then installs it" do
|
|
240
|
+
package_resource.run_action(:install)
|
|
241
|
+
cmd = shell_out!("debconf-show chef-integration-test")
|
|
242
|
+
cmd.stdout.should include('chef-integration-test/sample-var: "hello world"')
|
|
243
|
+
package_resource.should be_updated_by_last_action
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
context "and the preseed file exists and is up-to-date" do
|
|
247
|
+
|
|
248
|
+
before do
|
|
249
|
+
# Code here is duplicated from the implementation. Not great, but
|
|
250
|
+
# it should at least fail if the code gets out of sync.
|
|
251
|
+
source = File.join(CHEF_SPEC_DATA, "cookbooks/preseed/files/default/preseed-file.seed")
|
|
252
|
+
file_cache_dir = Chef::FileCache.create_cache_path("preseed/preseed")
|
|
253
|
+
dest = "#{file_cache_dir}/chef-integration-test-1.1-1.seed"
|
|
254
|
+
FileUtils.cp(source, dest)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "does not update the package configuration" do
|
|
258
|
+
package_resource.run_action(:install)
|
|
259
|
+
cmd = shell_out!("debconf-show chef-integration-test")
|
|
260
|
+
cmd.stdout.should include('chef-integration-test/sample-var: INVALID')
|
|
261
|
+
package_resource.should be_updated_by_last_action
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
context "with a preseed template" do
|
|
269
|
+
|
|
270
|
+
let(:package_resource) do
|
|
271
|
+
r = base_resource
|
|
272
|
+
r.cookbook_name = "preseed"
|
|
273
|
+
r.response_file("preseed-template.seed")
|
|
274
|
+
r
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
before do
|
|
278
|
+
node.set[:preseed_value] = "FROM TEMPLATE"
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it "preseeds the package, then installs it" do
|
|
282
|
+
package_resource.run_action(:install)
|
|
283
|
+
cmd = shell_out!("debconf-show chef-integration-test")
|
|
284
|
+
cmd.stdout.should include('chef-integration-test/sample-var: "FROM TEMPLATE"')
|
|
285
|
+
package_resource.should be_updated_by_last_action
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
|