hyperoslo/capistrano-foreman — pull request #13 by fabn (2013-09-06 14:03:28+00:00)
Title: Added alternative setup and rails enviroment options

I've encountered some issues with your current setup especially while running `rvmsudo` commands.

So I've created a fork which allows to run this gem using a deployment user with limited sudo privileges. In my setup I created the `sites` folder under `/etc/init/` and i gave that user write privileges for that folder. In this way the `foreman export` command can be executed without sudo.

After this I gave deployer user sudo privileges to execute upstart commands with no password but only with `sites/*` argument. In this way you can obtain a full passwordless deployment with no need of `rvmsudo`

Most part of this is in the readme, but some changes are required in the [lib code to some default values](https://github.com/fabn/capistrano-foreman/commit/455a1e283f573288b20e9dcab2ef2eb625f714c1#L1R0)

In the last part of my PR I've added some rails specific options in order to automatically create a `rails.env` file with common rails variables (such as `RAILS_ENV`), in this way if you don't need any env customization you can run plain foreman commands in multiple environments (I'm using this with capistrano multistage support). For instance with unicorn apps you can have a `Procfile` with this content
```
web: bundle exec unicorn -c ./config/unicorn.rb
```
the same file can be used with no need to manage env files because automatically generated file will provide the right values in both production and staging env file.

Default behavior is the same as before since new options are empty by default.

I've documented these behaviours in the readme file you can read it on [my fork page](https://github.com/fabn/capistrano-foreman#rails-usage)

If you want to accept only part of this PR let me know and I'll try to rearrange.