chef 0.8.16 → 0.9.0.a3
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.
- 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
|
@@ -53,13 +53,9 @@ class Chef
|
|
|
53
53
|
# <string>:: A string containing the option and then the quoted value
|
|
54
54
|
def set_options
|
|
55
55
|
opts = " #{@new_resource.group_name}"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Chef::Log.debug("#{@new_resource}: setting #{field.to_s} to #{@new_resource.send(field)}")
|
|
60
|
-
opts << " #{option} '#{@new_resource.send(field)}'"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
56
|
+
if @new_resource.gid && (@current_resource.gid != @new_resource.gid)
|
|
57
|
+
Chef::Log.debug("#{@new_resource}: current gid (#{@current_resource.gid}) doesnt match target gid (#{@new_resource.gid}), changing it")
|
|
58
|
+
opts << " -g '#{@new_resource.gid}'"
|
|
63
59
|
end
|
|
64
60
|
opts
|
|
65
61
|
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
|
3
|
+
# Copyright:: Copyright (c) 2010 VMware, 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/provider/user'
|
|
20
|
+
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
|
21
|
+
require 'chef/util/windows/net_group'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Chef
|
|
25
|
+
class Provider
|
|
26
|
+
class Group
|
|
27
|
+
class Windows < Chef::Provider::Group
|
|
28
|
+
|
|
29
|
+
def initialize(new_resource,run_context)
|
|
30
|
+
super
|
|
31
|
+
@net_group = Chef::Util::Windows::NetGroup.new(@new_resource.name)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def load_current_resource
|
|
35
|
+
@current_resource = Chef::Resource::Group.new(@new_resource.name)
|
|
36
|
+
@current_resource.group_name(@new_resource.group_name)
|
|
37
|
+
|
|
38
|
+
members = nil
|
|
39
|
+
begin
|
|
40
|
+
members = @net_group.local_get_members
|
|
41
|
+
rescue => e
|
|
42
|
+
@group_exists = false
|
|
43
|
+
Chef::Log.debug("#{@new_resource}: group does not exist")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if members
|
|
47
|
+
@current_resource.members(members)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
@current_resource
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def create_group
|
|
54
|
+
@net_group.local_add
|
|
55
|
+
manage_group
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def manage_group
|
|
59
|
+
if @new_resource.append
|
|
60
|
+
begin
|
|
61
|
+
#ERROR_MEMBER_IN_ALIAS if a member already exists in the group
|
|
62
|
+
@net_group.local_add_members(@new_resource.members)
|
|
63
|
+
rescue
|
|
64
|
+
members = @new_resource.members + @current_resource.members
|
|
65
|
+
@net_group.local_set_members(members.uniq)
|
|
66
|
+
end
|
|
67
|
+
else
|
|
68
|
+
@net_group.local_set_members(@new_resource.members)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def remove_group
|
|
73
|
+
@net_group.local_delete
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
data/lib/chef/provider/link.rb
CHANGED
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
require 'chef/config'
|
|
20
20
|
require 'chef/log'
|
|
21
|
-
require 'chef/mixin/
|
|
21
|
+
require 'chef/mixin/shell_out'
|
|
22
22
|
require 'chef/resource/link'
|
|
23
23
|
require 'chef/provider'
|
|
24
24
|
|
|
25
25
|
class Chef
|
|
26
26
|
class Provider
|
|
27
27
|
class Link < Chef::Provider
|
|
28
|
-
include Chef::Mixin::
|
|
28
|
+
include Chef::Mixin::ShellOut
|
|
29
|
+
#include Chef::Mixin::Command
|
|
29
30
|
|
|
30
31
|
def negative_complement(big)
|
|
31
32
|
if big > 1073741823 # Fixnum max
|
|
@@ -117,9 +118,7 @@ class Chef
|
|
|
117
118
|
if @current_resource.to != ::File.expand_path(@new_resource.to, @new_resource.target_file)
|
|
118
119
|
Chef::Log.info("Creating a #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file} for #{@new_resource}")
|
|
119
120
|
if @new_resource.link_type == :symbolic
|
|
120
|
-
|
|
121
|
-
:command => "ln -nfs #{@new_resource.to} #{@new_resource.target_file}"
|
|
122
|
-
)
|
|
121
|
+
shell_out! "ln -nfs #{@new_resource.to} #{@new_resource.target_file}"
|
|
123
122
|
elsif @new_resource.link_type == :hard
|
|
124
123
|
::File.link(@new_resource.to, @new_resource.target_file)
|
|
125
124
|
end
|
data/lib/chef/provider/mdadm.rb
CHANGED
|
@@ -17,53 +17,60 @@
|
|
|
17
17
|
#
|
|
18
18
|
|
|
19
19
|
require 'chef/log'
|
|
20
|
-
require 'chef/mixin/
|
|
20
|
+
require 'chef/mixin/shell_out'
|
|
21
21
|
require 'chef/provider'
|
|
22
22
|
|
|
23
23
|
class Chef
|
|
24
24
|
class Provider
|
|
25
25
|
class Mdadm < Chef::Provider
|
|
26
26
|
|
|
27
|
-
include Chef::Mixin::Command
|
|
27
|
+
#include Chef::Mixin::Command
|
|
28
|
+
include Chef::Mixin::ShellOut
|
|
29
|
+
|
|
30
|
+
def popen4
|
|
31
|
+
raise Exception, "deprecated, bitches"
|
|
32
|
+
end
|
|
28
33
|
|
|
29
34
|
def load_current_resource
|
|
30
35
|
@current_resource = Chef::Resource::Mdadm.new(@new_resource.name)
|
|
31
36
|
@current_resource.raid_device(@new_resource.raid_device)
|
|
32
37
|
Chef::Log.debug("Checking for software raid device #{@current_resource.raid_device}")
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
exists =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
39
|
+
mdadm = shell_out!("mdadm --detail --scan")
|
|
40
|
+
exists = mdadm.stdout.include?(@new_resource.raid_device)
|
|
41
|
+
#exists = false
|
|
42
|
+
# popen4(command) do |pid, stdin, stdout, stderr|
|
|
43
|
+
# stdout.each do |line|
|
|
44
|
+
# if line.include? @new_resource.raid_device
|
|
45
|
+
# exists = true
|
|
46
|
+
# end
|
|
47
|
+
# end
|
|
48
|
+
# end
|
|
43
49
|
@current_resource.exists(exists)
|
|
44
50
|
end
|
|
45
51
|
|
|
46
52
|
def action_create
|
|
47
53
|
unless @current_resource.exists
|
|
48
|
-
command = "yes | mdadm --create #{@new_resource.raid_device} --chunk=#{@new_resource.chunk} --level #{@new_resource.level} --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.
|
|
54
|
+
command = "yes | mdadm --create #{@new_resource.raid_device} --chunk=#{@new_resource.chunk} --level #{@new_resource.level} --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.join(" ")}"
|
|
49
55
|
Chef::Log.debug("mdadm command: #{command}")
|
|
50
|
-
pid, stdin, stdout, stderr = popen4(command)
|
|
56
|
+
#pid, stdin, stdout, stderr = popen4(command)
|
|
57
|
+
shell_out!(command)
|
|
51
58
|
Chef::Log.info("Created mdadm raid device (#{@new_resource.raid_device})")
|
|
52
59
|
@new_resource.updated = true
|
|
53
60
|
else
|
|
54
|
-
Chef::Log.debug("mdadm raid device already exists (#{@new_resource.raid_device})")
|
|
61
|
+
Chef::Log.debug("mdadm raid device already exists, skipping create (#{@new_resource.raid_device})")
|
|
55
62
|
end
|
|
56
63
|
end
|
|
57
64
|
|
|
58
65
|
def action_assemble
|
|
59
66
|
unless @current_resource.exists
|
|
60
|
-
command = "yes | mdadm --assemble #{@new_resource.raid_device} #{@new_resource.devices.
|
|
67
|
+
command = "yes | mdadm --assemble #{@new_resource.raid_device} #{@new_resource.devices.join(" ")}"
|
|
61
68
|
Chef::Log.debug("mdadm command: #{command}")
|
|
62
|
-
|
|
69
|
+
shell_out!(command)
|
|
63
70
|
Chef::Log.info("Assembled mdadm raid device (#{@new_resource.raid_device})")
|
|
64
71
|
@new_resource.updated = true
|
|
65
72
|
else
|
|
66
|
-
Chef::Log.debug("mdadm raid device already exists (#{@new_resource.raid_device})")
|
|
73
|
+
Chef::Log.debug("mdadm raid device already exists, skipping assemble (#{@new_resource.raid_device})")
|
|
67
74
|
end
|
|
68
75
|
end
|
|
69
76
|
|
|
@@ -71,7 +78,7 @@ class Chef
|
|
|
71
78
|
if @current_resource.exists
|
|
72
79
|
command = "yes | mdadm --stop #{@new_resource.raid_device}"
|
|
73
80
|
Chef::Log.debug("mdadm command: #{command}")
|
|
74
|
-
|
|
81
|
+
shell_out!(command)
|
|
75
82
|
Chef::Log.info("Stopped mdadm raid device (#{@new_resource.raid_device})")
|
|
76
83
|
@new_resource.updated = true
|
|
77
84
|
else
|
|
@@ -18,17 +18,16 @@
|
|
|
18
18
|
|
|
19
19
|
require 'chef/provider/mount'
|
|
20
20
|
require 'chef/log'
|
|
21
|
-
require 'chef/mixin/
|
|
21
|
+
require 'chef/mixin/shell_out'
|
|
22
22
|
|
|
23
23
|
class Chef
|
|
24
24
|
class Provider
|
|
25
25
|
class Mount
|
|
26
26
|
class Mount < Chef::Provider::Mount
|
|
27
|
+
include Chef::Mixin::ShellOut
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil)
|
|
31
|
-
super(node, new_resource, collection, definitions, cookbook_loader)
|
|
29
|
+
def initialize(new_resource, run_context)
|
|
30
|
+
super
|
|
32
31
|
@real_device = nil
|
|
33
32
|
end
|
|
34
33
|
attr_accessor :real_device
|
|
@@ -48,16 +47,14 @@ class Chef
|
|
|
48
47
|
|
|
49
48
|
# Check to see if the volume is mounted. Last volume entry wins.
|
|
50
49
|
mounted = false
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Chef::Log.debug("Special device #{$~[1]} mounted as #{@new_resource.mount_point}")
|
|
60
|
-
end
|
|
50
|
+
shell_out!("mount").stdout.each_line do |line|
|
|
51
|
+
case line
|
|
52
|
+
when /^#{device_mount_regex}\s+on\s+#{@new_resource.mount_point}/
|
|
53
|
+
mounted = true
|
|
54
|
+
Chef::Log.debug("Special device #{device_logstring} mounted as #{@new_resource.mount_point}")
|
|
55
|
+
when /^([\/\w])+\son\s#{@new_resource.mount_point}\s+/
|
|
56
|
+
mounted = false
|
|
57
|
+
Chef::Log.debug("Special device #{$~[1]} mounted as #{@new_resource.mount_point}")
|
|
61
58
|
end
|
|
62
59
|
end
|
|
63
60
|
@current_resource.mounted(mounted)
|
|
@@ -89,7 +86,7 @@ class Chef
|
|
|
89
86
|
command << " -o #{@new_resource.options.join(',')}" unless @new_resource.options.nil? || @new_resource.options.empty?
|
|
90
87
|
command << " #{device_real}"
|
|
91
88
|
command << " #{@new_resource.mount_point}"
|
|
92
|
-
|
|
89
|
+
shell_out!(command)
|
|
93
90
|
Chef::Log.info("Mounted #{@new_resource.mount_point}")
|
|
94
91
|
else
|
|
95
92
|
Chef::Log.debug("#{@new_resource.mount_point} is already mounted.")
|
|
@@ -98,8 +95,7 @@ class Chef
|
|
|
98
95
|
|
|
99
96
|
def umount_fs
|
|
100
97
|
if @current_resource.mounted
|
|
101
|
-
|
|
102
|
-
run_command(:command => command)
|
|
98
|
+
shell_out!("umount #{@new_resource.mount_point}")
|
|
103
99
|
Chef::Log.info("Unmounted #{@new_resource.mount_point}")
|
|
104
100
|
else
|
|
105
101
|
Chef::Log.debug("#{@new_resource.mount_point} is not mounted.")
|
|
@@ -108,8 +104,7 @@ class Chef
|
|
|
108
104
|
|
|
109
105
|
def remount_fs
|
|
110
106
|
if @current_resource.mounted and @new_resource.supports[:remount]
|
|
111
|
-
|
|
112
|
-
run_command(:command => command)
|
|
107
|
+
shell_out!("mount -o remount #{@new_resource.mount_point}")
|
|
113
108
|
|
|
114
109
|
@new_resource.updated = true
|
|
115
110
|
Chef::Log.info("Remounted #{@new_resource.mount_point}")
|
|
@@ -123,14 +118,12 @@ class Chef
|
|
|
123
118
|
end
|
|
124
119
|
|
|
125
120
|
def enable_fs
|
|
121
|
+
if @current_resource.enabled && mount_options_unchanged?
|
|
122
|
+
Chef::Log.debug("#{@new_resource.mount_point} is already enabled.")
|
|
123
|
+
return nil
|
|
124
|
+
end
|
|
125
|
+
|
|
126
126
|
if @current_resource.enabled
|
|
127
|
-
if @current_resource.fstype == @new_resource.fstype and
|
|
128
|
-
@current_resource.options == @new_resource.options and
|
|
129
|
-
@current_resource.dump == @new_resource.dump and
|
|
130
|
-
@current_resource.pass == @new_resource.pass
|
|
131
|
-
Chef::Log.debug("#{@new_resource.mount_point} is already enabled.")
|
|
132
|
-
return
|
|
133
|
-
end
|
|
134
127
|
# The current options don't match what we have, so
|
|
135
128
|
# disable, then enable.
|
|
136
129
|
disable_fs
|
|
@@ -214,6 +207,14 @@ class Chef
|
|
|
214
207
|
device_fstab
|
|
215
208
|
end
|
|
216
209
|
end
|
|
210
|
+
|
|
211
|
+
def mount_options_unchanged?
|
|
212
|
+
@current_resource.fstype == @new_resource.fstype and
|
|
213
|
+
@current_resource.options == @new_resource.options and
|
|
214
|
+
@current_resource.dump == @new_resource.dump and
|
|
215
|
+
@current_resource.pass == @new_resource.pass
|
|
216
|
+
end
|
|
217
|
+
|
|
217
218
|
end
|
|
218
219
|
end
|
|
219
220
|
end
|
|
@@ -30,8 +30,8 @@ class Chef
|
|
|
30
30
|
|
|
31
31
|
attr_accessor :candidate_version
|
|
32
32
|
|
|
33
|
-
def initialize(
|
|
34
|
-
super
|
|
33
|
+
def initialize(new_resource, run_context)
|
|
34
|
+
super
|
|
35
35
|
@candidate_version = nil
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -75,29 +75,28 @@ class Chef
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def action_remove
|
|
78
|
-
if
|
|
78
|
+
if removing_package?
|
|
79
79
|
Chef::Log.info("Removing #{@new_resource}")
|
|
80
80
|
remove_package(@current_resource.package_name, @new_resource.version)
|
|
81
81
|
@new_resource.updated = true
|
|
82
|
+
else
|
|
82
83
|
end
|
|
83
84
|
end
|
|
84
85
|
|
|
85
|
-
def
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
end
|
|
86
|
+
def removing_package?
|
|
87
|
+
if @current_resource.version.nil?
|
|
88
|
+
false # nothing to remove
|
|
89
|
+
elsif @new_resource.version.nil?
|
|
90
|
+
true # remove any version of a package
|
|
91
|
+
elsif @new_resource.version == @current_resource.version
|
|
92
|
+
true # remove the version we have
|
|
93
|
+
else
|
|
94
|
+
false # we don't have the version we want to remove
|
|
95
95
|
end
|
|
96
|
-
to_remove_package
|
|
97
96
|
end
|
|
98
97
|
|
|
99
98
|
def action_purge
|
|
100
|
-
if
|
|
99
|
+
if removing_package?
|
|
101
100
|
Chef::Log.info("Purging #{@new_resource}")
|
|
102
101
|
purge_package(@current_resource.package_name, @new_resource.version)
|
|
103
102
|
@new_resource.updated = true
|
|
@@ -124,31 +123,32 @@ class Chef
|
|
|
124
123
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support pre-seeding package install/upgrade instructions - don't ask it to!"
|
|
125
124
|
end
|
|
126
125
|
|
|
127
|
-
def get_preseed_file(name, version)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
Chef::Log.debug("Fetching preseed file to #{cache_path}")
|
|
126
|
+
def get_preseed_file(name, version)
|
|
127
|
+
resource = preseed_resource(name, version)
|
|
128
|
+
Chef::Log.debug("Fetching preseed file to #{resource.path}")
|
|
129
|
+
resource.run_action('create')
|
|
133
130
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
if resource.updated?
|
|
132
|
+
resource.path
|
|
133
|
+
else
|
|
134
|
+
false
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def preseed_resource(name, version)
|
|
139
|
+
# A directory in our cache to store this cookbook's preseed files in
|
|
140
|
+
file_cache_dir = Chef::FileCache.create_cache_path("preseed/#{@new_resource.cookbook_name}")
|
|
141
|
+
# The full path where the preseed file will be stored
|
|
142
|
+
cache_seed_to = "#{file_cache_dir}/#{name}-#{version}.seed"
|
|
143
|
+
|
|
144
|
+
Chef::Log.debug("Fetching preseed file to #{cache_seed_to}")
|
|
145
|
+
|
|
146
|
+
remote_file = Chef::Resource::CookbookFile.new(cache_seed_to)
|
|
139
147
|
remote_file.cookbook_name = @new_resource.cookbook_name
|
|
140
148
|
remote_file.source(@new_resource.response_file)
|
|
141
149
|
remote_file.backup(false)
|
|
142
150
|
|
|
143
|
-
|
|
144
|
-
rf_provider.load_current_resource
|
|
145
|
-
rf_provider.action_create
|
|
146
|
-
|
|
147
|
-
if remote_file.updated
|
|
148
|
-
Chef::FileCache.load(cache_path, false)
|
|
149
|
-
else
|
|
150
|
-
false
|
|
151
|
-
end
|
|
151
|
+
remote_file
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
def expand_options(options)
|
|
@@ -24,12 +24,20 @@ class Chef
|
|
|
24
24
|
class Provider
|
|
25
25
|
class Package
|
|
26
26
|
class Dpkg < Chef::Provider::Package::Apt
|
|
27
|
+
DPKG_INFO = /([a-z\d\-\+]+)\t([\w\d.-]+)/
|
|
28
|
+
DPKG_INSTALLED = /^Status: install ok installed/
|
|
29
|
+
DPKG_VERSION = /^Version: (.+)$/
|
|
27
30
|
|
|
28
31
|
def load_current_resource
|
|
29
32
|
@current_resource = Chef::Resource::Package.new(@new_resource.name)
|
|
30
33
|
@current_resource.package_name(@new_resource.package_name)
|
|
31
34
|
@new_resource.version(nil)
|
|
32
35
|
|
|
36
|
+
# if the source was not set, and we're installing, fail
|
|
37
|
+
if Array(@new_resource.action).include?(:install) && @new_resource.source.nil?
|
|
38
|
+
raise Chef::Exceptions::Package, "Source for package #{@new_resource.name} required for action install"
|
|
39
|
+
end
|
|
40
|
+
|
|
33
41
|
# We only -need- source for action install
|
|
34
42
|
if @new_resource.source
|
|
35
43
|
unless ::File.exists?(@new_resource.source)
|
|
@@ -39,29 +47,24 @@ class Chef
|
|
|
39
47
|
# Get information from the package if supplied
|
|
40
48
|
Chef::Log.debug("Checking dpkg status for #{@new_resource.package_name}")
|
|
41
49
|
status = popen4("dpkg-deb -W #{@new_resource.source}") do |pid, stdin, stdout, stderr|
|
|
42
|
-
stdout.
|
|
43
|
-
if pkginfo =
|
|
50
|
+
stdout.each_line do |line|
|
|
51
|
+
if pkginfo = DPKG_INFO.match(line)
|
|
44
52
|
@current_resource.package_name(pkginfo[1])
|
|
45
53
|
@new_resource.version(pkginfo[2])
|
|
46
54
|
end
|
|
47
55
|
end
|
|
48
56
|
end
|
|
49
|
-
else
|
|
50
|
-
# if the source was not set, and we're installing, fail
|
|
51
|
-
if @new_resource.action.include?(:install)
|
|
52
|
-
raise Chef::Exceptions::Package, "Source for package #{@new_resource.name} required for action install"
|
|
53
|
-
end
|
|
54
57
|
end
|
|
55
58
|
|
|
56
59
|
# Check to see if it is installed
|
|
57
60
|
package_installed = nil
|
|
58
61
|
Chef::Log.debug("Checking install state for #{@current_resource.package_name}")
|
|
59
62
|
status = popen4("dpkg -s #{@current_resource.package_name}") do |pid, stdin, stdout, stderr|
|
|
60
|
-
stdout.
|
|
63
|
+
stdout.each_line do |line|
|
|
61
64
|
case line
|
|
62
|
-
when
|
|
65
|
+
when DPKG_INSTALLED
|
|
63
66
|
package_installed = true
|
|
64
|
-
when
|
|
67
|
+
when DPKG_VERSION
|
|
65
68
|
if package_installed
|
|
66
69
|
Chef::Log.debug("Current version is #{$1}")
|
|
67
70
|
@current_resource.version($1)
|