0

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:      }
Stephen Walsh
  • 815
  • 4
  • 18
  • 34

1 Answers1

1

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).

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • thanks for the suggestions. But in my .kitchen/logs folder, there is just a kitchen.log file which only contains a few errors with a timestamp of last month on them, nothing from my recent converges. Yes, when I generated the template file, it was put in templates/nginx.conf.erb – Stephen Walsh Dec 21 '16 at 21:08
  • 1
    Did you run a `kitchen destroy`? That also removes the logs. – coderanger Dec 21 '16 at 21:22
  • ok, I was looking in the wrong .kitchen/logs folder and I've found the chef-client output now. I've updated the question with the output for the part of my recipe that sources the template, but my Nginx conf file still isn't being updated, even though the output quotes the updates which I want to made. – Stephen Walsh Dec 22 '16 at 14:22
  • 1
    Look below that and make sure another resource isn't changing it back. – coderanger Dec 22 '16 at 19:03