의존성으로 yum 요리 책을 사용하여 CentOS 컴퓨터에 nginx를 설치하려고합니다.Chef :: Exceptions :: Exec :/bin/systemctl start nginx가 1을 반환했습니다. 0
이것은
#
# Cookbook Name:: nginxl
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "yum"
case node["platform"] #Create Yum Repository for Nginx
when "redhat"
yum_repository "nginx" do
name 'nginx_repo'
baseurl 'http://nginx.org/packages/rhel/7/$basearch/';
enabled true
gpgcheck false
action :create
end
when "centos"
yum_repository "nginx" do
name 'nginx_repo'
baseurl 'http://nginx.org/packages/centos/7/$basearch/';
enabled true
gpgcheck false
action :create
end
end
package "nginx" do #Install Nginx package
version "1.6.2-1.el7.ngx"
action :install
end
template "nginx.conf" do #Create Nginx Configuration in the specified path
source "nginx.conf.erb"
path "#{node['nginx']['dir']}/nginx.conf"
action :create
mode 0644
end
template "default.conf" do #Create SSL,Proxy,Logs configuration in the specified path
source "default.conf.erb"
path "#{node['nginx']['dir']}/conf.d/default.conf"
action :create
mode 0644
end
directory "#{node['nginx']['ssl_directory']}" do
action :create
end
cookbook_file "nginx.crt" do #Drops the SSL Certificate from Files to the specified path.
path "#{node['nginx']['ssl_directory']}/nginx.crt"
action :create
end
cookbook_file "nginx.key" do #Drops the SSL Key from Files to the specified path.
path "#{node['nginx']['ssl_directory']}/nginx.key"
action :create
end
service "nginx" do
supports :restart => :true
action [:enable, :start]
end
에 클라이언트 서버에서 'sudo는 요리사 클라이언트'를 실행하려고, 내 nginx를/조리법/default.rb의 모습, 나는 다음과 같은 오류 얻을 :
[centos[email protected] ~]$ sudo chef-client
[2015-01-02T05:49:19+00:00] WARN:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.
To fix this issue add an entry like this to your configuration file:
```
# Verify all HTTPS connections (recommended)
ssl_verify_mode :verify_peer
# OR, Verify only connections to chef-server
verify_api_cert true
```
To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:
```
knife ssl check -c /etc/chef/client.rb
```
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Starting Chef Client, version 11.16.4
resolving cookbooks for run list: ["yum", "nginx"]
Synchronizing Cookbooks:
- yum
- nginx
Compiling Cookbooks...
Converging 9 resources
Recipe: yum::default
* yum_globalconfig[/etc/yum.conf] action create
* template[/etc/yum.conf] action create (up to date)
(up to date)
Recipe: nginx::default
* yum_repository[nginx_repo] action create
* template[/etc/yum.repos.d/nginx_repo.repo] action create (up to date)
* execute[yum-makecache-nginx_repo] action nothing (skipped due to action :nothing)
* ruby_block[yum-cache-reload-nginx_repo] action nothing (skipped due to action :nothing)
(up to date)
* package[nginx] action install (up to date)
* template[nginx.conf] action create (up to date)
* template[default.conf] action create (up to date)
* directory[/etc/nginx/ssl] action create (up to date)
* cookbook_file[nginx.crt] action create (up to date)
* cookbook_file[nginx.key] action create (up to date)
* service[nginx] action enable (up to date)
* service[nginx] action start
================================================================================
Error executing action `start` on resource 'service[nginx]'
================================================================================
Chef::Exceptions::Exec
----------------------
/bin/systemctl start nginx returned 1, expected 0
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/nginx/recipes/default.rb
67: service 'nginx' do
68: supports :restart => :true
69: action [:enable, :start]
70: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/nginx/recipes/default.rb:67:in `from_file'
service("nginx") do
provider Chef::Provider::Service::Systemd
action [:enable, :start]
supports {:restart=>:true}
retries 0
retry_delay 2
guard_interpreter :default
service_name "nginx"
enabled true
pattern "nginx"
cookbook_name "nginx"
recipe_name "default"
end
Running handlers:
[2015-01-02T05:49:21+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-01-02T05:49:21+00:00] ERROR: Exception handlers complete
[2015-01-02T05:49:21+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 2.227299679 seconds
[2015-01-02T05:49:21+00:00] ERROR: service[nginx] (nginx::default line 67) had an error:
Chef::Exceptions::Exec: /bin/systemctl start nginx returned 1, expected 0
[2015-01-02T05:49:21+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
을
편집 : 내 nginx.conf에서 디렉토리 lisitng에 대한 코드 조각 아래에 추가하는 경우에만 발생
server {
listen 443;
server_name <%= node['nginx']['server_name'] %>;
location/{
source <%= node['nginx']['source'] %>;
autoindex on;
}
}
nginx 로그 란 무엇입니까? 서비스가 시작될 수없는 것 같습니다. 특성이 없거나 인증서가있는 것으로 인해 구성에서 잘못된 지시문 (아마도 cert 파일의 소유자 또는 모드를 설정하지 않은 것입니다. 확실하지는 않습니다. nginx에서 허용합니다). – Tensibai
잘 실행되지만 nginx.conf 파일에 아래 코드를 추가하면 문제가 나타납니다 : 'server { listen 443; server_name <% = node [ 'nginx'] [ 'server_name'] %>; 위치/{ 소스 <% = node [ 'nginx'] [ 'source'] %>; 자동 색인 사용; } } ' –
질문을 수정하십시오. 코드 서식과 주석이 엉망이므로 읽으십시오. 속성이 올바르게 정의되어 있고 node [ 'nginx'] [ 'server_name']'이이 서버의 IP로 올바르게 해석됩니까? Chef가 예상 한 것을 실행 한 후 결과 구성이 시작되고 시작되지 않으면 nginx 오류 로그에 무엇이 있습니까? 나는 그것이 틀린 것을 당신에게 말할 것이라고 꽤 확신한다. – Tensibai