连接到另一台机器后重新启动服务
我对厨师是新手,并且正在为这个概念而努力 - 我不确定它是否可行,如果是,如何实现它。 迄今为止Google Fu已经让我失望了。
我有一个厨师客户和厨师服务器,我正在上传食谱来在我的客户端上运行。 我通过在厨师客户机上运行chef-client来触发代码。
然后我试图做的是通过SSH连接到其他几个盒子,然后停止服务,清除一个目录并重新启动服务。
在工作时,我将针对Solr服务
我的基本测试代码如下所示:
ruby_block 'do something' do
block do
Chef::Log.info('Do Something')
Chef::Resource::Notification.new('stop', :run, self)
end
end
#define the service - does nothing
service 'atd' do
action :nothing
end
#do something that triggers
execute 'start' do
command 'pwd'
Chef::Log.info('triggers start')
action :nothing
notifies :start, run_context.resource_collection.find(:service => 'atd')
end
execute 'stop' do
# some stuff
# on success...
command 'pwd'
Chef::Log.info('triggers restart')
notifies :stop, run_context.resource_collection.find(:service => 'atd'), :immediately
notifies :run, 'execute[start]'
end
在红宝石方块中,我计划通过一系列我拥有并向他们ssh'ing的机器进行迭代。 那么是否有可能在这些机器上运行代码的其余部分?
感谢您的任何帮助/建议。
链接地址: http://www.djcxy.com/p/78317.html上一篇: restart a service on another machine after connecting to it