chef 0.7.10 → 0.7.12

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.

Files changed (70) hide show
  1. data/distro/debian/etc/init.d/chef-client +175 -0
  2. data/distro/debian/etc/init.d/chef-indexer +175 -0
  3. data/distro/debian/etc/init.d/chef-server +120 -0
  4. data/distro/debian/man/man1/chef-indexer.1 +42 -0
  5. data/distro/debian/man/man1/chef-server.1 +108 -0
  6. data/distro/debian/man/man8/chef-client.8 +61 -0
  7. data/distro/debian/man/man8/chef-solo.8 +58 -0
  8. data/distro/redhat/etc/chef/client.rb +16 -0
  9. data/distro/redhat/etc/chef/indexer.rb +10 -0
  10. data/distro/redhat/etc/chef/server.rb +22 -0
  11. data/distro/redhat/etc/init.d/chef-client +74 -0
  12. data/distro/redhat/etc/init.d/chef-indexer +76 -0
  13. data/distro/redhat/etc/init.d/chef-server +77 -0
  14. data/lib/chef.rb +1 -1
  15. data/lib/chef/client.rb +33 -8
  16. data/lib/chef/compile.rb +34 -2
  17. data/lib/chef/cookbook.rb +29 -2
  18. data/lib/chef/cookbook_loader.rb +61 -49
  19. data/lib/chef/couchdb.rb +7 -3
  20. data/lib/chef/mixin/command.rb +67 -32
  21. data/lib/chef/mixin/convert_to_class_name.rb +48 -0
  22. data/lib/chef/mixin/find_preferred_file.rb +5 -14
  23. data/lib/chef/mixin/from_file.rb +14 -0
  24. data/lib/chef/mixin/generate_url.rb +2 -1
  25. data/lib/chef/mixin/recipe_definition_dsl_core.rb +77 -0
  26. data/lib/chef/platform.rb +1 -1
  27. data/lib/chef/provider.rb +63 -2
  28. data/lib/chef/provider/cron.rb +75 -25
  29. data/lib/chef/provider/deploy.rb +281 -0
  30. data/lib/chef/provider/deploy/revision.rb +70 -0
  31. data/lib/chef/provider/deploy/timestamped.rb +33 -0
  32. data/lib/chef/provider/git.rb +194 -0
  33. data/lib/chef/provider/group.rb +2 -2
  34. data/lib/chef/provider/group/gpasswd.rb +50 -0
  35. data/lib/chef/provider/group/groupadd.rb +2 -16
  36. data/lib/chef/provider/group/usermod.rb +57 -0
  37. data/lib/chef/provider/ifconfig.rb +3 -3
  38. data/lib/chef/provider/mount.rb +0 -4
  39. data/lib/chef/provider/mount/mount.rb +2 -2
  40. data/lib/chef/provider/package.rb +2 -2
  41. data/lib/chef/provider/package/apt.rb +4 -4
  42. data/lib/chef/provider/package/dpkg.rb +9 -13
  43. data/lib/chef/provider/package/freebsd.rb +6 -6
  44. data/lib/chef/provider/package/macports.rb +4 -4
  45. data/lib/chef/provider/package/portage.rb +3 -3
  46. data/lib/chef/provider/package/rpm.rb +4 -4
  47. data/lib/chef/provider/package/rubygems.rb +10 -4
  48. data/lib/chef/provider/package/yum.rb +6 -6
  49. data/lib/chef/provider/remote_file.rb +14 -7
  50. data/lib/chef/provider/service.rb +8 -2
  51. data/lib/chef/provider/service/freebsd.rb +1 -1
  52. data/lib/chef/provider/service/init.rb +8 -63
  53. data/lib/chef/provider/service/redhat.rb +2 -2
  54. data/lib/chef/provider/service/simple.rb +115 -0
  55. data/lib/chef/provider/subversion.rb +145 -0
  56. data/lib/chef/provider/template.rb +2 -0
  57. data/lib/chef/provider/user.rb +2 -2
  58. data/lib/chef/recipe.rb +9 -75
  59. data/lib/chef/resource.rb +131 -7
  60. data/lib/chef/resource/cron.rb +36 -0
  61. data/lib/chef/resource/deploy.rb +360 -0
  62. data/lib/chef/resource/deploy_revision.rb +35 -0
  63. data/lib/chef/resource/git.rb +36 -0
  64. data/lib/chef/resource/group.rb +2 -0
  65. data/lib/chef/resource/scm.rb +129 -0
  66. data/lib/chef/resource/subversion.rb +33 -0
  67. data/lib/chef/resource/timestamped_deploy.rb +31 -0
  68. data/lib/chef/resource_collection.rb +32 -4
  69. data/lib/chef/runner.rb +35 -28
  70. metadata +40 -11
