How to configure opscode nginx properly


#1

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


#2

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


#3

Hmm, I am not really sure where and why I should add “chef-server”. But after all my desperate attempts I have commited a wrapper cookbook for nginx to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to a custom location everything seems to fall apart again. The nginx cookbook always installs the default config, even if it has been told to not do so. This has really started to get frustrating. :frowning: So, any help is really appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


#4

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But after all my desperate attempts I have commited a wrapper cookbook for nginx to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to a custom location everything seems to fall apart again. The nginx cookbook always installs the default config, even if it has been told to not do so. This has really started to get frustrating. :frowning: So, any help is really appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#5

Thanks for your reply. However telling the wrapper cookbook that it should use the nginx default template is exactly the opposite of what I want.
I want to use my own config instead of the default config that is bundled with the nginx cookbook.
So, to what I understand, it should work if I set ‘default_site_enabled’ to false, which should prevent the default config from being used. However, for what I have been trying this does not seem to work.
Anyway, I resorted to leaving everything in its default location, which seems to at least solve that problem. Not the best solution, but at least it seems to work. I still haven’t been able to figure out how that part of the cookbook is supposed to work… Looks pretty scary to me, but I am still pretty new to chef.

On 21 Apr 2014, at 07:28, DV vindimy@gmail.com wrote:

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But after all my desperate attempts I have commited a wrapper cookbook for nginx to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to a custom location everything seems to fall apart again. The nginx cookbook always installs the default config, even if it has been told to not do so. This has really started to get frustrating. :frowning: So, any help is really appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#6

No, what I’m saying is that your template definition should look like this:

template “#{node[‘nginx’][‘dir’]}/sites-available/#{params[:name]}” do
source 'wrapper_site.erb’
owner 'root’
group 'root’
mode '0644’
notifies :reload, 'service[nginx]'
variables ({:site => params[:name], :port => params[:port],
:autoindex => params[:autoindex]})
cookbook "nginx"
end

I believe this way you’re telling Chef that you’re overriding a
template from “nginx” cookbook, so it won’t get all confused.

On Mon, Apr 21, 2014 at 4:08 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Thanks for your reply. However telling the wrapper cookbook that it should use the nginx default template is exactly the opposite of what I want.
I want to use my own config instead of the default config that is bundled with the nginx cookbook.
So, to what I understand, it should work if I set ‘default_site_enabled’ to false, which should prevent the default config from being used. However, for what I have been trying this does not seem to work.
Anyway, I resorted to leaving everything in its default location, which seems to at least solve that problem. Not the best solution, but at least it seems to work. I still haven’t been able to figure out how that part of the cookbook is supposed to work… Looks pretty scary to me, but I am still pretty new to chef.

On 21 Apr 2014, at 07:28, DV vindimy@gmail.com wrote:

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But after all my desperate attempts I have commited a wrapper cookbook for nginx to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to a custom location everything seems to fall apart again. The nginx cookbook always installs the default config, even if it has been told to not do so. This has really started to get frustrating. :frowning: So, any help is really appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#7

Yes, that is exactly what I had tried. The docs say the following:

“cookbook: The cookbook in which a file is located (if it is not located in the current cookbook). The default value is the current cookbook.”

I noticed that if I specify what you propose, chef looks for the template in the specified cookbook, which to my understand lines up with the docs. So using ‘cookbook “nginx”’, tells chef to look for the template in the nginx cookbook instead of the wrapper.
What I actually would need to do is modify the nginx cookbook to have ‘cookbook “wrapper-nginx”’ inside the definition, but that wouldn’t make much sense.
But I see there is a big refactoring planned for that cookbook [1] anyway. I think I will file a bug against the ‘default_site_enabled’ option nonetheless.

[1] https://tickets.opscode.com/browse/COOK-2781

On 22 Apr 2014, at 00:09, DV vindimy@gmail.com wrote:

No, what I’m saying is that your template definition should look like this:

template “#{node[‘nginx’][‘dir’]}/sites-available/#{params[:name]}” do
source 'wrapper_site.erb’
owner 'root’
group 'root’
mode '0644’
notifies :reload, 'service[nginx]'
variables ({:site => params[:name], :port => params[:port],
:autoindex => params[:autoindex]})
cookbook "nginx"
end

I believe this way you’re telling Chef that you’re overriding a
template from “nginx” cookbook, so it won’t get all confused.

