Ask Your Question
1

Add RailsEnv to VirtualHost

asked 2014-01-10 16:45:46 -0500

André Ricardo gravatar image

Hello, I have the following virtual host configuration for Apache

apache::vhost { 'apiuat.example.com':
    priority        => '10',
    vhost_name      => '',
    port            => '80',
    docroot         => '/home/uat/my_app/current/public',
    logroot         => '/home/uat/my_app/current/log',
    serveradmin     => 'info@example.com',
}

How can I add "RailsEnv staging" to my /etc/httpd/conf.d/10-apiuat.example.com.conf? Like so:

<VirtualHost>
  (...)
  DocumentRoot /home/uat/my_app/current/public/
  <Directory /home/uat/my_app/current/public/>
  (...)
  </Directory>
  RailsEnv staging
</VirtualHost>
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2014-01-12 11:31:50 -0500

Jeff Johnson gravatar image

updated 2014-01-12 11:37:54 -0500

I struggled with this for awhile myself. I tried using the apache::vhost directories, but I wasn't having much luck. Once I got my virtual host file set up the "old-fashioned" way (i.e. by hand), I created a template that would set the RailsEnv along with any other settings I need.

EDIT: I'm by no means an apache configuration guru, so there may be some settings in the template below that aren't required to run a Rails app with apache and passenger. The file below works for me, so your mileage may vary.

/etc/puppetlabs/puppet ... (more)

edit flag offensive delete link more

Comments

seems like a rather complex solution just to add the RailsEnv, I will try it and see it if works to accept the solution. Thank you.

André Ricardo gravatar imageAndré Ricardo ( 2014-01-31 07:57:01 -0500 )edit
1

answered 2014-01-13 13:17:25 -0500

ramindk gravatar image

JeffJohnson answered the question in a technical way. However I'd like to answer the meta question of how to build vhosts in general.

The problem is that any apache::vhost implementation can not deal with the thousands of config options Apache supports. In fact I think it's wrong to even try to handle it in a generic module.

What I recommend is creating your own $myco::vhost define and feeding it custom templates. An example might look like

define myco::vhost(
  $priority   = '99',
  $port       = '80',
  $a_options  = ''
  $a_template = "myco/vhosts/default.erb",
) { }

Additionally you could use concat module to ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-01-10 16:45:46 -0500

Seen: 261 times

Last updated: Jan 13 '14