chef 0.8.16 → 0.9.0.a3
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/shef +1 -0
- data/distro/common/man/man1/chef-server-webui.1 +106 -0
- data/distro/common/man/man1/chef-server.1 +0 -1
- data/distro/common/man/man1/chef-solr-indexer.1 +55 -0
- data/distro/common/man/man1/chef-solr.1 +55 -0
- data/distro/common/man/man8/chef-client.8 +4 -2
- data/distro/common/man/man8/chef-solo.8 +1 -2
- data/distro/common/man/man8/chef-solr-rebuild.8 +37 -0
- data/distro/common/man/man8/knife.8 +668 -266
- data/distro/common/man/man8/shef.8 +45 -0
- data/distro/common/markdown/README +3 -0
- data/distro/common/markdown/knife.mkd +520 -0
- data/distro/debian/etc/default/chef-client +4 -0
- data/distro/debian/etc/default/chef-server +6 -0
- data/distro/debian/etc/default/chef-server-webui +6 -0
- data/distro/debian/etc/default/chef-solr +4 -0
- data/distro/debian/etc/default/chef-solr-indexer +4 -0
- data/distro/debian/etc/init.d/chef-client +41 -41
- data/distro/debian/etc/init.d/chef-server +10 -10
- data/distro/debian/etc/init.d/chef-server-webui +121 -0
- data/distro/debian/etc/init.d/chef-solr +177 -0
- data/distro/debian/etc/init.d/chef-solr-indexer +176 -0
- data/distro/redhat/etc/init.d/chef-client +76 -48
- data/distro/redhat/etc/init.d/chef-server +85 -51
- data/distro/redhat/etc/init.d/chef-server-webui +85 -51
- data/distro/redhat/etc/init.d/chef-solr +77 -49
- data/distro/redhat/etc/init.d/chef-solr-indexer +77 -48
- data/distro/redhat/etc/logrotate.d/chef-client +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server-webui +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr-indexer +8 -0
- data/distro/redhat/etc/sysconfig/chef-client +9 -4
- data/distro/redhat/etc/sysconfig/chef-server +10 -6
- data/distro/redhat/etc/sysconfig/chef-server-webui +10 -6
- data/distro/redhat/etc/sysconfig/chef-solr +3 -4
- data/distro/redhat/etc/sysconfig/chef-solr-indexer +3 -3
- data/lib/chef.rb +16 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/solo.rb +1 -7
- data/lib/chef/cache/checksum.rb +12 -5
- data/lib/chef/cache/file_cache_by_checksum.rb +52 -0
- data/lib/chef/checksum.rb +115 -0
- data/lib/chef/client.rb +193 -185
- data/lib/chef/config.rb +9 -1
- data/lib/chef/cookbook/cookbook_collection.rb +43 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +53 -0
- data/lib/chef/cookbook/file_vendor.rb +47 -0
- data/lib/chef/cookbook/metadata.rb +34 -35
- data/lib/chef/cookbook/metadata/version.rb +1 -1
- data/lib/chef/cookbook_loader.rb +70 -45
- data/lib/chef/cookbook_version.rb +760 -0
- data/lib/chef/couchdb.rb +8 -5
- data/lib/chef/data_bag_item.rb +5 -5
- data/lib/chef/exceptions.rb +10 -0
- data/lib/chef/file_access_control.rb +134 -0
- data/lib/chef/handler.rb +62 -0
- data/lib/chef/handler/json_file.rb +47 -0
- data/lib/chef/knife.rb +14 -2
- data/lib/chef/knife/bootstrap.rb +126 -0
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_delete.rb +4 -4
- data/lib/chef/knife/cookbook_download.rb +57 -26
- data/lib/chef/knife/cookbook_metadata.rb +2 -2
- data/lib/chef/knife/cookbook_show.rb +30 -11
- data/lib/chef/knife/cookbook_upload.rb +113 -86
- data/lib/chef/knife/ec2_server_create.rb +146 -0
- data/lib/chef/knife/ec2_server_delete.rb +84 -0
- data/lib/chef/knife/ec2_server_list.rb +82 -0
- data/lib/chef/knife/status.rb +51 -0
- data/lib/chef/mixin/language_include_attribute.rb +16 -11
- data/lib/chef/mixin/language_include_recipe.rb +15 -16
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +17 -20
- data/lib/chef/mixin/shell_out.rb +38 -0
- data/lib/chef/mixins.rb +1 -1
- data/lib/chef/node.rb +190 -63
- data/lib/chef/node/attribute.rb +92 -78
- data/lib/chef/platform.rb +24 -4
- data/lib/chef/provider.rb +28 -10
- data/lib/chef/provider/breakpoint.rb +2 -2
- data/lib/chef/provider/cookbook_file.rb +96 -0
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/deploy.rb +12 -10
- data/lib/chef/provider/env.rb +152 -0
- data/lib/chef/provider/env/windows.rb +75 -0
- data/lib/chef/provider/file.rb +10 -14
- data/lib/chef/provider/group.rb +15 -2
- data/lib/chef/provider/group/dscl.rb +17 -25
- data/lib/chef/provider/group/gpasswd.rb +6 -3
- data/lib/chef/provider/group/pw.rb +3 -7
- data/lib/chef/provider/group/windows.rb +79 -0
- data/lib/chef/provider/link.rb +4 -5
- data/lib/chef/provider/mdadm.rb +25 -18
- data/lib/chef/provider/mount/mount.rb +28 -27
- data/lib/chef/provider/package.rb +35 -35
- data/lib/chef/provider/package/dpkg.rb +13 -10
- data/lib/chef/provider/package/easy_install.rb +6 -6
- data/lib/chef/provider/package/freebsd.rb +17 -51
- data/lib/chef/provider/package/rpm.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +391 -74
- data/lib/chef/provider/package/yum.rb +2 -2
- data/lib/chef/provider/package/zypper.rb +2 -1
- data/lib/chef/provider/remote_directory.rb +60 -83
- data/lib/chef/provider/remote_file.rb +17 -66
- data/lib/chef/provider/script.rb +20 -9
- data/lib/chef/provider/service.rb +23 -30
- data/lib/chef/provider/service/arch.rb +3 -3
- data/lib/chef/provider/service/debian.rb +22 -17
- data/lib/chef/provider/service/freebsd.rb +4 -4
- data/lib/chef/provider/service/init.rb +2 -2
- data/lib/chef/provider/service/redhat.rb +14 -16
- data/lib/chef/provider/service/simple.rb +7 -3
- data/lib/chef/provider/service/solaris.rb +85 -0
- data/lib/chef/provider/service/upstart.rb +12 -7
- data/lib/chef/provider/service/windows.rb +2 -2
- data/lib/chef/provider/template.rb +133 -118
- data/lib/chef/provider/user.rb +34 -17
- data/lib/chef/provider/user/dscl.rb +117 -114
- data/lib/chef/provider/user/windows.rb +124 -0
- data/lib/chef/providers.rb +7 -0
- data/lib/chef/recipe.rb +39 -20
- data/lib/chef/resource.rb +47 -52
- data/lib/chef/resource/apt_package.rb +4 -4
- data/lib/chef/resource/bash.rb +4 -4
- data/lib/chef/resource/cookbook_file.rb +45 -0
- data/lib/chef/resource/cron.rb +3 -3
- data/lib/chef/resource/csh.rb +4 -4
- data/lib/chef/resource/deploy.rb +3 -3
- data/lib/chef/resource/directory.rb +4 -4
- data/lib/chef/resource/dpkg_package.rb +4 -4
- data/lib/chef/resource/easy_install_package.rb +3 -3
- data/lib/chef/resource/env.rb +58 -0
- data/lib/chef/resource/erl_call.rb +3 -3
- data/lib/chef/resource/execute.rb +3 -3
- data/lib/chef/resource/file.rb +3 -3
- data/lib/chef/resource/freebsd_package.rb +3 -3
- data/lib/chef/resource/gem_package.rb +17 -9
- data/lib/chef/resource/git.rb +3 -3
- data/lib/chef/resource/group.rb +3 -3
- data/lib/chef/resource/http_request.rb +4 -4
- data/lib/chef/resource/ifconfig.rb +3 -3
- data/lib/chef/resource/link.rb +3 -3
- data/lib/chef/resource/log.rb +2 -2
- data/lib/chef/resource/macports_package.rb +2 -2
- data/lib/chef/resource/mdadm.rb +3 -3
- data/lib/chef/resource/mount.rb +2 -2
- data/lib/chef/resource/package.rb +4 -4
- data/lib/chef/resource/pacman_package.rb +4 -4
- data/lib/chef/resource/perl.rb +4 -4
- data/lib/chef/resource/portage_package.rb +4 -4
- data/lib/chef/resource/python.rb +4 -4
- data/lib/chef/resource/remote_directory.rb +3 -3
- data/lib/chef/resource/remote_file.rb +26 -3
- data/lib/chef/resource/route.rb +3 -3
- data/lib/chef/resource/ruby.rb +3 -3
- data/lib/chef/resource/ruby_block.rb +3 -2
- data/lib/chef/resource/scm.rb +7 -5
- data/lib/chef/resource/script.rb +4 -4
- data/lib/chef/resource/service.rb +3 -3
- data/lib/chef/resource/subversion.rb +4 -2
- data/lib/chef/resource/template.rb +3 -3
- data/lib/chef/resource/user.rb +3 -3
- data/lib/chef/resource/yum_package.rb +3 -3
- data/lib/chef/resource_collection.rb +9 -5
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/rest.rb +4 -0
- data/lib/chef/role.rb +2 -0
- data/lib/chef/run_context.rb +108 -0
- data/lib/chef/run_list.rb +75 -98
- data/lib/chef/run_list/run_list_expansion.rb +156 -0
- data/lib/chef/run_list/run_list_item.rb +71 -0
- data/lib/chef/runner.rb +58 -61
- data/lib/chef/sandbox.rb +147 -0
- data/lib/chef/shef.rb +4 -3
- data/lib/chef/shef/ext.rb +12 -4
- data/lib/chef/shef/shef_session.rb +27 -23
- data/lib/chef/shell_out.rb +375 -0
- data/lib/chef/util/windows.rb +56 -0
- data/lib/chef/util/windows/net_group.rb +101 -0
- data/lib/chef/util/windows/net_user.rb +198 -0
- data/lib/chef/version.rb +20 -0
- metadata +112 -22
- data/lib/chef/compile.rb +0 -158
- data/lib/chef/cookbook.rb +0 -201
- data/lib/chef/mixin/generate_url.rb +0 -58
@@ -106,9 +106,9 @@ class Chef
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
def initialize(
|
109
|
+
def initialize(new_resource, run_context)
|
110
110
|
@yum = YumCache.instance
|
111
|
-
super
|
111
|
+
super
|
112
112
|
end
|
113
113
|
|
114
114
|
def load_current_resource
|
@@ -32,8 +32,9 @@ class Chef
|
|
32
32
|
@current_resource.package_name(@new_resource.package_name)
|
33
33
|
|
34
34
|
is_installed=false
|
35
|
-
version=''
|
36
35
|
is_out_of_date=false
|
36
|
+
version=''
|
37
|
+
oud_version=''
|
37
38
|
Chef::Log.debug("Checking zypper for #{@new_resource.package_name}")
|
38
39
|
status = popen4("zypper info #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
|
39
40
|
stdout.each do |line|
|
@@ -18,8 +18,8 @@
|
|
18
18
|
|
19
19
|
require 'chef/provider/file'
|
20
20
|
require 'chef/provider/directory'
|
21
|
-
require 'chef/rest'
|
22
|
-
require 'chef/mixin/find_preferred_file'
|
21
|
+
#require 'chef/rest'
|
22
|
+
#require 'chef/mixin/find_preferred_file'
|
23
23
|
require 'chef/resource/directory'
|
24
24
|
require 'chef/resource/remote_file'
|
25
25
|
require 'chef/platform'
|
@@ -32,30 +32,29 @@ class Chef
|
|
32
32
|
class Provider
|
33
33
|
class RemoteDirectory < Chef::Provider::Directory
|
34
34
|
|
35
|
-
include ::Chef::Mixin::FindPreferredFile
|
36
|
-
|
37
35
|
def action_create
|
38
36
|
super
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
protected
|
43
|
-
|
44
|
-
def do_recursive
|
45
|
-
if Chef::Config[:solo]
|
46
|
-
Chef::Log.debug("Doing a local recursive directory copy for #{@new_resource}")
|
47
|
-
else
|
48
|
-
Chef::Log.debug("Doing a remote recursive directory transfer for #{@new_resource}")
|
49
|
-
end
|
37
|
+
Chef::Log.debug("Doing a remote recursive directory transfer for #{@new_resource}")
|
50
38
|
|
51
|
-
|
39
|
+
files_to_purge = Set.new Dir[::File.join(@new_resource.path, '**', '*')]
|
52
40
|
|
53
|
-
files_to_transfer.each do |
|
54
|
-
|
55
|
-
|
41
|
+
files_to_transfer.each do |cookbook_file_relative_path|
|
42
|
+
create_cookbook_file(cookbook_file_relative_path)
|
43
|
+
files_to_purge.delete(::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)))
|
44
|
+
files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
|
56
45
|
end
|
46
|
+
purge_unmanaged_files(files_to_purge)
|
47
|
+
end
|
48
|
+
|
49
|
+
def action_create_if_missing
|
50
|
+
raise Chef::Exceptions::UnsupportedAction, "Remote Directories do not support create_if_missing."
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def purge_unmanaged_files(unmanaged_files)
|
57
56
|
if @new_resource.purge
|
58
|
-
|
57
|
+
unmanaged_files.sort.reverse.each do |f|
|
59
58
|
if ::File.directory?(f)
|
60
59
|
Chef::Log.debug("Removing directory #{f}")
|
61
60
|
Dir::rmdir(f)
|
@@ -66,89 +65,67 @@ class Chef
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
69
|
-
|
68
|
+
|
70
69
|
def files_to_transfer
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
cookbook = run_context.cookbook_collection[resource_cookbook]
|
71
|
+
files = cookbook.relative_filenames_in_preferred_directory(node, :files, @new_resource.source)
|
72
|
+
files.sort.reverse
|
74
73
|
end
|
75
74
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
@new_resource.
|
80
|
-
:remote_file,
|
81
|
-
@new_resource.source,
|
82
|
-
@node[:fqdn],
|
83
|
-
@node[:platform],
|
84
|
-
@node[:platform_version]
|
85
|
-
)
|
86
|
-
|
87
|
-
unless (directory && ::File.directory?(directory))
|
88
|
-
raise NotFound, "Cannot find a suitable directory"
|
75
|
+
def directory_root_in_cookbook_cache
|
76
|
+
@directory_root_in_cookbook_cache ||= begin
|
77
|
+
cookbook = run_context.cookbook_collection[resource_cookbook]
|
78
|
+
cookbook.preferred_filename_on_disk_location(node, :files, @new_resource.source, @new_resource.path)
|
89
79
|
end
|
90
|
-
|
91
|
-
file_list = Array.new
|
92
|
-
Dir[::File.join(directory, '**', '*')].sort.reverse.select do |file|
|
93
|
-
unless ::File.directory?(file)
|
94
|
-
file_list << file[/^#{directory}\/(.+)$/, 1]
|
95
|
-
end
|
96
|
-
end
|
97
|
-
file_list
|
98
80
|
end
|
99
81
|
|
100
|
-
|
101
|
-
|
102
|
-
|
82
|
+
# Determine the cookbook to get the file from. If new resource sets an
|
83
|
+
# explicit cookbook, use it, otherwise fall back to the implicit cookbook
|
84
|
+
# i.e., the cookbook the resource was declared in.
|
85
|
+
def resource_cookbook
|
86
|
+
@new_resource.cookbook || @new_resource.cookbook_name
|
103
87
|
end
|
104
|
-
|
105
|
-
def
|
106
|
-
full_path = ::File.join(@new_resource.path,
|
88
|
+
|
89
|
+
def create_cookbook_file(cookbook_file_relative_path)
|
90
|
+
full_path = ::File.join(@new_resource.path, cookbook_file_relative_path)
|
107
91
|
|
108
92
|
ensure_directory_exists(::File.dirname(full_path))
|
109
93
|
|
110
|
-
file_to_fetch =
|
111
|
-
file_to_fetch.
|
112
|
-
file_to_fetch.
|
113
|
-
@new_resource.updated = true if file_to_fetch.new_resource.updated
|
94
|
+
file_to_fetch = cookbook_file_resource(full_path, cookbook_file_relative_path)
|
95
|
+
file_to_fetch.run_action(:create)
|
96
|
+
@new_resource.updated = true if file_to_fetch.updated?
|
114
97
|
end
|
115
98
|
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
99
|
+
def cookbook_file_resource(target_path, relative_source_path)
|
100
|
+
cookbook_file = Chef::Resource::CookbookFile.new(target_path, run_context)
|
101
|
+
cookbook_file.cookbook_name = @new_resource.cookbook || @new_resource.cookbook_name
|
102
|
+
cookbook_file.source(::File.join(@new_resource.source, relative_source_path))
|
103
|
+
cookbook_file.mode(@new_resource.files_mode) if @new_resource.files_mode
|
104
|
+
cookbook_file.group(@new_resource.files_group) if @new_resource.files_group
|
105
|
+
cookbook_file.owner(@new_resource.files_owner) if @new_resource.files_owner
|
106
|
+
cookbook_file.backup(@new_resource.files_backup) if @new_resource.files_backup
|
124
107
|
|
125
|
-
|
108
|
+
cookbook_file
|
126
109
|
end
|
127
110
|
|
128
111
|
def ensure_directory_exists(path)
|
129
112
|
unless ::File.directory?(path)
|
130
|
-
directory_to_create =
|
131
|
-
directory_to_create.
|
132
|
-
directory_to_create.
|
133
|
-
@new_resource.updated = true if directory_to_create.new_resource.updated
|
113
|
+
directory_to_create = resource_for_directory(path)
|
114
|
+
directory_to_create.run_action(:create)
|
115
|
+
@new_resource.updated = true if directory_to_create.updated?
|
134
116
|
end
|
135
117
|
end
|
136
|
-
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
Chef::Platform.provider_for_node(@node, new_dir)
|
146
|
-
end
|
147
|
-
|
148
|
-
def action_create_if_missing
|
149
|
-
raise Chef::Exceptions::UnsupportedAction, "Remote Directories do not support create_if_missing."
|
118
|
+
|
119
|
+
def resource_for_directory(path)
|
120
|
+
dir = Chef::Resource::Directory.new(path, run_context)
|
121
|
+
dir.cookbook_name = @new_resource.cookbook || @new_resource.cookbook_name
|
122
|
+
dir.mode(@new_resource.mode)
|
123
|
+
dir.group(@new_resource.group)
|
124
|
+
dir.owner(@new_resource.owner)
|
125
|
+
dir.recursive(true)
|
126
|
+
dir
|
150
127
|
end
|
151
128
|
|
152
129
|
end
|
153
130
|
end
|
154
|
-
end
|
131
|
+
end
|
@@ -31,56 +31,38 @@ class Chef
|
|
31
31
|
|
32
32
|
def action_create
|
33
33
|
Chef::Log.debug("Checking #{@new_resource} for changes")
|
34
|
-
do_remote_file(@new_resource.source, @current_resource.path)
|
35
|
-
end
|
36
|
-
|
37
|
-
def action_create_if_missing
|
38
|
-
if ::File.exists?(@new_resource.path)
|
39
|
-
Chef::Log.debug("File #{@new_resource.path} exists, taking no action.")
|
40
|
-
else
|
41
|
-
action_create
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def do_remote_file(source, path)
|
46
|
-
retval = true
|
47
34
|
|
48
35
|
if current_resource_matches_target_checksum?
|
49
36
|
Chef::Log.debug("File #{@new_resource} checksum matches target checksum (#{@new_resource.checksum}), not updating")
|
50
37
|
else
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Chef::Log.debug "#{@new_resource}: Target and Source checksums are the same, taking no action"
|
55
|
-
else
|
56
|
-
backup_new_resource
|
57
|
-
Chef::Log.debug "copying remote file from origin #{raw_file.path} to destination #{@new_resource.path}"
|
58
|
-
FileUtils.cp raw_file.path, @new_resource.path
|
59
|
-
@new_resource.updated = true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
rescue Net::HTTPRetriableError => e
|
63
|
-
if e.response.kind_of?(Net::HTTPNotModified)
|
64
|
-
Chef::Log.debug("File #{path} is unchanged")
|
65
|
-
retval = false
|
38
|
+
Chef::REST.new(@new_resource.source, nil, nil).fetch(@new_resource.source) do |raw_file|
|
39
|
+
if matches_current_checksum?(raw_file)
|
40
|
+
Chef::Log.debug "#{@new_resource}: Target and Source checksums are the same, taking no action"
|
66
41
|
else
|
67
|
-
|
42
|
+
backup_new_resource
|
43
|
+
Chef::Log.debug "copying remote file from origin #{raw_file.path} to destination #{@new_resource.path}"
|
44
|
+
FileUtils.cp raw_file.path, @new_resource.path
|
45
|
+
@new_resource.updated = true
|
68
46
|
end
|
69
47
|
end
|
70
|
-
|
71
|
-
Chef::Log.debug "#{@new_resource} completed"
|
72
|
-
retval
|
73
48
|
end
|
74
49
|
enforce_ownership_and_permissions
|
75
50
|
|
76
|
-
|
51
|
+
@new_resource.updated
|
52
|
+
end
|
53
|
+
|
54
|
+
def action_create_if_missing
|
55
|
+
if ::File.exists?(@new_resource.path)
|
56
|
+
Chef::Log.debug("File #{@new_resource.path} exists, taking no action.")
|
57
|
+
else
|
58
|
+
action_create
|
59
|
+
end
|
77
60
|
end
|
78
61
|
|
79
62
|
def enforce_ownership_and_permissions
|
80
63
|
set_owner if @new_resource.owner
|
81
64
|
set_group if @new_resource.group
|
82
65
|
set_mode if @new_resource.mode
|
83
|
-
|
84
66
|
end
|
85
67
|
|
86
68
|
def current_resource_matches_target_checksum?
|
@@ -94,6 +76,7 @@ class Chef
|
|
94
76
|
@new_resource.checksum(checksum(candidate_file.path))
|
95
77
|
Chef::Log.debug "#{@new_resource}: Target checksum: #{@current_resource.checksum}"
|
96
78
|
Chef::Log.debug "#{@new_resource}: Source checksum: #{@new_resource.checksum}"
|
79
|
+
|
97
80
|
@new_resource.checksum == @current_resource.checksum
|
98
81
|
else
|
99
82
|
Chef::Log.info "#{@new_resource}: Creating #{@new_resource.path}"
|
@@ -127,38 +110,6 @@ class Chef
|
|
127
110
|
false
|
128
111
|
end
|
129
112
|
|
130
|
-
def fetch_from_uri(source)
|
131
|
-
Chef::Log.debug("Downloading from absolute URI: #{source}")
|
132
|
-
Chef::REST.new(source, nil, nil).fetch(source) { |tmp_file| yield tmp_file }
|
133
|
-
end
|
134
|
-
|
135
|
-
def fetch_from_chef_server(source, current_checksum)
|
136
|
-
url = generate_url(source, "files", :checksum => current_checksum)
|
137
|
-
Chef::Log.debug("Downloading #{@new_resource} from server: #{url}")
|
138
|
-
Chef::REST.new(Chef::Config[:remotefile_url]).fetch(url) { |tmp_file| yield tmp_file }
|
139
|
-
end
|
140
|
-
|
141
|
-
def fetch_from_local_cookbook(source)
|
142
|
-
if Chef::Config[:solo]
|
143
|
-
cookbook_name = @new_resource.cookbook || @new_resource.cookbook_name
|
144
|
-
filename = find_preferred_file(
|
145
|
-
cookbook_name,
|
146
|
-
:remote_file,
|
147
|
-
source,
|
148
|
-
@node[:fqdn],
|
149
|
-
@node[:platform],
|
150
|
-
@node[:platform_version]
|
151
|
-
)
|
152
|
-
Chef::Log.debug("Using local file for remote_file:#{filename}")
|
153
|
-
begin
|
154
|
-
file = ::File.open(filename)
|
155
|
-
yield file
|
156
|
-
ensure
|
157
|
-
file.close
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
113
|
end
|
163
114
|
end
|
164
115
|
end
|
data/lib/chef/provider/script.rb
CHANGED
@@ -24,19 +24,30 @@ class Chef
|
|
24
24
|
class Script < Chef::Provider::Execute
|
25
25
|
|
26
26
|
def action_run
|
27
|
-
|
28
|
-
|
29
|
-
tf.close
|
27
|
+
script_file.puts(@new_resource.code)
|
28
|
+
script_file.close
|
30
29
|
|
31
|
-
|
32
|
-
fr.owner(@new_resource.user)
|
33
|
-
fr.group(@new_resource.group)
|
34
|
-
fr.run_action(:create)
|
30
|
+
set_owner_and_group
|
35
31
|
|
36
|
-
@new_resource.command("#{@new_resource.interpreter} #{
|
32
|
+
@new_resource.command("#{@new_resource.interpreter} #{script_file.path}")
|
37
33
|
super
|
38
34
|
ensure
|
39
|
-
|
35
|
+
unlink_script_file
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_owner_and_group
|
39
|
+
# FileUtils itself implements a no-op if +user+ or +group+ are nil
|
40
|
+
# You can prove this by running FileUtils.chown(nil,nil,'/tmp/file')
|
41
|
+
# as an unprivileged user.
|
42
|
+
FileUtils.chown(@new_resource.user, @new_resource.group, script_file.path)
|
43
|
+
end
|
44
|
+
|
45
|
+
def script_file
|
46
|
+
@script_file ||= Tempfile.open("chef-script")
|
47
|
+
end
|
48
|
+
|
49
|
+
def unlink_script_file
|
50
|
+
@script_file && @script_file.close!
|
40
51
|
end
|
41
52
|
|
42
53
|
end
|
@@ -25,29 +25,27 @@ class Chef
|
|
25
25
|
|
26
26
|
include Chef::Mixin::Command
|
27
27
|
|
28
|
-
def initialize(
|
29
|
-
super
|
28
|
+
def initialize(new_resource, run_context)
|
29
|
+
super
|
30
30
|
@enabled = nil
|
31
31
|
end
|
32
32
|
|
33
33
|
def action_enable
|
34
|
-
|
34
|
+
if @current_resource.enabled
|
35
|
+
Chef::Log.debug("#{@new_resource}: not enabling, already enabled")
|
36
|
+
else
|
35
37
|
Chef::Log.debug("#{@new_resource}: attempting to enable")
|
36
|
-
|
37
|
-
if status
|
38
|
+
if enable_service
|
38
39
|
@new_resource.updated = true
|
39
40
|
Chef::Log.info("#{@new_resource}: enabled successfully")
|
40
41
|
end
|
41
|
-
else
|
42
|
-
Chef::Log.debug("#{@new_resource}: not enabling, already enabled")
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
45
|
def action_disable
|
47
46
|
if @current_resource.enabled
|
48
47
|
Chef::Log.debug("#{@new_resource}: attempting to disable")
|
49
|
-
|
50
|
-
if status
|
48
|
+
if disable_service
|
51
49
|
@new_resource.updated = true
|
52
50
|
Chef::Log.info("#{@new_resource}: disabled successfully")
|
53
51
|
end
|
@@ -59,8 +57,7 @@ class Chef
|
|
59
57
|
def action_start
|
60
58
|
unless @current_resource.running
|
61
59
|
Chef::Log.debug("#{@new_resource}: attempting to start")
|
62
|
-
|
63
|
-
if status
|
60
|
+
if start_service
|
64
61
|
@new_resource.updated = true
|
65
62
|
Chef::Log.info("Started service #{@new_resource} successfully")
|
66
63
|
end
|
@@ -72,8 +69,7 @@ class Chef
|
|
72
69
|
def action_stop
|
73
70
|
if @current_resource.running
|
74
71
|
Chef::Log.debug("#{@new_resource}: attempting to stop")
|
75
|
-
|
76
|
-
if status
|
72
|
+
if stop_service
|
77
73
|
@new_resource.updated = true
|
78
74
|
Chef::Log.info("#{@new_resource}: stopped successfully")
|
79
75
|
end
|
@@ -84,49 +80,46 @@ class Chef
|
|
84
80
|
|
85
81
|
def action_restart
|
86
82
|
Chef::Log.debug("#{@new_resource}: attempting to restart")
|
87
|
-
|
88
|
-
if status
|
83
|
+
if restart_service
|
89
84
|
@new_resource.updated = true
|
90
85
|
Chef::Log.info("#{@new_resource}: restarted successfully")
|
91
86
|
end
|
92
87
|
end
|
93
88
|
|
94
89
|
def action_reload
|
95
|
-
unless @new_resource.supports[:reload]
|
90
|
+
unless (@new_resource.supports[:reload] || @new_resource.reload_command)
|
96
91
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :reload"
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
Chef::Log.info("#{@new_resource}: reloaded successfully")
|
104
|
-
end
|
92
|
+
end
|
93
|
+
if @current_resource.running
|
94
|
+
Chef::Log.debug("#{@new_resource}: attempting to reload")
|
95
|
+
if reload_service
|
96
|
+
@new_resource.updated = true
|
97
|
+
Chef::Log.info("#{@new_resource}: reloaded successfully")
|
105
98
|
end
|
106
99
|
end
|
107
100
|
end
|
108
101
|
|
109
|
-
def enable_service
|
102
|
+
def enable_service
|
110
103
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :enable"
|
111
104
|
end
|
112
105
|
|
113
|
-
def disable_service
|
106
|
+
def disable_service
|
114
107
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable"
|
115
108
|
end
|
116
109
|
|
117
|
-
def start_service
|
110
|
+
def start_service
|
118
111
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :start"
|
119
112
|
end
|
120
113
|
|
121
|
-
def stop_service
|
114
|
+
def stop_service
|
122
115
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :stop"
|
123
116
|
end
|
124
117
|
|
125
|
-
def restart_service
|
118
|
+
def restart_service
|
126
119
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :restart"
|
127
120
|
end
|
128
121
|
|
129
|
-
def reload_service
|
122
|
+
def reload_service
|
130
123
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :restart"
|
131
124
|
end
|
132
125
|
|