On Mon, Apr 21, 2014 at 4:08 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Thanks for your reply. However telling the wrapper cookbook that it should use the nginx default template is exactly the opposite of what I want.
I want to use my own config instead of the default config that is bundled with the nginx cookbook.
So, to what I understand, it should work if I set ‘default_site_enabled’ to false, which should prevent the default config from being used. However, for what I have been trying this does not seem to work.
Anyway, I resorted to leaving everything in its default location, which seems to at least solve that problem. Not the best solution, but at least it seems to work. I still haven’t been able to figure out how that part of the cookbook is supposed to work… Looks pretty scary to me, but I am still pretty new to chef.

On 21 Apr 2014, at 07:28, DV vindimy@gmail.com wrote:

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But after all my desperate attempts I have commited a wrapper cookbook for nginx to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to a custom location everything seems to fall apart again. The nginx cookbook always installs the default config, even if it has been told to not do so. This has really started to get frustrating. :frowning: So, any help is really appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default sample config. So, on every chef run the nginx cookbook notices that the default config is no longer there and replaces my config, then my wrapper cookbook notices that the config is not correct and replaces that file with my config again.
I was having the same issues when installing from source as well as using the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something fundamentally or a lot of other people must have been running into the same issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#8

What I think template’s “cookbook” parameter does is allow you to
override templates from other cookbooks. But I’ve never tested it
myself so I don’t know for sure. So if you have a template definition
in your wrapper cookbook, and set the template definition’s "cookbook"
parameter to “some-other-cookbook”, it would allow you to override
some-other-cookbook’s template.

On Tue, Apr 22, 2014 at 3:55 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Yes, that is exactly what I had tried. The docs say the following:

“cookbook: The cookbook in which a file is located (if it is not located in
the current cookbook). The default value is the current cookbook.”

I noticed that if I specify what you propose, chef looks for the template in
the specified cookbook, which to my understand lines up with the docs. So
using ‘cookbook “nginx”’, tells chef to look for the template in the nginx
cookbook instead of the wrapper.
What I actually would need to do is modify the nginx cookbook to have
‘cookbook “wrapper-nginx”’ inside the definition, but that wouldn’t make
much sense.
But I see there is a big refactoring planned for that cookbook [1] anyway. I
think I will file a bug against the ‘default_site_enabled’ option
nonetheless.

[1] https://tickets.opscode.com/browse/COOK-2781

On 22 Apr 2014, at 00:09, DV vindimy@gmail.com wrote:

No, what I’m saying is that your template definition should look like this:

template “#{node[‘nginx’][‘dir’]}/sites-available/#{params[:name]}” do
source 'wrapper_site.erb’
owner 'root’
group 'root’
mode '0644’
notifies :reload, 'service[nginx]'
variables ({:site => params[:name], :port => params[:port],
:autoindex => params[:autoindex]})
cookbook "nginx"
end

I believe this way you’re telling Chef that you’re overriding a
template from “nginx” cookbook, so it won’t get all confused.

On Mon, Apr 21, 2014 at 4:08 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Thanks for your reply. However telling the wrapper cookbook that it should
use the nginx default template is exactly the opposite of what I want.
I want to use my own config instead of the default config that is bundled
with the nginx cookbook.
So, to what I understand, it should work if I set ‘default_site_enabled’ to
false, which should prevent the default config from being used. However, for
what I have been trying this does not seem to work.
Anyway, I resorted to leaving everything in its default location, which
seems to at least solve that problem. Not the best solution, but at least it
seems to work. I still haven’t been able to figure out how that part of the
cookbook is supposed to work… Looks pretty scary to me, but I am still
pretty new to chef.

On 21 Apr 2014, at 07:28, DV vindimy@gmail.com wrote:

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But
after all my desperate attempts I have commited a wrapper cookbook for nginx
to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It
initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to
a custom location everything seems to fall apart again. The nginx cookbook
always installs the default config, even if it has been told to not do so.
This has really started to get frustrating. :frowning: So, any help is really
appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the
opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by
putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default
sample config. So, on every chef run the nginx cookbook notices that the
default config is no longer there and replaces my config, then my wrapper
cookbook notices that the config is not correct and replaces that file with
my config again.
I was having the same issues when installing from source as well as using
the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something
fundamentally or a lot of other people must have been running into the same
issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#9

If you want to modify a template resource defined in another cookbook, I’d
recommend looking at
http://www.getchef.com/blog/2013/12/03/doing-wrapper-cookbooks-right/ and
chef-rewind https://github.com/bryanwb/chef-rewind.