@@ -106,7 +106,7 @@ class Chef
106
106
  def generate_config
107
107
  b = binding
108
108
  case node[:platform]
109
- when ("centos" || "redhat" || "fedora")
109
+ when "centos","redhat","fedora"
110
110
  content = %{
111
111
  <% if @new_resource.device %>DEVICE=<%= @new_resource.device %><% end %>
112
112
  <% if @new_resource.onboot %>ONBOOT=<%= @new_resource.onboot %><% end %>
@@ -120,9 +120,9 @@ class Chef
120
120
  network_file = ::File.new("/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}", "w")
121
121
  network_file.puts(template.result(b))
122
122
  network_file.close
123
- when ("debian" || "ubantu")
123
+ when "debian","ubuntu"
124
124
  # template
125
- when ("slackware")
125
+ when "slackware"
126
126
  # template
127
127
  end
128
128
  end
@@ -26,10 +26,6 @@ class Chef
26
26
 
27
27
  include Chef::Mixin::Command
28
28
 
29
- def initialize(node, new_resource)
30
- super(node, new_resource)
31
- end
32
-
33
29
  def action_mount
34
30
  unless @current_resource.mounted
35
31
  Chef::Log.debug("#{@new_resource}: attempting to mount")
@@ -27,8 +27,8 @@ class Chef
27
27
 
28
28
  include Chef::Mixin::Command
29
29
 
30
- def initialize(node, new_resource)
31
- super(node, new_resource)
30
+ def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil)
31
+ super(node, new_resource, collection, definitions, cookbook_loader)
32
32
  @real_device = nil
33
33
  end
34
34
  attr_accessor :real_device
@@ -30,8 +30,8 @@ class Chef
30
30
 
31
31
  attr_accessor :candidate_version
32
32
 
33
- def initialize(node, new_resource)
34
- super(node, new_resource)
33
+ def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil)
34
+ super(node, new_resource, collection, definitions, cookbook_loader)
35
35
  @candidate_version = nil
36
36
  end
37
37
 
@@ -61,7 +61,7 @@ class Chef
61
61
  end
62
62
 
63
63
  def install_package(name, version)
