chef 0.8.10 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/bin/chef-client +2 -2
- data/bin/chef-solo +1 -2
- data/bin/knife +1 -2
- data/bin/shef +2 -5
- data/lib/chef.rb +11 -7
- data/lib/chef/application.rb +25 -20
- data/lib/chef/application/client.rb +12 -7
- data/lib/chef/application/knife.rb +7 -1
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/applications.rb +4 -0
- data/lib/chef/cache/checksum.rb +7 -6
- data/lib/chef/certificate.rb +2 -2
- data/lib/chef/client.rb +28 -4
- data/lib/chef/config.rb +4 -3
- data/lib/chef/cookbook_loader.rb +6 -1
- data/lib/chef/daemon.rb +2 -0
- data/lib/chef/data_bag_item.rb +2 -1
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/file_cache.rb +18 -18
- data/lib/chef/index_queue/indexable.rb +5 -3
- data/lib/chef/knife.rb +45 -13
- data/lib/chef/knife/client_list.rb +1 -1
- data/lib/chef/knife/client_show.rb +1 -1
- data/lib/chef/knife/configure.rb +47 -36
- data/lib/chef/knife/cookbook_list.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +22 -27
- data/lib/chef/knife/cookbook_metadata_from_file.rb +40 -0
- data/lib/chef/knife/cookbook_show.rb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +57 -0
- data/lib/chef/knife/cookbook_site_list.rb +55 -0
- data/lib/chef/knife/cookbook_site_search.rb +50 -0
- data/lib/chef/knife/cookbook_site_show.rb +56 -0
- data/lib/chef/knife/cookbook_site_vendor.rb +114 -0
- data/lib/chef/knife/cookbook_test.rb +103 -0
- data/lib/chef/knife/cookbook_upload.rb +29 -38
- data/lib/chef/knife/data_bag_edit.rb +1 -1
- data/lib/chef/knife/data_bag_list.rb +2 -2
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/ec2_instance_data.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +2 -2
- data/lib/chef/knife/node_from_file.rb +1 -1
- data/lib/chef/knife/node_list.rb +2 -2
- data/lib/chef/knife/node_run_list_add.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/node_show.rb +1 -1
- data/lib/chef/knife/rackspace_server_create.rb +156 -0
- data/lib/chef/knife/rackspace_server_delete.rb +57 -0
- data/lib/chef/knife/rackspace_server_list.rb +59 -0
- data/lib/chef/knife/role_from_file.rb +1 -1
- data/lib/chef/knife/role_list.rb +1 -1
- data/lib/chef/knife/role_show.rb +1 -1
- data/lib/chef/knife/search.rb +1 -1
- data/lib/chef/knife/ssh.rb +21 -4
- data/lib/chef/knife/terremark_server_create.rb +152 -0
- data/lib/chef/knife/terremark_server_delete.rb +87 -0
- data/lib/chef/knife/terremark_server_list.rb +77 -0
- data/lib/chef/mixin/command.rb +11 -9
- data/lib/chef/mixin/params_validate.rb +1 -1
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +4 -1
- data/lib/chef/mixin/template.rb +6 -5
- data/lib/chef/mixin/xml_escape.rb +3 -3
- data/lib/chef/mixins.rb +16 -0
- data/lib/chef/node.rb +53 -52
- data/lib/chef/openid_registration.rb +0 -1
- data/lib/chef/platform.rb +171 -137
- data/lib/chef/provider.rb +2 -2
- data/lib/chef/provider/cron.rb +22 -22
- data/lib/chef/provider/deploy/revision.rb +5 -1
- data/lib/chef/provider/erl_call.rb +2 -2
- data/lib/chef/provider/file.rb +44 -23
- data/lib/chef/provider/group/dscl.rb +6 -4
- data/lib/chef/provider/mdadm.rb +0 -4
- data/lib/chef/provider/mount/mount.rb +20 -8
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/freebsd.rb +22 -18
- data/lib/chef/provider/package/rubygems.rb +7 -10
- data/lib/chef/provider/remote_directory.rb +15 -0
- data/lib/chef/provider/remote_file.rb +73 -50
- data/lib/chef/provider/script.rb +10 -8
- data/lib/chef/provider/service/windows.rb +129 -0
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/template.rb +51 -50
- data/lib/chef/providers.rb +80 -0
- data/lib/chef/recipe.rb +2 -4
- data/lib/chef/resource.rb +21 -7
- data/lib/chef/resource/cron.rb +14 -5
- data/lib/chef/resource/deploy.rb +52 -45
- data/lib/chef/resource/execute.rb +1 -1
- data/lib/chef/resource/file.rb +16 -8
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/remote_directory.rb +19 -10
- data/lib/chef/resource/scm.rb +23 -16
- data/lib/chef/resource/service.rb +10 -1
- data/lib/chef/resources.rb +60 -0
- data/lib/chef/rest.rb +234 -189
- data/lib/chef/rest/auth_credentials.rb +78 -0
- data/lib/chef/{application/server.rb → rest/cookie_jar.rb} +18 -6
- data/lib/chef/rest/rest_request.rb +151 -0
- data/lib/chef/role.rb +38 -46
- data/lib/chef/streaming_cookbook_uploader.rb +8 -2
- data/lib/chef/tasks/chef_repo.rake +14 -4
- data/lib/chef/util/file_edit.rb +0 -1
- data/lib/chef/webui_user.rb +0 -1
- metadata +46 -9
- data/distro/suse/etc/init.d/chef-client +0 -121
@@ -0,0 +1,152 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 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 'chef/knife'
|
20
|
+
require 'json'
|
21
|
+
require 'tempfile'
|
22
|
+
|
23
|
+
class Chef
|
24
|
+
class Knife
|
25
|
+
class TerremarkServerCreate < Knife
|
26
|
+
|
27
|
+
banner "Sub-Command: terremark server create NAME [RUN LIST...] (options)"
|
28
|
+
|
29
|
+
option :terremark_password,
|
30
|
+
:short => "-K PASSWORD",
|
31
|
+
:long => "--terremark-password PASSWORD",
|
32
|
+
:description => "Your terremark password",
|
33
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:terremark_password] = key }
|
34
|
+
|
35
|
+
option :terremark_username,
|
36
|
+
:short => "-A USERNAME",
|
37
|
+
:long => "--terremark-username USERNAME",
|
38
|
+
:description => "Your terremark username",
|
39
|
+
:proc => Proc.new { |username| Chef::Config[:knife][:terremark_username] = username }
|
40
|
+
|
41
|
+
option :terremark_service,
|
42
|
+
:short => "-S SERVICE",
|
43
|
+
:long => "--terremark-service SERVICE",
|
44
|
+
:description => "Your terremark service name",
|
45
|
+
:proc => Proc.new { |service| Chef::Config[:knife][:terremark_service] = service }
|
46
|
+
|
47
|
+
def h
|
48
|
+
@highline ||= HighLine.new
|
49
|
+
end
|
50
|
+
|
51
|
+
def run
|
52
|
+
require 'fog'
|
53
|
+
require 'highline'
|
54
|
+
require 'net/ssh/multi'
|
55
|
+
require 'readline'
|
56
|
+
require 'net/scp'
|
57
|
+
|
58
|
+
server_name = @name_args[0]
|
59
|
+
|
60
|
+
terremark = Fog::Terremark.new(
|
61
|
+
:terremark_username => Chef::Config[:knife][:terremark_username],
|
62
|
+
:terremark_password => Chef::Config[:knife][:terremark_password],
|
63
|
+
:terremark_service => Chef::Config[:knife][:terremark_service] || :vcloud
|
64
|
+
)
|
65
|
+
|
66
|
+
$stdout.sync = true
|
67
|
+
|
68
|
+
puts "Instantiating vApp #{h.color(server_name, :bold)}"
|
69
|
+
vapp_id = terremark.instantiate_vapp_template(server_name).body['href'].split('/').last
|
70
|
+
|
71
|
+
deploy_task_id = terremark.deploy_vapp(vapp_id).body['href'].split('/').last
|
72
|
+
print "Waiting for deploy task [#{h.color(deploy_task_id, :bold)}]"
|
73
|
+
terremark.tasks.get(deploy_task_id).wait_for { print "."; ready? }
|
74
|
+
print "\n"
|
75
|
+
|
76
|
+
power_on_task_id = terremark.power_on(vapp_id).body['href'].split('/').last
|
77
|
+
print "Waiting for power on task [#{h.color(power_on_task_id, :bold)}]"
|
78
|
+
terremark.tasks.get(power_on_task_id).wait_for { print "."; ready? }
|
79
|
+
print "\n"
|
80
|
+
|
81
|
+
private_ip = terremark.get_vapp(vapp_id).body['IpAddress']
|
82
|
+
ssh_internet_service = terremark.create_internet_service(terremark.default_vdc_id, 'SSH', 'TCP', 22).body
|
83
|
+
ssh_internet_service_id = ssh_internet_service['Id']
|
84
|
+
public_ip = ssh_internet_service['PublicIpAddress']['Name']
|
85
|
+
public_ip_id = ssh_internet_service['PublicIpAddress']['Id']
|
86
|
+
ssh_node_service_id = terremark.add_node_service(ssh_internet_service_id, private_ip, 'SSH', 22).body['Id']
|
87
|
+
|
88
|
+
puts "\nBootstrapping #{h.color(server_name, :bold)}..."
|
89
|
+
password = terremark.get_vapp_template(12).body['Description'].scan(/\npassword: (.*)\n/).first.first
|
90
|
+
|
91
|
+
command = <<EOH
|
92
|
+
bash -c '
|
93
|
+
echo nameserver 208.67.222.222 > /etc/resolv.conf
|
94
|
+
echo nameserver 208.67.220.220 >> /etc/resolv.conf
|
95
|
+
|
96
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
97
|
+
apt-get update
|
98
|
+
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
|
99
|
+
cd /tmp
|
100
|
+
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
|
101
|
+
tar xvf rubygems-1.3.6.tgz
|
102
|
+
cd rubygems-1.3.6
|
103
|
+
ruby setup.rb
|
104
|
+
cp /usr/bin/gem1.8 /usr/bin/gem
|
105
|
+
gem install chef ohai --no-rdoc --no-ri --verbose
|
106
|
+
fi
|
107
|
+
|
108
|
+
mkdir -p /etc/chef
|
109
|
+
|
110
|
+
(
|
111
|
+
cat <<'EOP'
|
112
|
+
#{IO.read(Chef::Config[:validation_key])}
|
113
|
+
EOP
|
114
|
+
) > /etc/chef/validation.pem
|
115
|
+
|
116
|
+
(
|
117
|
+
cat <<'EOP'
|
118
|
+
log_level :info
|
119
|
+
log_location STDOUT
|
120
|
+
chef_server_url "#{Chef::Config[:chef_server_url]}"
|
121
|
+
validation_client_name "#{Chef::Config[:validation_client_name]}"
|
122
|
+
EOP
|
123
|
+
) > /etc/chef/client.rb
|
124
|
+
|
125
|
+
(
|
126
|
+
cat <<'EOP'
|
127
|
+
#{{ "run_list" => @name_args[1..-1] }.to_json}
|
128
|
+
EOP
|
129
|
+
) > /etc/chef/first-boot.json
|
130
|
+
|
131
|
+
/usr/bin/chef-client -j /etc/chef/first-boot.json'
|
132
|
+
EOH
|
133
|
+
|
134
|
+
begin
|
135
|
+
ssh = Chef::Knife::Ssh.new
|
136
|
+
ssh.name_args = [ public_ip, "sudo #{command}" ]
|
137
|
+
ssh.config[:ssh_user] = "vcloud"
|
138
|
+
ssh.config[:manual] = true
|
139
|
+
ssh.config[:password] = password
|
140
|
+
ssh.password = password
|
141
|
+
ssh.run
|
142
|
+
rescue Errno::ETIMEDOUT
|
143
|
+
puts "Timed out on bootstrap, re-trying. Hit CTRL-C to abort."
|
144
|
+
puts "You probably need to log in to Terremark and powercycle #{h.color(@name_args[0], :bold)}"
|
145
|
+
retry
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 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 'chef/knife'
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
class TerremarkServerDelete < Knife
|
25
|
+
|
26
|
+
banner "Sub-Command: terremark server delete SERVER (options)"
|
27
|
+
|
28
|
+
def h
|
29
|
+
@highline ||= HighLine.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
require 'fog'
|
34
|
+
require 'highline'
|
35
|
+
|
36
|
+
terremark = Fog::Terremark.new(
|
37
|
+
:terremark_username => Chef::Config[:knife][:terremark_username],
|
38
|
+
:terremark_password => Chef::Config[:knife][:terremark_password],
|
39
|
+
:terremark_service => Chef::Config[:knife][:terremark_service] || :vcloud
|
40
|
+
)
|
41
|
+
|
42
|
+
$stdout.sync = true
|
43
|
+
|
44
|
+
vapp_id = terremark.servers.detect {|server| server.name == @name_args[0]}.id
|
45
|
+
confirm("Do you really want to delete server ID #{vapp_id} named #{@name_args[0]}")
|
46
|
+
|
47
|
+
puts "Cleaning up internet services..."
|
48
|
+
private_ip = terremark.servers.get(vapp_id).ip_address
|
49
|
+
internet_services = terremark.get_internet_services(terremark.default_vdc_id).body['InternetServices']
|
50
|
+
public_ip_usage = {}
|
51
|
+
internet_services.each do |internet_service|
|
52
|
+
public_ip_address = internet_service['PublicIpAddress']['Name']
|
53
|
+
public_ip_usage[public_ip_address] ||= []
|
54
|
+
public_ip_usage[public_ip_address] << internet_service['Id']
|
55
|
+
end
|
56
|
+
internet_services.each do |internet_service|
|
57
|
+
node_services = terremark.get_node_services(internet_service['Id']).body['NodeServices']
|
58
|
+
node_services.delete_if do |node_service|
|
59
|
+
if node_service['IpAddress'] == private_ip
|
60
|
+
terremark.delete_node_service(node_service['Id'])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
if node_services.empty?
|
64
|
+
terremark.delete_internet_service(internet_service['Id'])
|
65
|
+
public_ip_usage.each_value {|internet_services| internet_services.delete(internet_service['Id'])}
|
66
|
+
if public_ip_usage[internet_service['PublicIpAddress']['Name']].empty?
|
67
|
+
terremark.delete_public_ip(internet_service['PublicIpAddress']['Id'])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
power_off_task_id = terremark.power_off(vapp_id).body['href'].split('/').last
|
73
|
+
print "Waiting for power off task [#{h.color(power_off_task_id, :bold)}]"
|
74
|
+
terremark.tasks.get(power_off_task_id).wait_for { print '.'; ready? }
|
75
|
+
print "\n"
|
76
|
+
|
77
|
+
print "Deleting vApp #{h.color(vapp_id, :bold)}"
|
78
|
+
delete_vapp_task_id = terremark.delete_vapp(vapp_id).headers['Location'].split('/').last
|
79
|
+
terremark.tasks.get(delete_vapp_task_id).wait_for { print '.'; ready? }
|
80
|
+
print "\n"
|
81
|
+
|
82
|
+
Chef::Log.warn("Deleted server #{@name_args[0]}")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 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 'chef/knife'
|
20
|
+
require 'json'
|
21
|
+
require 'tempfile'
|
22
|
+
|
23
|
+
class Chef
|
24
|
+
class Knife
|
25
|
+
class TerremarkServerList < Knife
|
26
|
+
|
27
|
+
banner "Sub-Command: terremark server list (options)"
|
28
|
+
|
29
|
+
option :terremark_password,
|
30
|
+
:short => "-K PASSWORD",
|
31
|
+
:long => "--terremark-password PASSWORD",
|
32
|
+
:description => "Your terremark password",
|
33
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:terremark_password] = key }
|
34
|
+
|
35
|
+
option :terremark_username,
|
36
|
+
:short => "-A USERNAME",
|
37
|
+
:long => "--terremark-username USERNAME",
|
38
|
+
:description => "Your terremark username",
|
39
|
+
:proc => Proc.new { |username| Chef::Config[:knife][:terremark_username] = username }
|
40
|
+
|
41
|
+
option :terremark_service,
|
42
|
+
:short => "-S SERVICE",
|
43
|
+
:long => "--terremark-service SERVICE",
|
44
|
+
:description => "Your terremark service name",
|
45
|
+
:proc => Proc.new { |service| Chef::Config[:knife][:terremark_service] = service }
|
46
|
+
|
47
|
+
def h
|
48
|
+
@highline ||= HighLine.new
|
49
|
+
end
|
50
|
+
|
51
|
+
def run
|
52
|
+
require 'fog'
|
53
|
+
require 'highline'
|
54
|
+
|
55
|
+
server_name = @name_args[0]
|
56
|
+
|
57
|
+
terremark = Fog::Terremark.new(
|
58
|
+
:terremark_username => Chef::Config[:knife][:terremark_username],
|
59
|
+
:terremark_password => Chef::Config[:knife][:terremark_password],
|
60
|
+
:terremark_service => Chef::Config[:knife][:terremark_service] || :vcloud
|
61
|
+
)
|
62
|
+
|
63
|
+
$stdout.sync = true
|
64
|
+
|
65
|
+
server_list = [ h.color('ID', :bold), h.color('Name', :bold) ]
|
66
|
+
terremark.servers.all.each do |server|
|
67
|
+
server_list << server.id.to_s
|
68
|
+
server_list << server.name
|
69
|
+
end
|
70
|
+
puts h.list(server_list, :columns_across, 2)
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
data/lib/chef/mixin/command.rb
CHANGED
@@ -97,6 +97,7 @@ class Chef
|
|
97
97
|
# timeout<String>: How many seconds to wait for the command to execute before timing out
|
98
98
|
# returns<String>: The single exit value command is expected to return, otherwise causes an exception
|
99
99
|
# ignore_failure<Boolean>: Whether to raise an exception on failure, or just return the status
|
100
|
+
# output_on_failure<Boolean>: Return output in raised exception regardless of Log.level
|
100
101
|
#
|
101
102
|
# user<String>: The UID or user name of the user to execute the command as
|
102
103
|
# group<String>: The GID or group name of the group to execute the command as
|
@@ -108,6 +109,7 @@ class Chef
|
|
108
109
|
command_output = ""
|
109
110
|
|
110
111
|
args[:ignore_failure] ||= false
|
112
|
+
args[:output_on_failure] ||= false
|
111
113
|
|
112
114
|
if args.has_key?(:creates)
|
113
115
|
if File.exists?(args[:creates])
|
@@ -165,18 +167,18 @@ class Chef
|
|
165
167
|
|
166
168
|
module_function :output_of_command
|
167
169
|
|
168
|
-
def handle_command_failures(status, command_output,
|
169
|
-
unless
|
170
|
-
|
171
|
-
|
170
|
+
def handle_command_failures(status, command_output, opts={})
|
171
|
+
unless opts[:ignore_failure]
|
172
|
+
opts[:returns] ||= 0
|
173
|
+
unless Array(opts[:returns]).include?(status.exitstatus)
|
172
174
|
# if the log level is not debug, through output of command when we fail
|
173
175
|
output = ""
|
174
|
-
if Chef::Log.level == :debug
|
175
|
-
output << "\n---- Begin output of #{
|
176
|
-
output <<
|
177
|
-
output << "---- End output of #{
|
176
|
+
if Chef::Log.level == :debug || opts[:output_on_failure]
|
177
|
+
output << "\n---- Begin output of #{opts[:command]} ----\n"
|
178
|
+
output << command_output.to_s
|
179
|
+
output << "\n---- End output of #{opts[:command]} ----\n"
|
178
180
|
end
|
179
|
-
raise Chef::Exceptions::Exec, "#{
|
181
|
+
raise Chef::Exceptions::Exec, "#{opts[:command]} returned #{status.exitstatus}, expected #{opts[:returns]}#{output}"
|
180
182
|
end
|
181
183
|
end
|
182
184
|
end
|
@@ -193,7 +193,7 @@ class Chef
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
unless passes
|
196
|
-
raise Exceptions::ValidationFailed, "Option #{key}'s value #{value} does not match regular expression #{regex.
|
196
|
+
raise Exceptions::ValidationFailed, "Option #{key}'s value #{value} does not match regular expression #{regex.inspect}"
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
@@ -17,11 +17,14 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'chef/recipe'
|
21
20
|
require 'chef/resource'
|
22
21
|
require 'chef/mixin/convert_to_class_name'
|
23
22
|
require 'chef/mixin/language'
|
24
23
|
|
24
|
+
# UGH. this is a circular require that will cause an uninitialized constant
|
25
|
+
# error, but this file really does depend on Chef::Recipe. oh well.
|
26
|
+
# require 'chef/recipe'
|
27
|
+
|
25
28
|
class Chef
|
26
29
|
module Mixin
|
27
30
|
module RecipeDefinitionDSLCore
|
data/lib/chef/mixin/template.rb
CHANGED
@@ -42,15 +42,16 @@ class Chef
|
|
42
42
|
rescue Object => e
|
43
43
|
raise TemplateError.new(e, template, context)
|
44
44
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
Tempfile.open("chef-rendered-template") do |tempfile|
|
46
|
+
tempfile.print(output)
|
47
|
+
tempfile.close
|
48
|
+
yield tempfile
|
49
|
+
end
|
49
50
|
end
|
50
51
|
|
51
52
|
class TemplateError < RuntimeError
|
52
53
|
attr_reader :original_exception, :context
|
53
|
-
SOURCE_CONTEXT_WINDOW = 2
|
54
|
+
SOURCE_CONTEXT_WINDOW = 2
|
54
55
|
|
55
56
|
def initialize(original_exception, template, context)
|
56
57
|
@original_exception, @template, @context = original_exception, template, context
|
@@ -80,18 +80,18 @@ class Chef
|
|
80
80
|
156 => 339, # latin small ligature oe
|
81
81
|
158 => 382, # latin small letter z with caron
|
82
82
|
159 => 376 # latin capital letter y with diaeresis
|
83
|
-
}
|
83
|
+
}
|
84
84
|
|
85
85
|
# http://www.w3.org/TR/REC-xml/#dt-chardata
|
86
86
|
PREDEFINED = {
|
87
87
|
38 => '&', # ampersand
|
88
88
|
60 => '<', # left angle bracket
|
89
89
|
62 => '>' # right angle bracket
|
90
|
-
}
|
90
|
+
}
|
91
91
|
|
92
92
|
# http://www.w3.org/TR/REC-xml/#charsets
|
93
93
|
VALID = [[0x9, 0xA, 0xD], (0x20..0xD7FF),
|
94
|
-
(0xE000..0xFFFD), (0x10000..0x10FFFF)]
|
94
|
+
(0xE000..0xFFFD), (0x10000..0x10FFFF)]
|
95
95
|
|
96
96
|
def xml_escape(unescaped_str)
|
97
97
|
begin
|
data/lib/chef/mixins.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'chef/mixin/check_helper'
|
2
|
+
require 'chef/mixin/checksum'
|
3
|
+
require 'chef/mixin/command'
|
4
|
+
require 'chef/mixin/convert_to_class_name'
|
5
|
+
require 'chef/mixin/create_path'
|
6
|
+
require 'chef/mixin/deep_merge'
|
7
|
+
require 'chef/mixin/find_preferred_file'
|
8
|
+
require 'chef/mixin/from_file'
|
9
|
+
require 'chef/mixin/generate_url'
|
10
|
+
require 'chef/mixin/language'
|
11
|
+
require 'chef/mixin/language_include_attribute'
|
12
|
+
require 'chef/mixin/language_include_recipe'
|
13
|
+
require 'chef/mixin/params_validate'
|
14
|
+
require 'chef/mixin/recipe_definition_dsl_core'
|
15
|
+
require 'chef/mixin/template'
|
16
|
+
require 'chef/mixin/xml_escape'
|