繁体   English   中英

厨师客户端无法启动服务

[英]chef-client does not start service

我在厨师上使用opscode教程来从食谱中启动服务。 服务是apache2,菜谱名为“ learn_chef_apache2”

package 'apache2'

service 'apache2' do
    action [:start, :enable]
end

template '/var/www/html/index.html' do
    source 'index.html.erb'
end

据我了解,如果尚未安装apache2,则应该安装它;如果尚未运行,请启动并启用apache2;并在/ var / www / html /文件夹中创建index.html文件。

这确实报告它已成功运行。 但是,这是我的结果。

akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo chef-client --local-mode --runlist 'recipe[learn_chef_apache2]'
[2015-03-13T22:13:55-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.0.3
resolving cookbooks for run list: ["learn_chef_apache2"]
Synchronizing Cookbooks:
  - learn_chef_apache2
Compiling Cookbooks...
Converging 3 resources
Recipe: learn_chef_apache2::default
  * apt_package[apache2] action install (up to date)
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)
  * template[/var/www/html/index.html] action create (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 0/4 resources updated in 1.916971556 seconds
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ service apache2 status * apache2 is not running
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ 

可以在以下位置找到该教程: https : //learn.chef.io/learn-the-basics/ubuntu/make-your-recipe-more-manageable/


akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ chef
chef         chef-apply   chef-client  chef-shell   chef-solo    
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ chef
chef         chef-apply   chef-client  chef-shell   chef-solo    
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ chef
chef         chef-apply   chef-client  chef-shell   chef-solo    
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ chef-client -v
Chef: 12.0.3
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ 

好像是通过配方或通过sudo service apache2 stop启动“停止”时sudo service apache2 stop

另一个配方将“不能”启动备份服务。 不必使用“启动”,而必须使用“重新启动”来使其工作。

    package 'apache2'

service 'apache2' do
    action [:stop, :enable]
end

template '/var/www/html/index.html' do
    source 'index.html.erb'
end

akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo chef-client --local-mode --runlist 'recipe[learn_chef_apache2]'
[2015-03-14T11:28:28-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.0.3
resolving cookbooks for run list: ["learn_chef_apache2"]
Synchronizing Cookbooks:
  - learn_chef_apache2
Compiling Cookbooks...
Converging 3 resources
Recipe: learn_chef_apache2::default
  * apt_package[apache2] action install (up to date)
  * service[apache2] action stop
    - stop service service[apache2]
  * service[apache2] action enable (up to date)
  * template[/var/www/html/index.html] action create (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 1/4 resources updated in 3.538150111 seconds
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ 
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo service apache2 status * apache2 is not running
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ 

在这里,我启动了“启动”操作,该操作无效。

package 'apache2'

service 'apache2' do
    action [:start, :enable]
end

template '/var/www/html/index.html' do
    source 'index.html.erb'
end

akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo chef-client --local-mode --runlist 'recipe[learn_chef_apache2]'
[2015-03-14T11:35:43-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.0.3
resolving cookbooks for run list: ["learn_chef_apache2"]
Synchronizing Cookbooks:
  - learn_chef_apache2
Compiling Cookbooks...
Converging 3 resources
Recipe: learn_chef_apache2::default
  * apt_package[apache2] action install (up to date)
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)
  * template[/var/www/html/index.html] action create (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 0/4 resources updated in 2.524905132 seconds
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo service apache2 status * apache2 is not running
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ 

在这里,我执行了一个“重新启动”,它起作用了。

package 'apache2'

service 'apache2' do
    action [:restart, :enable]
end

template '/var/www/html/index.html' do
    source 'index.html.erb'
end

akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo chef-client --local-mode --runlist 'recipe[learn_chef_apache2]'
[2015-03-14T11:32:52-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.0.3
resolving cookbooks for run list: ["learn_chef_apache2"]
Synchronizing Cookbooks:
  - learn_chef_apache2
Compiling Cookbooks...
Converging 3 resources
Recipe: learn_chef_apache2::default
  * apt_package[apache2] action install (up to date)
  * service[apache2] action restart
    - restart service service[apache2]
  * service[apache2] action enable (up to date)
  * template[/var/www/html/index.html] action create (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 1/4 resources updated in 3.468081078 seconds
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ sudo service apache2 status
 * apache2 is running
akhter@akhter-GA-990FXA-UD3:~/chef-repo/cookbooks$ 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM