Use Keep Files to Customize and Maintain Configurations

A keep file gives you the flexibility to modify configuration settings in specific files within the /data and /etc directories of your EBS (Amazon Elastic Block Storage) volume.

When Engine Yard’s Chef goes to create configuration files from its recipe templates, it checks the filesystem for certain files prefaced with keep. If such files exist, then the Chef recipe doesn’t create new configuration files; instead it leaves the keep files in place.

For example, if the template is about to write out a configuration file called /data/myservice.conf, Chef first looks for /data/keep.myservice.conf. If this file is found, then Chef skips writing out the template-base configuration file. And, the keep.myservice.conf file is used instead.

Files that can be keep files

These are the files that can be made into keep files.

Note: Only this subset of files in the /etc or /data directories can be made into keep files. Other files in these directories might be overwritten or ignored even if they have been prefaced with “keep”.

  • /data/#{appname}/shared/config/database.yml
  • /data/nginx/nginx.conf
  • /data/nginx/common/proxy.conf
  • /data/nginx/common/servers.conf
  • /data/nginx/common/fcgi.conf
  • /data/nginx/servers/#{appname}.rewrites
  • /data/nginx/servers/#{appname}.conf
  • /data/nginx/servers/#{appname}.ssl.conf
  • /etc/haproxy.cfg
  • /etc/conf.d/nginx
  • /etc/engineyard/collectd.conf
  • /etc/redis/redis.conf
  • /etc/monit.d/unicorn_#{appname}.monitrc
  • /etc/monit.d/#{name}.#{appname}.monitrc
  • /etc/ssh/sshd_config

Important! Risks associated with keep files

There are risks associated with keep files. Use keep files with caution.

Making a keep file effectively “freezes” the file. If your environment changes, either through changes that you apply yourself or when you upgrade to the latest Engine Yard stack, your keep files can become out-of-date and thus compromise your application.

Before making changes to a production environment, review your keep files.

Tip: Where possible, consider using an include file instead of a keep file.

To use keep files for configuration

  1. Connect to your instance via SSH.

  2. Edit the file and rename (to keep.filename.extension) any of the files listed above.

    For example, for an application name “myapp”, configure the nginx server by renaming /data/nginx/servers/myapp.conf to /data/nginx/servers/keep.myapp.conf

  3. If you make nginx.conf or database.yml into keep files, add a deploy hook to create a symlink.

    ln -nfs /data/nginx/keep.nginx.conf /data/nginx/nginx.conf 


    ln -nfs /data/#{appname}/shared/config/keep.database.yml /data/#{appname}/shared/config/database.yml
  4. Important! If you make any changes to your environment that affect your keep files, update them before rebooting your environment.

More information

For more information about... See...
SSH Connect to your instance via SSH.                                                                      
Deploy hooks Use deploy hooks.
Customizing Unicorn configuration (without keep files)                                            Customize Unicorn.

If you have feedback or questions about this page, add a comment below. If you need help, submit a ticket with Engine Yard Support.


Article is closed for comments.