puppet 2.7.16 → 2.7.17

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ 2.7.17
2
+ ===
3
+ 30d89d3 (maint) Add symlink stub to gentoo service provider spec
4
+ ff1b37a Add comment to upstart provider explaining exclusion of 'wait-for-state'
5
+ 6b854f7 Upstart code cleanup, init provider improvement
6
+ 0f81d9a Add spec test for network-interface-security
7
+ a2c1e23 Add basic service resource test to upstart acceptance
8
+ 2c85d4d Handle network-interface-security in upstart
9
+ ed00e74 Add exclude list to upstart provider
10
+ 17cc177 (#15027, #15028, #15029) Fix upstart version parsing
11
+ b0ee6ad (maint) Add --test to puppet run
12
+
1
13
  2.7.16
2
14
  ===
3
15
  99fecc3 Update facter dep to reflect epoch 1
@@ -5,7 +5,7 @@
5
5
  %global confdir conf/redhat
6
6
 
7
7
  Name: puppet
8
- Version: 2.7.16
8
+ Version: 2.7.17
9
9
  #Release: 0.1rc1.2%{?dist}
10
10
  Release: 1%{?dist}
11
11
  Summary: A network tool for managing many disparate systems
@@ -289,7 +289,10 @@ fi
289
289
  rm -rf %{buildroot}
290
290
 
291
291
  %changelog
292
- * Wed Jun 13 2012 Matthaus Litteken <matthaus@puppelabs.com> - 2.7.16-1
292
+ * Tue Jun 19 2012 Matthaus Litteken <matthaus@puppetlabs.com> - 2.7.17-1
293
+ - Update for 2.7.17
294
+
295
+ * Wed Jun 13 2012 Matthaus Litteken <matthaus@puppetlabs.com> - 2.7.16-1
293
296
  - Update for 2.7.16
294
297
 
295
298
  * Fri Jun 08 2012 Moses Mendoza <moses@puppetlabs.com> - 2.7.16-0.1rc1.2
@@ -24,7 +24,7 @@ require 'puppet/util/run_mode'
24
24
  # it's also a place to find top-level commands like 'debug'
25
25
 
26
26
  module Puppet
27
- PUPPETVERSION = '2.7.16'
27
+ PUPPETVERSION = '2.7.17'
28
28
 
29
29
  def Puppet.version
30
30
  PUPPETVERSION
@@ -42,6 +42,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
42
42
  next if name =~ /^\./
43
43
  next if exclude.include? name
44
44
  next if not FileTest.executable?(fullpath)
45
+ next if not is_init?(fullpath)
45
46
  instances << new(:name => name, :path => path, :hasstatus => true)
46
47
  end
47
48
  end
@@ -130,5 +131,10 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
130
131
  (@resource[:hasstatus] == :true) && [initscript, :status]
131
132
  end
132
133
 
134
+ private
135
+
136
+ def self.is_init?(script = initscript)
137
+ !File.symlink?(script) || File.readlink(script) != "/lib/init/upstart-job"
138
+ end
133
139
  end
134
140
 
@@ -25,7 +25,18 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
25
25
  # http://www.linuxplanet.com/linuxplanet/tutorials/7033/2/
26
26
  has_feature :enableable
27
27
 
28
+ # 'wait-for-state' is excluded from instances here because it takes
29
+ # parameters that have unclear meaning. It looks like 'wait-for-state' is
30
+ # mainly used internally for other upstart services as a 'sleep until something happens'
31
+ # (http://lists.debian.org/debian-devel/2012/02/msg01139.html). There is an open launchpad bug
32
+ # (https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/962047) that may
33
+ # eventually explain how to use this service or perhaps why it should remain
34
+ # excluded. When that bug is adddressed this should be reexamined.
28
35
  def self.instances
36
+ self.get_services(['wait-for-state'])
37
+ end
38
+
39
+ def self.get_services(exclude=[])
29
40
  instances = []
30
41
  execpipe("#{command(:initctl)} list") { |process|
31
42
  process.each_line { |line|
@@ -37,13 +48,15 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
37
48
  name = \
38
49
  if matcher = line.match(/^(network-interface)\s\(([^\)]+)\)/)
39
50
  "#{matcher[1]} INTERFACE=#{matcher[2]}"
51
+ elsif matcher = line.match(/^(network-interface-security)\s\(([^\)]+)\)/)
52
+ "#{matcher[1]} JOB=#{matcher[2]}"
40
53
  else
41
54
  line.split.first
42
55
  end
43
56
  instances << new(:name => name)
44
57
  }
