nginxchef-infrachef-recipechef-zerochef-template

Chef: 'kitchen converge' not sourcing new template


I've generated a new template which I will be using to edit a Nginx conf file. The nginx.conf.erb file is created in my cookbook's Templates folder and I have edited it to make it configure Nginx as I want to. In my recipe, I have then added the following to make it update my Nginx conf file using my nginx.conf.erb template:

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

The problem is when I run a 'kitchen converge' and login to the vagrant instance, my Nginx conf file (/etc/nginx/conf.d/default.conf) is not updated to the content of my nginx.conf.erb file. There is no errors during the converge and it appears that everything else in the recipe has been ran. The ChefDK won't let me scroll far enough up through the output to see what happened. Any suggestions on why the template might have not updated or where I can find logs that will give me the full output from the converge?

Chef client output (below) quotes the updates which I want to be made to the Nginx conf file but the file isn't updated when I login after the converge.

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:      }

Solution

  • The full log is in .kitchen/logs/$instancename.log. That will show you the output from chef-client. You can also double check that you put the template file in the right place (though it would probably error if you didn't): templates/nginx.conf.erb (or templates/default/nginx.conf.erb if you're still using the outdated default/ subfolder).