Possible bug with the :disable service action declaration


#1

I believe I have either found a bug or perhaps need better guidance with
regards to the :disable service action declaration. I was not clear if this is
the correct list for this question.

In my scenario I am making a service definition to disable AppArmor on an
Ubuntu 12.04 server. I want to stop the process (which requires teardown to
dump the profiles and stop to dump the cache) and then disable it. The
AppArmor software does not run in the process list so I have to use the status.
This block of code did not function properly.

service "apparmor" do
  stop_command "/etc/init.d/apparmor teardown && /etc/init.d/apparmor stop"
  action [:stop, :disable]
  supports [:status]
  ignore_failure true
end

The :stop ran and did the teardown and stop functions as expected. The problem
was when the :disable part ran it first checked the service status to see if it
was running. Since it had already been stopped the service was no longer
running and the status returns an error code of 2. This caused the :disable to
be skipped. To work around this I have had to break my service declaration
into two parts. This block of code functions properly, in that it first
disables the service and then does the teardown and stop afterwards.

service "apparmor_disable" do
  service_name "apparmor"
  action [:disable]
  supports [:status]
  ignore_failure true
end

service "apparmor_teardown" do
  service_name "apparmor"
  stop_command "/etc/init.d/apparmor teardown && /etc/init.d/apparmor stop"
  action [:stop]
  supports [:status]
  ignore_failure true
end

Is this proper behavior for the :disable service action? Is it supposed to
check to see if the service is running before disabling? This effectively
makes it impossible to have service actions of :stop and :disable function
together.

Thanks,

Jeremy