45
58
  }
46
- instances
59
+ instances.reject { |instance| exclude.include?(instance.name) }
47
60
  end
48
61
 
49
62
  def self.defpath
@@ -51,7 +64,7 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
51
64
  end
52
65
 
53
66
  def upstart_version
54
- @@upstart_version ||= SemVer.new(initctl(" --version").match(/initctl \(upstart (\d\.\d[\.\d]?)\)/)[1])
67
+ @@upstart_version ||= initctl("--version").match(/initctl \(upstart ([^\)]*)\)/)[1]
55
68
  end
56
69
 
57
70
  # Where is our override script?
@@ -63,7 +76,8 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
63
76
  # Search prefers .conf as that is what upstart uses
64
77
  [".conf", "", ".sh"].each do |suffix|
65
78
  paths.each do |path|
66
- fqname = File.join(path,name+suffix)
79
+ service_name = name.match(/^(\S+)/)[1]
80
+ fqname = File.join(path, service_name + suffix)
67
81
  if File.exists?(fqname)
68
82
  return fqname
69
83
  end
@@ -79,11 +93,11 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
79
93
  return super if not is_upstart?
80
94
 
81
95
  script_contents = read_script_from(initscript)
82
- if upstart_version < "0.6.7"
96
+ if version_is_pre_0_6_7
83
97
  enabled_pre_0_6_7?(script_contents)
84
- elsif upstart_version < "0.9.0"
98
+ elsif version_is_pre_0_9_0
85
99
  enabled_pre_0_9_0?(script_contents)
86
- elsif upstart_version >= "0.9.0"
100
+ elsif version_is_post_0_9_0
87
101
  enabled_post_0_9_0?(script_contents, read_override_file)
88
102
  end
89
103
  end
@@ -92,7 +106,7 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
92
106
  return super if not is_upstart?
93
107
 
94
108
  script_text = read_script_from(initscript)
95
- if upstart_version < "0.9.0"
109
+ if version_is_pre_0_9_0
96
110
  enable_pre_0_9_0(script_text)
97
111
  else
98
112
  enable_post_0_9_0(script_text, read_override_file)
@@ -103,11 +117,11 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
103
117
  return super if not is_upstart?
104
118
 
105
119
  script_text = read_script_from(initscript)
106
- if upstart_version < "0.6.7"
120
+ if version_is_pre_0_6_7
107
121
  disable_pre_0_6_7(script_text)
108
- elsif upstart_version < "0.9.0"
122
+ elsif version_is_pre_0_9_0
109
123
  disable_pre_0_9_0(script_text)
110
- elsif upstart_version >= "0.9.0"
124
+ elsif version_is_post_0_9_0
111
125
  disable_post_0_9_0(read_override_file)
112
126
  end
113
127
  end
@@ -129,36 +143,32 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
129
143
  end
130
144
 
131
145
  def status
132
- if @resource[:status]
133
- is_upstart?(@resource[:status]) ? upstart_status(@resource[:status]) : normal_status
134
- elsif is_upstart?
135
- upstart_status
136
- else
137
- super
138
- end
139
- end
140
-
141
- def normal_status
142
- ucommand(:status, false)
143
- ($?.exitstatus == 0) ? :running : :stopped
144
- end
146
+ return super if not is_upstart?
145
147
 
146
- def upstart_status(exec = @resource[:name])
147
148
  output = status_exec(@resource[:name].split)
