Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

How to install with the Passenger module? #6

Open
enthooz opened this issue Mar 16, 2013 · 10 comments
Open

How to install with the Passenger module? #6

enthooz opened this issue Mar 16, 2013 · 10 comments
Labels

Comments

@enthooz
Copy link

enthooz commented Mar 16, 2013

In the nginx formula, there is an option for installing the Passenger module. It requires passing an argument --with-passenger. How does one pass an argument with Puppet/Boxen?

@enthooz
Copy link
Author

enthooz commented Mar 20, 2013

I fixed it for myself with this commit. Now, homebrew doesn't ignore install_options passed as so:

package { 'boxen/brews/nginx':
  ensure          => '1.2.7-boxen1',
  notify          => Service['dev.nginx'],
  install_options => '--with-passenger',
}

Now, I just need to get the passenger gem installed appropriately before installing nginx.

@enthooz
Copy link
Author

enthooz commented Mar 20, 2013

NOTE: The above commit adds the check for Options.coerce(ARGV.options_only).empty?

@mriddle
Copy link

mriddle commented Mar 22, 2013

Any luck getting your nginx brew and your passenger gem to play nice? I am running into the following error /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:243: command not found: passenger-config --root. I assume it's mixed up about which Ruby/Gem to use but I don't know how to correct it.

@enthooz
Copy link
Author

enthooz commented Mar 22, 2013

Unfortunately, no. I'm not sure how to specify which rbenv version to use during the Package['boxen/brews/nginx'] run.

@grosser
Copy link
Contributor

grosser commented Jan 7, 2014

FYI our solution, a little hacky but seems to work nicely, I tried to make it alway work on a clean machine and after the passenger-version was changed

class custom::nginx($port = 80) {
  include ::nginx

  $passenger_version = "5.0.20"
  $passenger_root = "/Library/Ruby/Gems/2.0.0/gems/passenger-${passenger_version}"

  # use our own custom nginx.conf
  File <| title == $nginx::config::configfile |> {
    content => template("custom/nginx.conf.erb", "nginx/config/nginx/nginx.conf.erb")
  }

  # uninstall system nginx if it's built without passenger or selftest is failing
  # and do it before the onlyif / unless conditions of other blocks are even executed
  $x = inline_template("<%=
    config = File.read('${projects_config}') rescue ''
    if !config.include?('passenger-${passenger_version}') || !system('sudo nginx -t >/dev/null 2>&1')
      puts 'Uninstalling nginx'
      Bundler.with_clean_env { `brew uninstall nginx 2>/dev/null` }
    end
  %>")

  # install passenger into the ruby which nginx will use https://github.com/boxen/puppet-ruby/issues/109
  exec {"install system passenger":
    command => "env -i bash -c 'source /opt/boxen/env.sh && rbenv shell system && gem install passenger -v $passenger_version --no-rdoc --no-ri'",
    unless => "/usr/bin/gem list passenger | grep $passenger_version",
    user => root,
  }

  # make installed rake available to nginx
  file{"/opt/boxen/homebrew/Library/ENV/4.3/rake":
    ensure => "link",
    target => "/usr/bin/rake",
  }

  # make nginx formula install via default ruby and exact passenger version
  file{ "/opt/boxen/homebrew/Library/ENV/4.3/passenger-config":
    content => "#!/bin/sh\necho ${passenger_root}",
    mode    => "0755",
    require => Exec["install system passenger"],
  }

  # Passenger compile leftovers get removed after install, compile manually or passenger cannot boot
  exec{ "compile-passenger":
    command => "cd ${passenger_root} && /usr/bin/rake nginx",
    user => "root",
    unless => "test -d ${passenger_root}/buildout",
    require => Exec["install system passenger"],
  }

  # or nginx install fails with passenger errors (buildout/common/libboost_oxt.a)
  exec {"fix-passenger-permissions":
    command => "chmod -R 777 ${passenger_root}",
    user => root,
    require => Ruby::Gem["passenger-system"],
  }

  Package <| title == "boxen/brews/nginx" |> {
    install_options => "--with-passenger",
    require => [Exec["install system passenger"], File["/opt/boxen/homebrew/Library/ENV/4.3/rake"], File["/opt/boxen/homebrew/Library/ENV/4.3/passenger-config"], Exec["fix-passenger-permissions"]],
  }
}

@stereobooster
Copy link

@grosser thanks for sharing your solution, though there are some troubles with it:

  • There is no Exec["fix-passenger-permissions"] task defined
  • There is Ruby::Gem["passenger for ${team::dependency::config::ruby_version}"] and not defined but ruby::gem {"passenger-system" defined and not used. Is it right?

@grosser
Copy link
Contributor

grosser commented Apr 25, 2014

Thx, fixed it, have to strip our own version of all the other stuff we have going on :)

@ocxo
Copy link
Contributor

ocxo commented May 5, 2014

Going to close this for now as there hasn't been any activity here recently. Please feel free to re-open if it's still an issue.

@ocxo ocxo closed this as completed May 5, 2014
@ocxo
Copy link
Contributor

ocxo commented May 5, 2014

Sorry, didn't mean to close this one.

@grosser
Copy link
Contributor

grosser commented Oct 16, 2015

FYI updated to work with newer puppet-ruby ... would be great to get that in as nginx::passenger or so to make this less weird ... not sure if anyone got this working without these hacks (and having a global ruby that is not system ruby)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

5 participants