64
- run_command(
64
+ run_command_with_systems_locale(
65
65
  :command => "apt-get -q -y#{expand_options(@new_resource.options)} install #{name}=#{version}",
66
66
  :environment => {
67
67
  "DEBIAN_FRONTEND" => "noninteractive"
@@ -74,7 +74,7 @@ class Chef
74
74
  end
75
75
 
76
76
  def remove_package(name, version)
77
- run_command(
77
+ run_command_with_systems_locale(
78
78
  :command => "apt-get -q -y#{expand_options(@new_resource.options)} remove #{@new_resource.package_name}",
79
79
  :environment => {
80
80
  "DEBIAN_FRONTEND" => "noninteractive"
@@ -83,7 +83,7 @@ class Chef
83
83
  end
84
84
 
85
85
  def purge_package(name, version)
86
- run_command(
86
+ run_command_with_systems_locale(
87
87
  :command => "apt-get -q -y#{expand_options(@new_resource.options)} purge #{@new_resource.package_name}",
88
88
  :environment => {
89
89
  "DEBIAN_FRONTEND" => "noninteractive"
@@ -95,7 +95,7 @@ class Chef
95
95
  preseed_file = get_preseed_file(name, version)
96
96
  if preseed_file
97
97
  Chef::Log.info("Pre-seeding #{@new_resource} with package installation instructions.")
98
- run_command(
98
+ run_command_with_systems_locale(
99
99
  :command => "debconf-set-selections #{preseed_file}",
100
100
  :environment => {
101
101
  "DEBIAN_FRONTEND" => "noninteractive"
@@ -40,10 +40,9 @@ class Chef
40
40
  Chef::Log.debug("Checking dpkg status for #{@new_resource.package_name}")
41
41
  status = popen4("dpkg-deb -W #{@new_resource.source}") do |pid, stdin, stdout, stderr|
42
42
  stdout.each do |line|
43
- case line
44
- when /([\w\d]+)\t([\w\d.-]+)/
45
- @current_resource.package_name($1)
46
- @new_resource.version($2)
43
+ if pkginfo = /([a-z\d\-\+]+)\t([\w\d.-]+)/.match(line)
44
+ @current_resource.package_name(pkginfo[1])
45
+ @new_resource.version(pkginfo[2])
47
46
  end
48
47
  end
49
48
  end
@@ -79,31 +78,28 @@ class Chef
79
78
  end
80
79
 
81
80
  def install_package(name, version)
82
- run_command(
81
+ run_command_with_systems_locale(
83
82
  :command => "dpkg -i#{expand_options(@new_resource.options)} #{@new_resource.source}",
84
83
  :environment => {
85
- "DEBIAN_FRONTEND" => "noninteractive",
86
- "LANG" => "en_US"
84
+ "DEBIAN_FRONTEND" => "noninteractive"
87
85
  }
88
86
  )
89
87
  end
90
88
 
91
89
  def remove_package(name, version)
92
- run_command(
90
+ run_command_with_systems_locale(
93
91
  :command => "dpkg -r#{expand_options(@new_resource.options)} #{@new_resource.package_name}",
94
92
  :environment => {
95
- "DEBIAN_FRONTEND" => "noninteractive",
96
- "LANG" => "en_US"
93
+ "DEBIAN_FRONTEND" => "noninteractive"
97
94
  }
98
95
  )
99
96
  end
100
97
 
101
98
  def purge_package(name, version)
102
- run_command(
99
+ run_command_with_systems_locale(
103
100
  :command => "dpkg -P#{expand_options(@new_resource.options)} #{@new_resource.package_name}",
104
101
  :environment => {
105
- "DEBIAN_FRONTEND" => "noninteractive",
106
- "LANG" => "en_US"
102
+ "DEBIAN_FRONTEND" => "noninteractive"
107
103
  }
108
104
  )
109
105
  end
@@ -110,24 +110,24 @@ class Chef
110
110
  unless @current_resource.version
111
111
  case @new_resource.source
112
112
  when /^ports$/
113
- run_command(
113
+ run_command_with_systems_locale(
114
114
  :command => "make -DBATCH install",
115
115
  :cwd => "#{port_path}"
116
116
  )
117
117
  when /^http/, /^ftp/
118
- run_command(
118
+ run_command_with_systems_locale(
119
119
  :command => "pkg_add -r #{package_name}",
120
120
  :environment => { "PACKAGESITE" => @new_resource.source }
121
121
  )
122
122
  Chef::Log.info("Installed package #{package_name} from: #{@new_resource.source}")
123
123
  when /^\//
124
- run_command(
124
+ run_command_with_systems_locale(
125
125
  :command => "pkg_add #{@new_resource.name}",
126
126
  :environment => { "PKG_PATH" => @new_resource.source }
127
127
  )
128
128
  Chef::Log.info("Installed package #{@new_resource.name} from: #{@new_resource.source}")
129
129
  else
130
- run_command(
130
+ run_command_with_systems_locale(
131
131
  :command => "pkg_add -r #{latest_link_name}"
132
132
  )
133
133
  Chef::Log.info("Installed package #{package_name}")
@@ -138,11 +138,11 @@ class Chef
138
138
  def remove_package(name, version)
139
139
  # a version is mandatory
140
140
  if version
141
- run_command(
141
+ run_command_with_systems_locale(
142
142
  :command => "pkg_delete #{package_name}-#{version}"
143
143
  )
144
144
  else
145
- run_command(
145
+ run_command_with_systems_locale(
146
146
  :command => "pkg_delete #{package_name}-#{@current_resource.version}"
147
147
  )
148
148
  end
@@ -45,7 +45,7 @@ class Chef
45
45
  unless @current_resource.version == version
46
46
  command = "port install #{name}"
47
47
  command << " @#{version}" if version and !version.empty?
48
- run_command(
48
+ run_command_with_systems_locale(
49
49
  :command => command
50
50
  )
51
51
  end
@@ -54,7 +54,7 @@ class Chef
54
54
  def purge_package(name, version)
55
55
  command = "port uninstall #{name}"
56
56
  command << " @#{version}" if version and !version.empty?
57
- run_command(
57
+ run_command_with_systems_locale(
58
58
  :command => command
59
59
  )
60
60
  end
@@ -63,7 +63,7 @@ class Chef
63
63
  command = "port deactivate #{name}"
64
64
  command << " @#{version}" if version and !version.empty?
65
65
 
66
- run_command(
66
+ run_command_with_systems_locale(
67
67
  :command => command
68
68
  )
69
69
  end
@@ -78,7 +78,7 @@ class Chef
78
78
  # that hasn't been installed.
79
79
  install_package(name, version)
80
80
  elsif current_version != version
81
- run_command(
81
+ run_command_with_systems_locale(
82
82
  :command => "port upgrade #{name} @#{version}"
83
83
  )
84
84
  end
@@ -38,7 +38,7 @@ class Chef
38
38
 
39
39
  if( ::File.exists?(catdir) )
40
40
  Dir.entries(catdir).each do |entry|
41
- if(entry =~ /^#{Regexp.escape(pkg)}\-(.+)/)
41
+ if(entry =~ /^#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?)/)
42
42
  @current_resource.version($1)
43
43
  Chef::Log.debug("Got current version #{$1}")
44
44
  break
@@ -93,7 +93,7 @@ class Chef
93
93
  pkg = "~#{name}-#{$1}"
94
94
  end
95
95
 
96
- run_command(
96
+ run_command_with_systems_locale(
97
97
  :command => "emerge -g --color n --nospinner --quiet#{expand_options(@new_resource.options)} #{pkg}"
98
98
  )
99
99
  end
@@ -109,7 +109,7 @@ class Chef
109
109
  pkg = "#{@new_resource.package_name}"
110
110
  end
111
111
 
112
- run_command(
112
+ run_command_with_systems_locale(
113
113
  :command => "emerge --unmerge --color n --nospinner --quiet#{expand_options(@new_resource.options)} #{pkg}"
114
114
  )
115
115
  end
@@ -69,24 +69,24 @@ class Chef
69
69
  end
70
70
 
71
71
  def install_package(name, version)
72
- run_command(
72
+ run_command_with_systems_locale(
73
73
  :command => "rpm -i #{@new_resource.source}"
74
74
  )
75
75
  end
76
76
 
77
77
  def upgrade_package(name, version)
78
- run_command(
78
+ run_command_with_systems_locale(
79
79
  :command => "rpm -U #{@new_resource.source}"
80
80
  )
81
81
  end
82
82
 
83
83
  def remove_package(name, version)
84
84
  if version
85
- run_command(
85
+ run_command_with_systems_locale(
86
86
  :command => "rpm -e #{name}-#{version}"
87
87
  )
88
88
  else
89
- run_command(
89
+ run_command_with_systems_locale(
90
90
  :command => "rpm -e #{name}"
91
91
  )
92
92
  end
@@ -99,8 +99,8 @@ class Chef
99
99
  if @new_resource.source
100
100
  src = " --source=#{@new_resource.source} --source=http://gems.rubyforge.org"
101
101
  end
102
- run_command(
103
- :command => "#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}"
102
+ run_command_with_systems_locale(
103
+ :command => "#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}"
104
104
  )
105
105
  end
106
106
 
@@ -110,11 +110,11 @@ class Chef
110
110
 
111
111
  def remove_package(name, version)
112
112
  if version
113
- run_command(
113
+ run_command_with_systems_locale(
114
114
  :command => "#{gem_binary_path} uninstall #{name} -q -v \"#{version}\""
115
115
  )
116
116
  else
117
- run_command(
117
+ run_command_with_systems_locale(
118
118
  :command => "#{gem_binary_path} uninstall #{name} -q -a"
119
119
  )
120
120
  end
@@ -123,6 +123,12 @@ class Chef
123
123
  def purge_package(name, version)
124
124
  remove_package(name, version)
125
125
  end
126
+
127
+ private
128
+
129
+ def opts
130
+ expand_options(@new_resource.options)
131
+ end
126
132
 
127
133
  end
128
134
  end
@@ -106,9 +106,9 @@ class Chef
106
106
  end
107
107
  end
108
108
 
109
- def initialize(node, new_resource)
109
+ def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil)
110
110
  @yum = YumCache.instance
111
- super(node, new_resource)
111
+ super(node, new_resource, collection, definitions, cookbook_loader)
112
112
  end
113
113
 
114
114
  def load_current_resource
@@ -133,7 +133,7 @@ class Chef
133
133
  end
134
134
 
135
135
  def install_package(name, version)
136
- run_command(
136
+ run_command_with_systems_locale(
137
137
  :command => "yum -q -y install #{name}-#{version}"
138
138
  )
139
139
  @yum.flush
@@ -142,7 +142,7 @@ class Chef
142
142
  def upgrade_package(name, version)
143
143
  # If we have a version, we can upgrade - otherwise, install
144
144
  if @current_resource.version
145
- run_command(
145
+ run_command_with_systems_locale(
146
146
  :command => "yum -q -y update #{name}-#{version}"
147
147
  )
148
148
  @yum.flush
@@ -153,11 +153,11 @@ class Chef
153
153
 
154
154
  def remove_package(name, version)
155
155
  if version
156
- run_command(
156
+ run_command_with_systems_locale(
157
157
  :command => "yum -q -y remove #{name}-#{version}"
158
158
  )
159
159
  else
160
- run_command(
160
+ run_command_with_systems_locale(
161
161
  :command => "yum -q -y remove #{name}"
162
162
  )
163
163
  end
@@ -55,23 +55,30 @@ class Chef
55
55
  get_from_local_cookbook(source)
56
56
 
57
57
  # If the file exists
58
+ Chef::Log.debug "#{@new_resource}: Checking for file existence of #{@new_resource.path}"
58
59
  if ::File.exists?(@new_resource.path)
59
60
  # And it matches the checksum of the raw file
60
61
  @new_resource.checksum(self.checksum(raw_file.path))
62
+ Chef::Log.debug "#{@new_resource}: File exists at #{@new_resource.path}"
63
+ Chef::Log.debug "#{@new_resource}: Target checksum: #{@current_resource.checksum}"
64
+ Chef::Log.debug "#{@new_resource}: Source checksum: #{@new_resource.checksum}"
61
65
  if @new_resource.checksum != @current_resource.checksum
62
66
  # Updating target file, let's perform a backup!
63
- Chef::Log.debug("#{@new_resource} changed from #{@current_resource.checksum} to #{@new_resource.checksum}")
64
- Chef::Log.info("Updating #{@new_resource} at #{@new_resource.path}")
65
- backup(@new_resource.path)
67
+ Chef::Log.debug "#{@new_resource}: checksum changed from #{@current_resource.checksum} to #{@new_resource.checksum}"
68
+ Chef::Log.info "#{@new_resource}: Updating #{@new_resource.path}"
69
+ backup @new_resource.path
70
+ FileUtils.cp raw_file.path, @new_resource.path
71
+ @new_resource.updated = true
72
+ else
73
+ Chef::Log.debug "#{@new_resource}: Target and Source checksums are the same, taking no action"
66
74
  end
67
75
  else
68
76
  # We're creating a new file
69
- Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}")
77
+ Chef::Log.info "#{@new_resource}: Creating #{@new_resource.path}"
78
+ FileUtils.cp raw_file.path, @new_resource.path
79
+ @new_resource.updated = true
70
80
  end
71
81
 
72
- FileUtils.cp(raw_file.path, @new_resource.path)
73
- @new_resource.updated = true
74
-
75
82
  # We're done with the file, so make sure to close it if it was open.
76
83
  raw_file.close unless raw_file.closed?
77
84
  rescue Net::HTTPRetriableError => e
@@ -25,8 +25,8 @@ class Chef
25
25
 
26
26
  include Chef::Mixin::Command
27
27
 
28
- def initialize(node, new_resource)
29
- super(node, new_resource)
28
+ def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil)
29
+ super(node, new_resource, collection, definitions, cookbook_loader)
30
30
  @enabled = nil
31
31
  end
32
32
 
@@ -35,6 +35,7 @@ class Chef
35
35
  Chef::Log.debug("#{@new_resource}: attempting to enable")
36
36
  status = enable_service()
37
37
  if status
38
+ @new_resource.updated = true
38
39
  Chef::Log.info("#{@new_resource}: enabled successfully")
39
40
  end
40
41
  else
@@ -47,6 +48,7 @@ class Chef
47
48
  Chef::Log.debug("#{@new_resource}: attempting to disable")
48
49
  status = disable_service()
49
50
  if status
51
+ @new_resource.updated = true
50
52
  Chef::Log.info("#{@new_resource}: disabled successfully")
51
53
  end
52
54
  else
@@ -59,6 +61,7 @@ class Chef
59
61
  Chef::Log.debug("#{@new_resource}: attempting to start")
60
62
  status = start_service()
61
63
  if status
64
+ @new_resource.updated = true
62
65
  Chef::Log.info("Started service #{@new_resource} successfully")
63
66
  end
64
67
  else
@@ -71,6 +74,7 @@ class Chef
71
74
  Chef::Log.debug("#{@new_resource}: attempting to stop")
72
75
  status = stop_service()
73
76
  if status
77
+ @new_resource.updated = true
74
78
  Chef::Log.info("#{@new_resource}: stopped successfully")
75
79
  end
76
80
  else
@@ -82,6 +86,7 @@ class Chef
82
86
  Chef::Log.debug("#{@new_resource}: attempting to restart")
83
87
  status = restart_service()
84
88
  if status
89
+ @new_resource.updated = true
85
90
  Chef::Log.info("#{@new_resource}: restarted successfully")
86
91
  end
87
92
  end
@@ -94,6 +99,7 @@ class Chef
94
99
  Chef::Log.debug("#{@new_resource}: attempting to reload")
95
100
  status = reload_service()
96
101
  if status
102
+ @new_resource.updated = true
97
103
  Chef::Log.info("#{@new_resource}: reloaded successfully")
98
104
  end
99
105
  end