148
- if (! $?.nil?) && (output =~ /start\//)
149
+ if output =~ /start\//
149
150
  return :running
150
151
  else
151
152
  return :stopped
152
153
  end
153
154
  end
154
155
 
156
+ private
155
157
  def is_upstart?(script = initscript)
156
- return true if (File.symlink?(script) && File.readlink(script) == "/lib/init/upstart-job")
157
- return true if (File.file?(script) && (not script.include?("init.d")))
158
- return false
158
+ File.exists?(script) && script.match(/\/etc\/init\/\S+\.conf/)
159
159
  end
160
160
 
161
- private
161
+ def version_is_pre_0_6_7
162
+ Puppet::Util::Package.versioncmp(upstart_version, "0.6.7") == -1
163
+ end
164
+
165
+ def version_is_pre_0_9_0
166
+ Puppet::Util::Package.versioncmp(upstart_version, "0.9.0") == -1
167
+ end
168
+
169
+ def version_is_post_0_9_0
170
+ Puppet::Util::Package.versioncmp(upstart_version, "0.9.0") >= 0
171
+ end
162
172
 
163
173
  def enabled_pre_0_6_7?(script_text)
164
174
  # Upstart version < 0.6.7 means no manual stanza.
@@ -48,6 +48,7 @@ describe Puppet::Type.type(:service).provider(:gentoo) do
48
48
 
49
49
  it "should get a list of services from /etc/init.d but exclude helper scripts" do
50
50
  FileTest.expects(:directory?).with('/etc/init.d').returns true
51
+ File.stubs(:symlink?).returns(false)
51
52
  Dir.expects(:entries).with('/etc/init.d').returns initscripts
52
53
  (initscripts - helperscripts).each do |script|
53
54
  FileTest.expects(:executable?).with("/etc/init.d/#{script}").returns true
@@ -14,9 +14,7 @@ describe provider_class do
14
14
  @resource = stub 'resource'
15
15
  @resource.stubs(:[]).returns(nil)
16
16
  @resource.stubs(:[]).with(:name).returns "myservice"
17
- # @resource.stubs(:[]).with(:ensure).returns :enabled
18
17
  @resource.stubs(:[]).with(:path).returns ["/service/path","/alt/service/path"]
19
- # @resource.stubs(:ref).returns "Service[myservice]"
20
18
  File.stubs(:directory?).returns(true)
21
19
 
22
20
  @provider = provider_class.new
@@ -31,41 +29,64 @@ describe provider_class do
31
29
  FileTest.stubs(:executable?).returns(true)
32
30
  @class.stubs(:defpath).returns('tmp')
33
31
  end
32
+
34
33
  it "should return instances for all services" do
35
34
  @services.each do |inst|
36
35
  @class.expects(:new).with{|hash| hash[:name] == inst}.returns("#{inst}_instance")
37
36
  end
38
37
  results = @services.collect {|x| "#{x}_instance"}
38
+
39
39
  @class.instances.should == results
40
40
  end
41
+
41
42
  it "should omit an array of services from exclude list" do
42
43
  exclude = ['two', 'four']
43
- (@services-exclude).each do |inst|
44
+ (@services - exclude).each do |inst|
44
45
  @class.expects(:new).with{|hash| hash[:name] == inst}.returns("#{inst}_instance")
45
46
  end
46
47
  results = (@services-exclude).collect {|x| "#{x}_instance"}
48
+
47
49
  @class.get_services(@class.defpath, exclude).should == results
48
50
  end
51
+
49
52
  it "should omit a single service from the exclude list" do
50
53
  exclude = 'two'
51
- (@services-[exclude]).each do |inst|
54
+ (@services - [exclude]).each do |inst|
52
55
  @class.expects(:new).with{|hash| hash[:name] == inst}.returns("#{inst}_instance")
53
56
  end
54
- results = @services.reject{|x| x==exclude }.collect {|x| "#{x}_instance"}
57
+ results = @services.reject{|x| x == exclude }.collect {|x| "#{x}_instance"}
58
+
55
59
  @class.get_services(@class.defpath, exclude).should == results
56
60
  end
61
+
57
62
  it "should use defpath" do
58
63
  @services.each do |inst|
59
64
  @class.expects(:new).with{|hash| hash[:path] == @class.defpath}.returns("#{inst}_instance")
60
65
  end
61
66
  results = @services.sort.collect {|x| "#{x}_instance"}
67
+
62
68
  @class.instances.sort.should == results
63
69
  end
70
+
64
71
  it "should set hasstatus to true for providers" do
65
72
  @services.each do |inst|
66
73
  @class.expects(:new).with{|hash| hash[:name] == inst && hash[:hasstatus] == true}.returns("#{inst}_instance")
67
74
  end
68
75
  results = @services.collect {|x| "#{x}_instance"}
76
+
77
+ @class.instances.should == results
78
+ end
79
+
80
+ it "should discard upstart jobs" do
81
+ not_init_service, *valid_services = @services
82
+ valid_services.each do |inst|
83
+ @class.expects(:new).with{|hash| hash[:name] == inst && hash[:hasstatus] == true}.returns("#{inst}_instance")
84
+ end
85
+ File.stubs(:symlink?).returns(false)
86
+ File.stubs(:symlink?).with("tmp/#{not_init_service}").returns(true)
87
+ File.stubs(:readlink).with("tmp/#{not_init_service}").returns("/lib/init/upstart-job")
88
+
89
+ results = valid_services.collect {|x| "#{x}_instance"}
69
90
  @class.instances.should == results
70
91
  end
71
92
  end
@@ -25,25 +25,47 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
25
25
  end
26
26
 
27
27
  it "should attach the interface name for network interfaces" do
28
- processes = ["network-interface (eth0)"].join("\n")
28
+ processes = "network-interface (eth0)"
29
29
  provider_class.stubs(:execpipe).yields(processes)
30
30
  provider_class.instances.first.name.should == "network-interface INTERFACE=eth0"
31
31
  end
32
+
33
+ it "should attach the job name for network interface security" do
34
+ processes = "network-interface-security (network-interface/eth0)"
35
+ provider_class.stubs(:execpipe).yields(processes)
36
+ provider_class.instances.first.name.should == "network-interface-security JOB=network-interface/eth0"
37
+ end
38
+
39
+ it "should not find excluded services" do
40
+ processes = "wait-for-state stop/waiting"
41
+ provider_class.stubs(:execpipe).yields(processes)
42
+ provider_class.instances.should be_empty
43
+ end
32
44
  end
33
45
 
34
- describe "#status" do
35
- it "should allow the user to override the status command" do
36
- resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart, :status => "/bin/foo")
46
+ describe "#search" do
47
+ it "searches through paths to find a matching conf file" do
48
+ File.stubs(:directory?).returns(true)
49
+ File.stubs(:exists?).returns(false)
50
+ File.expects(:exists?).with("/etc/init/foo-bar.conf").returns(true)
51
+ resource = Puppet::Type.type(:service).new(:name => "foo-bar", :provider => :upstart)
37
52
  provider = provider_class.new(resource)
