How to symlink additional config file on application deployment

's Avatar

kostiantyn.kahanskyi

26 Mar, 2012 08:46 AM

Hello,

I'm deploying a Scalarium application, which beside "database.yml" etc. has some custom configuration files, which should be shared between deployments. What is the best way to achieve this?

Thanks!

  1. Support Staff 2 Posted by Jonathan Weiss on 26 Mar, 2012 11:51 AM

    Jonathan Weiss's Avatar

    The best way to do this is using deploy-hooks, see http://wiki.opscode.com/display/chef/Deploy+Resource#DeployResource...

    an example would be deploy/before_migrate.rb:

      Chef::Log.info "Looking for files to symlink in #{release_path}/../../shared/config/*"
    
      known_configs = %w(my_special.yml another.yml).map{|c| "#{release_path}/../../shared/config/#{c}" }
      files_to_symlink =  Dir.glob("#{release_path}/../../shared/config/*") + known_configs
    
      files_to_symlink.each do |config|
        config = ::File.expand_path(config)
        Chef::Log.info "Checking shared config #{config}"
        if ::File.exists?("#{release_path}/config/#{::File.basename(config)}")
          Chef::Log.info "skipping #{config}"
        else
          Chef::Log.info "Symlinking #{config}"
          system("ln -s #{config} #{release_path}/config/#{::File.basename(config)}")
        end
      end
    

    This would symlink the my_special.yml another.yml from shared/config to current/config on every dpeloy.

  2. Jonathan Weiss closed this discussion on 26 Mar, 2012 11:51 AM.

Comments are currently closed for this discussion. You can start a new one.