diff --git a/lib/puppet/provider/service/openbsd.rb b/lib/puppet/provider/service/openbsd.rb index 8fe68955e..55b521785 100644 --- a/lib/puppet/provider/service/openbsd.rb +++ b/lib/puppet/provider/service/openbsd.rb @@ -1,23 +1,341 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :init do desc "Provider for OpenBSD's rc.d daemon control scripts" confine :operatingsystem => :openbsd defaultfor :operatingsystem => :openbsd + has_feature :flaggable + + def self.rcconf() '/etc/rc.conf' end + def self.rcconf_local() '/etc/rc.conf.local' end def self.defpath ["/etc/rc.d"] end def startcmd [self.initscript, "-f", :start] end def restartcmd (@resource[:hasrestart] == :true) && [self.initscript, "-f", :restart] end def statuscmd [self.initscript, :check] end + + # Fetch the state of all service resources + def self.prefetch(resources) + services = instances + resources.keys.each do |name| + if provider = services.find { |svc| svc.name == name } + resources[name].provider = provider + end + end + end + + # Return the list of rc scripts + # @api private + def self.rclist + unless @rclist + Puppet.debug "Building list of rc scripts" + @rclist = [] + defpath.each do |p| + Dir.glob(p + '/*').each do |item| + @rclist << item if File.executable?(item) + end + end + end + @rclist + end + + # Return a hash where the keys are the rc script names as symbols with flags + # as values + # @api private + def self.rcflags + unless @flag_hash + Puppet.debug "Retrieving flags for all discovered services" + + Puppet.debug "Reading the contents of the rc conf files" + + if File.exists?(rcconf_local()) + rcconf_local_contents = File.readlines(rcconf_local()) + else + rcconf_local_contents = [] + end + + if File.exists?(rcconf()) + rcconf_contents = File.readlines(rcconf()) + else + rcconf_contents = [] + end + + @flag_hash = {} + rclist().each do |rcitem| + + rcname = rcitem.split('/').last + + if flagline = rcconf_local_contents.find {|l| l =~ /^#{rcname}_flags/ } + flag = parse_rc_line(flagline) + @flag_hash[rcname.to_sym] ||= flag + end + + # For the defaults, if the flags are set to 'NO', we skip setting the + # flag here, since it will already be disabled, and this makes the + # output of `puppet resource service` a bit more correct. + if flagline = rcconf_contents.find {|l| l =~ /^#{rcname}_flags/ } + flag = parse_rc_line(flagline) + unless flag == "NO" + @flag_hash[rcname.to_sym] ||= flag + end + end + @flag_hash[rcname.to_sym] ||= nil + end + end + @flag_hash + end + + # @api private + def self.parse_rc_line(rc_line) + rc_line.sub!(/\s*#(.*)$/,'') + regex = /\w+_flags=(.*)/ + rc_line.match(regex)[1].gsub(/^"/,'').gsub(/"$/,'') + end + + # Read the rc.conf* files and determine the value of the flags + # @api private + def self.get_flags(rcname) + rcflags() + @flag_hash[rcname.to_sym] + end + + def self.instances + instances = [] + defpath.each do |path| + unless File.directory?(path) + Puppet.debug "Service path #{path} does not exist" + next + end + + rclist().each do |d| + instances << new( + :name => File.basename(d), + :path => path, + :flags => get_flags(File.basename(d)), + :hasstatus => true + ) + end + end + instances + end + + # @api private + def rcvar_name + self.name + '_flags' + end + + # @api private + def read_rcconf_local_text() + if File.exists?(self.class.rcconf_local()) + File.read(self.class.rcconf_local()) + else + [] + end + end + + # @api private + def load_rcconf_local_array + if File.exists?(self.class.rcconf_local()) + File.readlines(self.class.rcconf_local()).map {|l| + l.chomp! + } + else + [] + end + end + + # @api private + def write_rc_contents(file, text) + Puppet::Util.replace_file(file, 0644) do |f| + f.write(text) + end + end + + # @api private + def set_content_flags(content,flags) + unless content.is_a? Array + debug "content must be an array at flags" + return "" + else + content.reject! {|l| l.nil? } + end + + if flags.nil? + append = resource[:name] + '_flags=""' + else + append = resource[:name] + '_flags="' + flags + '"' + end + + if content.find {|l| l =~ /#{resource[:name]}_flags/ }.nil? + content << append + else + content.map {|l| l.gsub!(/^#{resource[:name]}_flags="(.*)?"(.*)?$/, append) } + end + content + end + + # @api private + def remove_content_flags(content) + content.reject {|l| l =~ /#{resource[:name]}_flags/ } + end + + # return an array of the currently enabled pkg_scripts + # @api private + def pkg_scripts + current = load_rcconf_local_array() + if scripts = current.find{|l| l =~ /^pkg_scripts/ } + if match = scripts.match(/^pkg_scripts="(.*)?"(.*)?$/) + match[1].split(' ') + else + [] + end + else + [] + end + end + + # return the array with the current resource added + # @api private + def pkg_scripts_append + [pkg_scripts(), resource[:name]].flatten.sort.uniq + end + + # return the array without the current resource + # @api private + def pkg_scripts_remove + pkg_scripts().reject {|s| s == resource[:name] } + end + + # Modify the content array to contain the requsted pkg_scripts line and retun + # the resulting array + # @api private + def set_content_scripts(content,scripts) + unless content.is_a? Array + debug "content must be an array at scripts" + return "" + else + content.reject! {|l| l.nil? } + end + + scripts_line = 'pkg_scripts="' + scripts.join(' ') + '"' + + if content.find {|l| l =~ /^pkg_scripts/ }.nil? + content << scripts_line + else + # Replace the found pkg_scripts line with our own + content.each_with_index {|l,i| + if l =~ /^pkg_scripts/ + content[i] = scripts_line + end + } + end + content + end + + # Determine if the rc script is included in base, or if it exists as a result + # of a package installation. + # @api private + def in_base? + system("/usr/sbin/pkg_info -qE /etc/rc.d/#{self.name}> /dev/null") + $?.exitstatus == 1 + end + + # @api private + def default_disabled? + line = File.readlines(self.class.rcconf).find {|l| l =~ /#{rcvar_name}/ } + self.class.parse_rc_line(line) == 'NO' + end + + def enabled? + if in_base? + if (@property_hash[:flags].nil? or @property_hash[:flags] == 'NO') + :false + else + :true + end + else + if (pkg_scripts().include?(@property_hash[:name])) + :true + else + :false + end + end + end + + def enable + self.debug("Enabling #{self.name}") + end + + # We should also check for default state + def disable + self.debug("Disabling #{self.name}") + end + + def flags + @property_hash[:flags] + end + + def flags=(value) + @property_hash[:flags] = value + end + + def flush + debug "Flusing resource for #{self.name}" + + # Here we load the contents of the rc.conf.local file into the contents + # variable, modify it if needed, and then compare that to the original. If + # they are different, we write it out. + + original = load_rcconf_local_array() + content = original + + debug @property_hash.inspect + + if resource[:enable] == :true + #set_flags(resource[:flags]) + content = set_content_flags(content, resource[:flags]) + + # We need only add append the resource name to the pkg_scripts if the + # package is not found in the base system. + + if not in_base? + content = set_content_scripts(content,pkg_scripts_append()) + end + elsif resource[:enable] == :false + + # By virtue of being excluded from the base system, all packages are + # disabled by default and need not be set in the rc.conf.local at all. + + if not in_base? + content = remove_content_flags(content) + content = set_content_scripts(content,pkg_scripts_remove()) + else + if default_disabled? + content = remove_content_flags(content) + else + content = set_content_flags(content, "NO") + end + end + end + + # Make sure to append a newline to the end of the file + unless content[-1] == "" + content << "" + end + output = content.join("\n") + + # Write the contents only if necessary, and only once + write_rc_contents(self.class.rcconf_local(), output) + end end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index 607a9361f..dc54f1d61 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -1,228 +1,234 @@ # This is our main way of managing processes right now. # # a service is distinct from a process in that services # can only be managed through the interface of an init script # which is why they have a search path for initscripts and such module Puppet newtype(:service) do @doc = "Manage running services. Service support unfortunately varies widely by platform --- some platforms have very little if any concept of a running service, and some have a very codified and powerful concept. Puppet's service support is usually capable of doing the right thing, but the more information you can provide, the better behaviour you will get. Puppet 2.7 and newer expect init scripts to have a working status command. If this isn't the case for any of your services' init scripts, you will need to set `hasstatus` to false and possibly specify a custom status command in the `status` attribute. As a last resort, Puppet will attempt to search the process table by calling whatever command is listed in the `ps` fact. The default search pattern is the name of the service, but you can specify it with the `pattern` attribute. **Refresh:** `service` resources can respond to refresh events (via `notify`, `subscribe`, or the `~>` arrow). If a `service` receives an event from another resource, Puppet will restart the service it manages. The actual command used to restart the service depends on the platform and can be configured: * If you set `hasrestart` to true, Puppet will use the init script's restart command. * You can provide an explicit command for restarting with the `restart` attribute. * If you do neither, the service's stop and start commands will be used." feature :refreshable, "The provider can restart the service.", :methods => [:restart] feature :enableable, "The provider can enable and disable the service", :methods => [:disable, :enable, :enabled?] feature :controllable, "The provider uses a control variable." + feature :flaggable, "The provider can pass flags to the service." + newproperty(:enable, :required_features => :enableable) do desc "Whether a service should be enabled to start at boot. This property behaves quite differently depending on the platform; wherever possible, it relies on local tools to enable or disable a given service." newvalue(:true, :event => :service_enabled) do provider.enable end newvalue(:false, :event => :service_disabled) do provider.disable end newvalue(:manual, :event => :service_manual_start) do provider.manual_start end def retrieve provider.enabled? end validate do |value| if value == :manual and !Puppet.features.microsoft_windows? raise Puppet::Error.new("Setting enable to manual is only supported on Microsoft Windows.") end end end # Handle whether the service should actually be running right now. newproperty(:ensure) do desc "Whether a service should be running." newvalue(:stopped, :event => :service_stopped) do provider.stop end newvalue(:running, :event => :service_started, :invalidate_refreshes => true) do provider.start end aliasvalue(:false, :stopped) aliasvalue(:true, :running) def retrieve provider.status end def sync event = super() if property = @resource.property(:enable) val = property.retrieve property.sync unless property.safe_insync?(val) end event end end + newproperty(:flags, :required_features => :flaggable) do + desc "Specify a string of flags to pass to the startup script." + end + newparam(:binary) do desc "The path to the daemon. This is only used for systems that do not support init scripts. This binary will be used to start the service if no `start` parameter is provided." end newparam(:hasstatus) do desc "Declare whether the service's init script has a functional status command; defaults to `true`. This attribute's default value changed in Puppet 2.7.0. The init script's status command must return 0 if the service is running and a nonzero value otherwise. Ideally, these exit codes should conform to [the LSB's specification][lsb-exit-codes] for init script status actions, but Puppet only considers the difference between 0 and nonzero to be relevant. If a service's init script does not support any kind of status command, you should set `hasstatus` to false and either provide a specific command using the `status` attribute or expect that Puppet will look for the service name in the process table. Be aware that 'virtual' init scripts (like 'network' under Red Hat systems) will respond poorly to refresh events from other resources if you override the default behavior without providing a status command." newvalues(:true, :false) defaultto :true end newparam(:name) do desc <<-EOT The name of the service to run. This name is used to find the service; on platforms where services have short system names and long display names, this should be the short name. (To take an example from Windows, you would use "wuauserv" rather than "Automatic Updates.") EOT isnamevar end newparam(:path) do desc "The search path for finding init scripts. Multiple values should be separated by colons or provided as an array." munge do |value| value = [value] unless value.is_a?(Array) value.flatten.collect { |p| p.split(File::PATH_SEPARATOR) }.flatten end defaultto { provider.class.defpath if provider.class.respond_to?(:defpath) } end newparam(:pattern) do desc "The pattern to search for in the process table. This is used for stopping services on platforms that do not support init scripts, and is also used for determining service status on those service whose init scripts do not include a status command. Defaults to the name of the service. The pattern can be a simple string or any legal Ruby pattern, including regular expressions (which should be quoted without enclosing slashes)." defaultto { @resource[:binary] || @resource[:name] } end newparam(:restart) do desc "Specify a *restart* command manually. If left unspecified, the service will be stopped and then started." end newparam(:start) do desc "Specify a *start* command manually. Most service subsystems support a `start` command, so this will not need to be specified." end newparam(:status) do desc "Specify a *status* command manually. This command must return 0 if the service is running and a nonzero value otherwise. Ideally, these exit codes should conform to [the LSB's specification][lsb-exit-codes] for init script status actions, but Puppet only considers the difference between 0 and nonzero to be relevant. If left unspecified, the status of the service will be determined automatically, usually by looking for the service in the process table. [lsb-exit-codes]: http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html" end newparam(:stop) do desc "Specify a *stop* command manually." end newparam(:control) do desc "The control variable used to manage services (originally for HP-UX). Defaults to the upcased service name plus `START` replacing dots with underscores, for those providers that support the `controllable` feature." defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? } end newparam :hasrestart do desc "Specify that an init script has a `restart` command. If this is false and you do not specify a command in the `restart` attribute, the init script's `stop` and `start` commands will be used. Defaults to false." newvalues(:true, :false) end newparam(:manifest) do desc "Specify a command to config a service, or a path to a manifest to do so." end # Basically just a synonym for restarting. Used to respond # to events. def refresh # Only restart if we're actually running if (@parameters[:ensure] || newattr(:ensure)).retrieve == :running provider.restart else debug "Skipping restart; service is not running" end end end end diff --git a/spec/unit/provider/service/openbsd_spec.rb b/spec/unit/provider/service/openbsd_spec.rb index 5bed8862a..e7ba4a4db 100644 --- a/spec/unit/provider/service/openbsd_spec.rb +++ b/spec/unit/provider/service/openbsd_spec.rb @@ -1,125 +1,232 @@ #!/usr/bin/env ruby # # Unit testing for the OpenBSD service provider require 'spec_helper' provider_class = Puppet::Type.type(:service).provider(:openbsd) describe provider_class do before :each do Puppet::Type.type(:service).stubs(:defaultprovider).returns described_class Facter.stubs(:value).with(:operatingsystem).returns :openbsd end let :rcscripts do [ - 'apmd', - 'aucat', - 'cron', - 'puppetd' - ] + '/etc/rc.d/apmd', + '/etc/rc.d/aucat', + '/etc/rc.d/cron', + '/etc/rc.d/puppetd' + ] end describe "#instances" do it "should have an instances method" do described_class.should respond_to :instances end it "should list all available services" do - FileTest.expects(:directory?).with('/etc/rc.d').returns true - Dir.expects(:entries).with('/etc/rc.d').returns rcscripts + File.expects(:directory?).with('/etc/rc.d').returns true + Dir.expects(:glob).with('/etc/rc.d/*').returns rcscripts rcscripts.each do |script| - FileTest.expects(:executable?).with("/etc/rc.d/#{script}").returns true + File.expects(:executable?).with(script).returns true end described_class.instances.map(&:name).should == [ 'apmd', 'aucat', 'cron', 'puppetd' ] end end describe "#start" do it "should use the supplied start command if specified" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :start => '/bin/foo')) provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.start end it "should start the service otherwise" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd')) provider.expects(:execute).with(['/etc/rc.d/sshd', '-f', :start], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.expects(:search).with('sshd').returns('/etc/rc.d/sshd') provider.start end end describe "#stop" do it "should use the supplied stop command if specified" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :stop => '/bin/foo')) provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.stop end it "should stop the service otherwise" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd')) provider.expects(:execute).with(['/etc/rc.d/sshd', :stop], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.expects(:search).with('sshd').returns('/etc/rc.d/sshd') provider.stop end end describe "#status" do it "should use the status command from the resource" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo')) provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true) provider.status end - it "should return :stopped when status command returns with a non-zero exitcode" do - provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo')) - provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never - provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true) - $CHILD_STATUS.stubs(:exitstatus).returns 3 - provider.status.should == :stopped - end + it "should return :stopped when status command returns with a non-zero exitcode" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo')) + provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never + provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true) + $CHILD_STATUS.stubs(:exitstatus).returns 3 + provider.status.should == :stopped + end - it "should return :running when status command returns with a zero exitcode" do - provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo')) - provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never - provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true) - $CHILD_STATUS.stubs(:exitstatus).returns 0 - provider.status.should == :running - end + it "should return :running when status command returns with a zero exitcode" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo')) + provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never + provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true) + $CHILD_STATUS.stubs(:exitstatus).returns 0 + provider.status.should == :running + end end describe "#restart" do it "should use the supplied restart command if specified" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo')) provider.expects(:execute).with(['/etc/rc.d/sshd', '-f', :restart], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.restart end it "should restart the service with rc-service restart if hasrestart is true" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :hasrestart => true)) provider.expects(:execute).with(['/etc/rc.d/sshd', '-f', :restart], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.expects(:search).with('sshd').returns('/etc/rc.d/sshd') provider.restart end it "should restart the service with rc-service stop/start if hasrestart is false" do provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :hasrestart => false)) provider.expects(:execute).with(['/etc/rc.d/sshd', '-f', :restart], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never provider.expects(:execute).with(['/etc/rc.d/sshd', :stop], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.expects(:execute).with(['/etc/rc.d/sshd', '-f', :start], :failonfail => true, :override_locale => false, :squelch => false, :combine => true) provider.expects(:search).with('sshd').returns('/etc/rc.d/sshd') provider.restart end end + + describe "#parse_rc_line" do + it "can parse a flag line with a known value" do + output = described_class.parse_rc_line('daemon_flags=') + output.should eq('') + end + + it "can parse a flag line with a flag is wrapped in single quotes" do + output = described_class.parse_rc_line('daemon_flags=\'\'') + output.should eq('\'\'') + end + + it "can parse a flag line with a flag is wrapped in double quotes" do + output = described_class.parse_rc_line('daemon_flags=""') + output.should eq('') + end + + it "can parse a flag line with a trailing comment" do + output = described_class.parse_rc_line('daemon_flags="-d" # bees') + output.should eq('-d') + end + + it "can parse a flag line with a bare word" do + output = described_class.parse_rc_line('daemon_flags=YES') + output.should eq('YES') + end + + it "can parse a flag line with a flag that contains an equals" do + output = described_class.parse_rc_line('daemon_flags="-Dbla -tmpdir=foo"') + output.should eq('-Dbla -tmpdir=foo') + end + end + + describe "#pkg_scripts" do + it "can retrieve the package_scripts array from rc.conf.local" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon cupsd"'] + expect(provider.pkg_scripts).to match_array(['dbus_daemon', 'cupsd']) + end + + it "returns an empty array when no pkg_scripts line is found" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.expects(:load_rcconf_local_array).returns ["#\n#\n#"] + expect(provider.pkg_scripts).to match_array([]) + end + end + + describe "#pkg_scripts_append" do + it "can append to the package_scripts array and return the result" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon"'] + expect(provider.pkg_scripts_append).to match_array(['dbus_daemon', 'cupsd']) + end + + it "should not duplicate the script name" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="cupsd dbus_daemon"'] + expect(provider.pkg_scripts_append).to match_array(['dbus_daemon', 'cupsd']) + end + end + + describe "#pkg_scripts_remove" do + it "can append to the package_scripts array and return the result" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon cupsd"'] + expect(provider.pkg_scripts_remove).to match_array(['dbus_daemon']) + end + + it "should not remove the script from the array unless its needed" do + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon"'] + expect(provider.pkg_scripts_remove).to match_array(['dbus_daemon']) + end + end + + describe "#set_content_flags" do + it "can create the necessary content where none is provided" do + content = [] + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.set_content_flags(content,'-d').should match_array(['cupsd_flags="-d"']) + end + + it "can modify the existing content" do + content = ['cupsd_flags="-f"'] + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + output = provider.set_content_flags(content,"-d") + output.should match_array(['cupsd_flags="-d"']) + end + end + + describe "#remove_content_flags" do + it "can remove the flags line from the requested content" do + content = ['cupsd_flags="-d"'] + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + output = provider.remove_content_flags(content) + output.should_not match_array(['cupsd_flags="-d"']) + end + end + + describe "#set_content_scripts" do + it "should append to the list of scripts" do + content = ['pkg_scripts="dbus_daemon"'] + scripts = ['dbus_daemon','cupsd'] + provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd')) + provider.set_content_scripts(content,scripts).should match_array(['pkg_scripts="dbus_daemon cupsd"']) + end + end end