【发布时间】:2015-03-14 02:15:57
【问题描述】:
我正在使用关于 chef 的 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$
【问题讨论】:
-
以 root 身份检查 apache2 状态的结果是否相同?即:
sudo service apache2 status -
没错,和“sudo service apache2 status”一样
-
ubuntu@chefnode:~$ sudo service apache2 status ● apache2.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead)
标签: ruby apache chef-infra