38
53
 
39
- # Because we stub execution, we also need to stub the result of it, or a
40
- # previously failing command execution will cause this test to do the
41
- # wrong thing.
42
- provider.expects(:ucommand)
43
- $?.stubs(:exitstatus).returns(0)
44
- provider.status.should == :running
54
+ provider.initscript.should == "/etc/init/foo-bar.conf"
45
55
  end
46
56
 
57
+ it "searches for just the name of a compound named service" do
58
+ File.stubs(:directory?).returns(true)
59
+ File.stubs(:exists?).returns(false)
60
+ File.expects(:exists?).with("/etc/init/network-interface.conf").returns(true)
61
+ resource = Puppet::Type.type(:service).new(:name => "network-interface INTERFACE=lo", :provider => :upstart)
62
+ provider = provider_class.new(resource)
63
+
64
+ provider.initscript.should == "/etc/init/network-interface.conf"
65
+ end
66
+ end
67
+
68
+ describe "#status" do
47
69
  it "should use the default status command if none is specified" do
48
70
  resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart)
49
71
  provider = provider_class.new(resource)
@@ -87,18 +109,6 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
87
109
  provider.statuscmd.should be_nil
88
110
  end
89
111
  end
90
-
91
- describe "when init script" do
92
- before(:each) do
93
- provider.stubs(:is_upstart?).returns(false)
94
- end
95
- ["start", "stop", "status"].each do |command|
96
- it "should return the #{command}cmd of its parent provider" do
97
- provider.expects(:search).with('foo').returns("/etc/init.d/foo")
98
- provider.send("#{command}cmd".to_sym).should == ["/etc/init.d/foo", command.to_sym]
99
- end
100
- end
101
- end
102
112
  end
103
113
 
104
114
  describe "should be enableable" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 7
9
- - 16
10
- version: 2.7.16
9
+ - 17
10
+ version: 2.7.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Puppet Labs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-14 00:00:00 Z
18
+ date: 2012-06-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: facter