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
15 views
15 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 (30) 5

Your answer

Preview

Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
By submitting this post you agree to our Terms & Conditions.
To avoid this verification in future, please log in or register.

1 Answer

0 votes
 
Best answer

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 (30) 5
...