Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
189 views
189 views

We created a new service provider for Puppet. However, when using that provider the service keeps getting (re-)enabled with every Puppet run:

Notice: /Stage[main]/Profiles::Base/Service[foo]/enable: enable changed 'true' to 'true'

Debug output shows that the service already is enabled (and running), but it's still getting enabled again:

Debug: Executing: '/usr/bin/svctl isup foo'
Debug: foo is running
Debug: Executing: '/usr/bin/svctl isenabled foo'
Debug: foo is enabled
Debug: Executing: '/usr/bin/svctl enable foo'
Debug: Executing: '/usr/bin/svctl update'
Debug: foo has been enabled
Notice: /Stage[main]/Profiles::Base/Service[foo]/enable: enable changed 'true' to 'true'

These are the relevant parts of the provider code:

commands :svctl => "svctl"

# ... 

def enabled?
  begin
    svctl(["isenabled", @resource[:name]])
    return true
  rescue Puppet::ExecutionFailure => e
    if $?.exitstatus == 1
      return false
    else
      return nil 
    end 
  end 
end 

def enable
  begin
    svctl(["enable", @resource[:name]])
    self.updatecmd
  rescue Puppet::ExecutionFailure => e
    return nil 
  end 
end 
in Scripting
by (115)
2 19 33
edit history

Please log in or register to answer this question.

1 Answer

0 votes
 

Turns out, the problem was that the provider's enabled? method returned the objects true/false instead of the symbols :true/:false (note the leading colons).

After changing true and false to :true and :false respectively, the problem disappeared.

by (115)
2 19 33
edit history
...