You want to set the “cookbook” value to the cookbook which contains the
template source that you want to use, i.e. “wrapper-nginx”.

On Wed, Apr 23, 2014 at 10:31 PM, DV vindimy@gmail.com wrote:

What I think template’s “cookbook” parameter does is allow you to
override templates from other cookbooks. But I’ve never tested it
myself so I don’t know for sure. So if you have a template definition
in your wrapper cookbook, and set the template definition’s "cookbook"
parameter to “some-other-cookbook”, it would allow you to override
some-other-cookbook’s template.

On Tue, Apr 22, 2014 at 3:55 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Yes, that is exactly what I had tried. The docs say the following:

“cookbook: The cookbook in which a file is located (if it is not located
in
the current cookbook). The default value is the current cookbook.”

I noticed that if I specify what you propose, chef looks for the
template in
the specified cookbook, which to my understand lines up with the docs. So
using ‘cookbook “nginx”’, tells chef to look for the template in the
nginx
cookbook instead of the wrapper.
What I actually would need to do is modify the nginx cookbook to have
‘cookbook “wrapper-nginx”’ inside the definition, but that wouldn’t make
much sense.
But I see there is a big refactoring planned for that cookbook [1]
anyway. I
think I will file a bug against the ‘default_site_enabled’ option
nonetheless.

[1] https://tickets.opscode.com/browse/COOK-2781

On 22 Apr 2014, at 00:09, DV vindimy@gmail.com wrote:

No, what I’m saying is that your template definition should look like
this:

template “#{node[‘nginx’][‘dir’]}/sites-available/#{params[:name]}” do
source 'wrapper_site.erb’
owner 'root’
group 'root’
mode '0644’
notifies :reload, 'service[nginx]'
variables ({:site => params[:name], :port => params[:port],
:autoindex => params[:autoindex]})
cookbook "nginx"
end

I believe this way you’re telling Chef that you’re overriding a
template from “nginx” cookbook, so it won’t get all confused.

On Mon, Apr 21, 2014 at 4:08 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Thanks for your reply. However telling the wrapper cookbook that it
should
use the nginx default template is exactly the opposite of what I want.
I want to use my own config instead of the default config that is bundled
with the nginx cookbook.
So, to what I understand, it should work if I set ‘default_site_enabled’
to
false, which should prevent the default config from being used. However,
for
what I have been trying this does not seem to work.
Anyway, I resorted to leaving everything in its default location, which
seems to at least solve that problem. Not the best solution, but at
least it
seems to work. I still haven’t been able to figure out how that part of
the
cookbook is supposed to work… Looks pretty scary to me, but I am still
pretty new to chef.

On 21 Apr 2014, at 07:28, DV vindimy@gmail.com wrote:

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But
after all my desperate attempts I have commited a wrapper cookbook for
nginx
to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It
initially appeared to work fine, but after I had set the
[‘nginx’][‘dir’] to
a custom location everything seems to fall apart again. The nginx
cookbook
always installs the default config, even if it has been told to not do
so.
This has really started to get frustrating. :frowning: So, any help is really
appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the
opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by
putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the
default
sample config. So, on every chef run the nginx cookbook notices that the
default config is no longer there and replaces my config, then my wrapper
cookbook notices that the config is not correct and replaces that file
with
my config again.
I was having the same issues when installing from source as well as using
the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something
fundamentally or a lot of other people must have been running into the
same
issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


John Schnare
Network Operations and Software Engineer
Kano Applications Inc http://www.kanoapps.com/
539 Herald St
Victoria, BC V8W 1S5
(250) 590-5266 [office]
(250) 216-6058 [cell]
John.Schnare@kanoapps.com


#10

Thanks, John. That seems to work really well.
However the real reason for that issue being that the opscode cookbook seems to ignore the configuration which tells if it should install the default sites or not. I was kinda hoping that someone on the list uses the nginx cookbook and could give some input wether this is a configuration issue or indeed a bug.
But overriding the template definition solves my issue pretty well for now

On 24 Apr 2014, at 19:20, John Schnare john.schnare@kanoapps.com wrote:

If you want to modify a template resource defined in another cookbook, I’d recommend looking at http://www.getchef.com/blog/2013/12/03/doing-wrapper-cookbooks-right/ and chef-rewind.

You want to set the “cookbook” value to the cookbook which contains the template source that you want to use, i.e. “wrapper-nginx”.

