0

我已经生成了一个新模板,我将使用它来编辑 Nginx conf 文件。nginx.conf.erb 文件是在我的食谱的 Templates 文件夹中创建的,我已经对其进行了编辑以使其按照我的意愿配置 Nginx。在我的食谱中,我添加了以下内容,使其使用我的 nginx.conf.erb 模板更新我的 Nginx conf 文件:

template '/etc/nginx/conf.d/default.conf' do
  source 'nginx.conf.erb'
  user 'root'
  group 'root'
  mode '0644'
end

问题是当我运行“厨房收敛”并登录到 vagrant 实例时,我的 Nginx conf 文件(/etc/nginx/conf.d/default.conf)没有更新为我的 nginx.conf.erb 文件的内容. 收敛期间没有错误,并且配方中的其他所有内容似乎都已运行。ChefDK 不会让我在输出中向上滚动足够远以查看发生了什么。关于模板可能没有更新的原因或我可以在哪里找到可以为我提供融合的完整输出的日志的任何建议?

Chef 客户端输出(如下)引用了我想要对 Nginx conf 文件进行的更新,但是当我在收敛后登录时该文件没有更新。

I, [2016-12-21T16:33:22.524333 #6764]  INFO -- default-centos-67:   * template[/etc/nginx/conf.d/default.conf] action create
I, [2016-12-21T16:33:22.524333 #6764]  INFO -- default-centos-67:     - update content in file /etc/nginx/conf.d/default.conf from 2c3f71 to 348c91
I, [2016-12-21T16:33:22.524833 #6764]  INFO -- default-centos-67:     --- /etc/nginx/conf.d/default.conf    2016-10-31 12:37:31.000000000 +0000
I, [2016-12-21T16:33:22.524833 #6764]  INFO -- default-centos-67:     +++ /etc/nginx/conf.d/.chef-default20161221-2093-4qbcg9.conf  2016-12-21 21:33:21.094000001 +0000
I, [2016-12-21T16:33:22.524833 #6764]  INFO -- default-centos-67:     @@ -1,27 +1,52 @@
I, [2016-12-21T16:33:22.524833 #6764]  INFO -- default-centos-67:      #
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:     -# The default server
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:     +# The default WebCanada nginx front-end server
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:      #
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:      
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:     +
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:      server {
I, [2016-12-21T16:33:22.525333 #6764]  INFO -- default-centos-67:     -    listen       80 default_server;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     -    listen       [::]:80 default_server;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     -    server_name  _;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     -    root         /usr/share/nginx/html;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +    listen       80;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +    server_name  spgcravings.com www.spgcravings.com origin-www.spgcravings.com;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:      
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     -    # Load configuration files for the default server block.
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     -    include /etc/nginx/default.d/*.conf;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +    root '/var/www/vhosts/spg_cravings/httpdocs';
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:      
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +    location ~* \.php$ {
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +        proxy_pass http://127.0.0.1:8000;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +        proxy_set_header Host $host;
I, [2016-12-21T16:33:22.525833 #6764]  INFO -- default-centos-67:     +        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
I, [2016-12-21T16:33:22.526333 #6764]  INFO -- default-centos-67:     +    }
I, [2016-12-21T16:33:22.526333 #6764]  INFO -- default-centos-67:     +
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +    location /assets/ {
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +        gzip_static on;
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +    }
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:   location / {
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +        proxy_pass http://127.0.0.1:8000;
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +        proxy_set_header Host $host;
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:     +        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
I, [2016-12-21T16:33:22.531333 #6764]  INFO -- default-centos-67:   }
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +}
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:      
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     -    error_page 404 /404.html;
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     -        location = /40x.html {
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +server {
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +    listen       80;
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +    server_name  ihlgt.com www.ihlgt.com origin-www.ihlgt.com;
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +    root '/var/www/vhosts/ihlgt/httpdocs';
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +    location ~* \.php$ {
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +        proxy_pass http://127.0.0.1:8000;
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +        proxy_set_header Host $host;
I, [2016-12-21T16:33:22.531833 #6764]  INFO -- default-centos-67:     +        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:   }
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:      
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     -    error_page 500 502 503 504 /50x.html;
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     -        location = /50x.html {
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     +    location /assets/ {
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     +        gzip_static on;
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:   }
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:      
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     +    location / {
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     +        proxy_pass http://127.0.0.1:8000;
I, [2016-12-21T16:33:22.532333 #6764]  INFO -- default-centos-67:     +        proxy_set_header Host $host;
I, [2016-12-21T16:33:22.536833 #6764]  INFO -- default-centos-67:     +        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
I, [2016-12-21T16:33:22.536833 #6764]  INFO -- default-centos-67:     +    }
I, [2016-12-21T16:33:22.536833 #6764]  INFO -- default-centos-67:      }
4

1 回答 1

1

完整的日志在.kitchen/logs/$instancename.log. 这将显示来自 chef-client 的输出。您还可以仔细检查您是否将模板文件放在正确的位置(尽管如果您不这样做可能会出错):(templates/nginx.conf.erb或者templates/default/nginx.conf.erb如果您仍在使用过时的default/子文件夹)。

于 2016-12-21T21:02:39.400 回答