[chef] Re: How to check that service is stopped, and if not - stop it ?


Chronological Thread 
  • From: Tensibai < >
  • To: < >
  • Subject: [chef] Re: How to check that service is stopped, and if not - stop it ?
  • Date: Wed, 16 Oct 2013 14:25:03 +0200

Bis from mail client bug ...

Le 2013-10-15 08:22, Vladimir Skubriev a écrit :

How to check that service is stopped, and if not - stop it ?

For example in this code block:


# See if needed 
http://stackoverflow.com/questions/14809840/installation-of-redmine-with-bundler-requires-root-password
bash "bundle_redmine_mylyn" do
   cwd 
"#{node['redmine']['datafs']}/redmine/plugins/redmine_mylyn_connector"
   user node['apache']['user']
   code <<-EOH
               # We doing source because of interactive shell don't read 
our .profile
               source #{node['redmine']['home']}/.rvm/scripts/rvm
               bundle install
   EOH
end


And Can write some not_if's only_if's for example

do
     not_if
     not_if
     only_if
     only_if
end

?

I would use notifications for this use case, something like:

bash "bundle_redmine_mylyn" do
   cwd 
"#{node['redmine']['datafs']}/redmine/plugins/redmine_mylyn_connector"
   user node['apache']['user']
   code <<-EOH
               # We doing source because of interactive shell don't read 
our .profile
               source #{node['redmine']['home']}/.rvm/scripts/rvm
               bundle install
   EOH
action :nothing
notifies :start, "service[apache2] end

 

service "apache2" do

 action :stop

 notifies :run, "bash[bundle_redmine_mylyn]"

end

 

More or less from memory so there may be syntax mistakes with notifications but the idea is there, if action :stop is too much it may be trigerred by another ressource (a dummy ruby_block just notyfing or anything else)

The major drawback I see from this way is that it is NOT idempotent and will do the same again and again at each chef-run if there's not way to test the install has to be done or not.

Regards,

Tensibai





 

 



Archive powered by MHonArc 2.6.16.

§