On Wed, Apr 23, 2014 at 10:31 PM, DV vindimy@gmail.com wrote:
What I think template’s “cookbook” parameter does is allow you to
override templates from other cookbooks. But I’ve never tested it
myself so I don’t know for sure. So if you have a template definition
in your wrapper cookbook, and set the template definition’s "cookbook"
parameter to “some-other-cookbook”, it would allow you to override
some-other-cookbook’s template.

On Tue, Apr 22, 2014 at 3:55 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Yes, that is exactly what I had tried. The docs say the following:

“cookbook: The cookbook in which a file is located (if it is not located in
the current cookbook). The default value is the current cookbook.”

I noticed that if I specify what you propose, chef looks for the template in
the specified cookbook, which to my understand lines up with the docs. So
using ‘cookbook “nginx”’, tells chef to look for the template in the nginx
cookbook instead of the wrapper.
What I actually would need to do is modify the nginx cookbook to have
‘cookbook “wrapper-nginx”’ inside the definition, but that wouldn’t make
much sense.
But I see there is a big refactoring planned for that cookbook [1] anyway. I
think I will file a bug against the ‘default_site_enabled’ option
nonetheless.

[1] https://tickets.opscode.com/browse/COOK-2781

On 22 Apr 2014, at 00:09, DV vindimy@gmail.com wrote:

No, what I’m saying is that your template definition should look like this:

template “#{node[‘nginx’][‘dir’]}/sites-available/#{params[:name]}” do
source 'wrapper_site.erb’
owner 'root’
group 'root’
mode '0644’
notifies :reload, 'service[nginx]'
variables ({:site => params[:name], :port => params[:port],
:autoindex => params[:autoindex]})
cookbook "nginx"
end

I believe this way you’re telling Chef that you’re overriding a
template from “nginx” cookbook, so it won’t get all confused.

On Mon, Apr 21, 2014 at 4:08 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Thanks for your reply. However telling the wrapper cookbook that it should
use the nginx default template is exactly the opposite of what I want.
I want to use my own config instead of the default config that is bundled
with the nginx cookbook.
So, to what I understand, it should work if I set ‘default_site_enabled’ to
false, which should prevent the default config from being used. However, for
what I have been trying this does not seem to work.
Anyway, I resorted to leaving everything in its default location, which
seems to at least solve that problem. Not the best solution, but at least it
seems to work. I still haven’t been able to figure out how that part of the
cookbook is supposed to work… Looks pretty scary to me, but I am still
pretty new to chef.

On 21 Apr 2014, at 07:28, DV vindimy@gmail.com wrote:

Try adding cookbook “nginx” to this template definition:

https://github.com/st-h/wrapper-nginx/blob/master/definitions/definition.rb#L23

You can see the template’s “cookbook” attribute description here:

http://docs.opscode.com/resource_template.html#attributes

On Sat, Apr 19, 2014 at 11:25 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

Hmm, I am not really sure where and why I should add “chef-server”. But
after all my desperate attempts I have commited a wrapper cookbook for nginx
to github: https://github.com/st-h/wrapper-nginx
It’s designed after an example I had gotten from #chef irc yesterday. It
initially appeared to work fine, but after I had set the [‘nginx’][‘dir’] to
a custom location everything seems to fall apart again. The nginx cookbook
always installs the default config, even if it has been told to not do so.
This has really started to get frustrating. :frowning: So, any help is really
appreciated…

On 19 Apr 2014, at 02:15, DV vindimy@gmail.com wrote:

Are you specifying “cookbook” property in your cookbook’s template
definition? Try specifying cookbook “chef-server” and see what
happens.

On Wed, Apr 16, 2014 at 10:40 AM, Steve Hummingbird
Steve.Hummingbird@yandex.com wrote:

I have been running into some issues when configuring nginx using the
opscode cookbook.
I have created a wrapper cookbook, which replaces the default config by
putting my config into /etc/nginx/sites-available/default
However, the opscode cookbook always replaces that config with the default
sample config. So, on every chef run the nginx cookbook notices that the
default config is no longer there and replaces my config, then my wrapper
cookbook notices that the config is not correct and replaces that file with
my config again.
I was having the same issues when installing from source as well as using
the ubuntu package installation.
So, in the end I am getting the feeling that I might be missing something
fundamentally or a lot of other people must have been running into the same
issue. How do I configure nginx the right way using the opscode cookbook?

Thanks,
Steve


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.


John Schnare
Network Operations and Software Engineer
Kano Applications Inc
539 Herald St
Victoria, BC V8W 1S5
(250) 590-5266 [office]
(250) 216-6058 [cell]
John.Schnare@kanoapps.com