Problem with web_tools / app role interaction

137 views
Skip to first unread message

Chris

unread,
May 15, 2012, 4:33:26 AM5/15/12
to rubbe...@googlegroups.com
I'm getting the following error on my app server when trying to deploy
after creating a web_tools instance.

** [out :: app01.mydomain.com] nginx: [emerg] open()
"/etc/nginx/rubber/tools.conf" failed (2: No such file or directory)
in /etc/nginx/nginx.conf:60

From my instance-production.yml file (I've :

- !ruby/object:Rubber::Configuration::InstanceItem
name: webtools
domain: mydomain.com
roles:
- !ruby/object:Rubber::Configuration::RoleItem
name: web_tools
options: {}
- !ruby/object:Rubber::Configuration::RoleItem
name: resque_web
options: {}
- !ruby/object:Rubber::Configuration::RoleItem
name: collectd
options: {}
- !ruby/object:Rubber::Configuration::RoleItem
name: monit
options: {}
instance_id: i-8d3ea8eb
image_type: m1.small
image_id: ami-3c994355
security_groups:
- myapp_production_default
- myapp_production_web_tools
- myapp_production_webtools
- myapp_production_resque_web
- myapp_production_collectd
- myapp_production_monit

- !ruby/object:Rubber::Configuration::InstanceItem
name: app01
domain: mydomain.com
roles:
- !ruby/object:Rubber::Configuration::RoleItem
name: app
options: {}
- !ruby/object:Rubber::Configuration::RoleItem
name: passenger_nginx
options: {}
- !ruby/object:Rubber::Configuration::RoleItem
name: collectd
options: {}
- !ruby/object:Rubber::Configuration::RoleItem
name: monit
options: {}
instance_id: i-79b47a1f
image_type: m1.small
image_id: ami-3c994355
security_groups:
- myapp_production_default
- myapp_production_app01
- myapp_production_app
- myapp_production_passenger_nginx
- myapp_production_collectd
- myapp_production_monit

Obviously the tools config information isn't being copied to the app
servers (which I assume is the correct and desired behavior).

I understand that this is the code that is adding the config:
<% if rubber_instances.for_role('web_tools').first %>
include /etc/nginx/rubber/tools.conf;
<% end %>

But that seems like it is just checking if ANY web_tools roles exist,
rather than checking if this particular instance has that role.

Am I missing something, or is this a bug that I just need to fix by
changing the above mentioned check? If it's a bug, what is the ideal
way of changing the code to ensure that it only happens on the
appropriate box?

Thanks,
Chris

Matthew Conway

unread,
May 15, 2012, 7:45:57 AM5/15/12
to rubbe...@googlegroups.com

Obviously the tools config information isn't being copied to the app
servers (which I assume is the correct and desired behavior).

I understand that this is the code that is adding the config:
 <% if rubber_instances.for_role('web_tools').first %>
   include /etc/nginx/rubber/tools.conf;
 <% end %>

But that seems like it is just checking if ANY web_tools roles exist,
rather than checking if this particular instance has that role.

I'm not familiar with the nginx templates, so couldn't say for sure, but your analysis is correct.  I only really test with what I use - complete_passenger_postgresql

Am I missing something, or is this a bug that I just need to fix by
changing the above mentioned check?  If it's a bug, what is the ideal
way of changing the code to ensure that it only happens on the
appropriate box?

For an example of how to check if the current instance has a role, take a look at https://github.com/wr0ngway/rubber/blob/master/templates/collectd/config/rubber/role/collectd/collectd-ping.conf

Like all software, rubber has evolved over time.  Commonly used templates like apache have become more generic, so the apache template itself doesn't do much than the core apache setup. Its left up to templates that depend on it (passenger, graylog_web, graphite_web, etc) to do the configuration of apache that makes it useful for that role by adding supplemental config.  In apache's case, this is typically done by adding a vhost in a way that it doesn't have to mess with the core apache config files (follows the ubuntu pattern of sticking config files in an autoload directory).  The nginx templates should move more to that pattern - accepting pull requests :)

Matt

Gordon McNaughton

unread,
May 16, 2012, 1:45:49 AM5/16/12
to rubber
Hey Chris,

I ran into the same problem using web_tools with
complete_passenger_nginx. The fix was to change this line:

<% if rubber_instances.for_role('web_tools').first %>

to the following:

<% if rubber_instances[rubber_env.host].role_names.include?
('web_tools') %>

My install is a couple versions out of date (2.0.0-pre12), but the
web_tools role has (or had) other problems with nginx (two off the top
of my head: graphite_web required apache, which fights with nginx over
port 80; also nginx conf files didn't respect web_tools_proxies
settings, so a lot of the links on the web_tools home page were
broken). Not sure whether any of these have been fixed in 2.0.3!

-Gordon

Chris

unread,
May 17, 2012, 4:24:50 AM5/17/12
to rubbe...@googlegroups.com
Gordan/Matt,
Thank you for the replies. Gordon's suggestion for the fix worked
great for solving the error, but I still can't seem to use the web
tools.

So another question: What _exactly_ do I need to specify when
creating the web_tools instance in order for it to work? (ie. Do I
need to do anything more than "ALIAS=webtools01 ROLES=web_tools cap
rubber:create"?) Obviously I need to bootstrap and deploy, but do I
need to add any additional roles?

I ask because so far I haven't been able to make it work. All my
other instances so far seem to be fine.

Thanks again,
Chris
> --
> You received this message because you are subscribed to the Google Groups "rubber" group.
> To post to this group, send email to rubbe...@googlegroups.com.
> To unsubscribe from this group, send email to rubber-ec2+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubber-ec2?hl=en.
>

Matthew Conway

unread,
May 17, 2012, 6:21:49 AM5/17/12
to rubbe...@googlegroups.com

On May 17, 2012, at 4:24 AM, Chris wrote:

> Gordan/Matt,
> Thank you for the replies. Gordon's suggestion for the fix worked
> great for solving the error, but I still can't seem to use the web
> tools.
>
> So another question: What _exactly_ do I need to specify when
> creating the web_tools instance in order for it to work? (ie. Do I
> need to do anything more than "ALIAS=webtools01 ROLES=web_tools cap
> rubber:create"?) Obviously I need to bootstrap and deploy, but do I
> need to add any additional roles?

Thats the way its supposed to work - and does for the complete_passenger_postgresql template. The web_tools role actually expands into multiple other roles through the role_dependencies mechanism in rubber. It could be that isn't setup for the templates you are using…? If I have a chance I'll take a look using those templates, but it might be quicker if you are able to debug it :)

It may be useful for you to bring up a dummy app webtools instance with the complete_passenger_postgresql template and use that to compare against what is happening with yours.

Matt


Chris

unread,
May 17, 2012, 6:41:03 AM5/17/12
to rubbe...@googlegroups.com
Matt,
Thanks for the reply. It very well could be the templates that I'm
using. I'll have to play with the apache version and see if I can get
it working and then figure out the differences. I didn't want to do
that if it was just a matter of me not specifying the right
combination of roles.

I went the nginx route because I eventually plan on removing the
passenger portions and use unicorn instead, but I thought I shouldn't
change too many variables at once. :-)

I'm slowly getting up to speed with this whole thing. One day I may
even feel comfortable enough with it to adjust the templates and start
sending pull requests. I'm not there yet though.

Thanks again,
Chris
Reply all
Reply to author
Forward
0 new messages