Check out Brightbox Cloud - launch UK-based cloud servers in 30 seconds with £20 free trial credit to get started!
 

Advanced Gem Settings

Deploy.local.rb

NB: This only applies to Brightbox Deployment Gem v2.3.6 and above

Local deploy settings

There are certain deploy settings that shouldn't be put in your config/deploy.rb. A prime example is your deploy password, each person deploying needs it, but for security reasons you don't want it checked into source control. To solve this common problem, the Brightbox Deployment Gem now loads in config/deploy.local.rb, if it exists.

The basic idea is you create config/deploy.local.rb, add any sensitive settings in there that you want to exclude from source control, and then ignore the deploy.local.rb file in your source control mechanism.

Here's an example to set your server password, using git as your source control:

  • Create config/deploy.local.rb
  • Add “config/deploy.local.rb” to your .gitignore and commit the change
  • Edit your deploy.local.rb to add your password:
set :password, "supersecretpassword"
  • Deploy!

Settings in deploy.local.rb don't override those set in deploy.rb, but anything you could put in deploy.rb will work in deploy.local.rb.

Multistage support

There isn't direct multistage support built in, but here is a workaround using deploy.local.rb to set a different value depending on which stage is selected.

Using the previous example of setting the deploy password, we want a different password set for the staging servers and production servers.

Firstly we set the values of the different passwords, using the variable name format {stage}_password

set :staging_password, "supersecretpassword"
set :production_password, "anothersecretpassword"

Then we use capistrano's lazy variable evaluation to set the password variable during the setup for the task, so we know which stage we're using.

set(:password) { send(:"#{stage}_password") }

Disable generating webserver configs

NB: This only applies to Brightbox Deployment Gem v2.3.6 and above

You can stop your application's apache or nginx config being regenerated by deploy:setup now. This is useful if you've got manual modifications to your config files you don't want overwritten. If your config hasn't been generated yet, it won't be created with the following set, so be sure your config has already been generated before adding it to your deploy.rb.

To disable config generation, add the following to your deploy.rb:

set :generate_webserver_config, false
docs/gemv2/advancedgemsettings.txt · Last modified: 2010/04/14 18:04 by caius