title: Can I pass variables to be rendered by erb from the command line?
body: <p>I have an <code>erb template</code> in a <code>chef cookbook</code> that configures my <code>vhost</code> for my <code>vagrant</code> environment and my <code>aws opsworks</code> environment.  I would like to utilize this template on my continuous integration server to generate the vhost for my non chef managed machines before it pushes it out.</p>
  
  <p>Suppose I have the following erb:</p>
  
  <pre><code>&lt;VirtualHost &lt;%= @params[:http_host] %&gt;:&lt;%= @params[:http_port] || node['apache']['listen_ports'].first %&gt;&gt;
      ServerName &lt;%= @params[:server_name] %&gt;
      ServerAlias &lt;% @params[:server_aliases].each do |a| %&gt;&lt;%= a %&gt; &lt;% end %&gt;
  
      DocumentRoot &lt;%= @params[:docroot] %&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>How do I go about populating those variables if I wanted to call <code>erb</code> directly?</p>
  
  <p>I know I can call <code>erb -r library vhost.conf.erb</code> to load a library to be leveraged, can set variables as an argument to erb or do I need to create a custom library.  If I need a custom library, how would that look?</p>