title: How to handle environment-specific application configuration organization-wide?
body: <h2>Problem</h2>
  
  <p>Your organization has many separate applications, some of which interact with each other (to form "systems").  You need to deploy these applications to separate environments to facilitate staged testing (for example, DEV, QA, UAT, PROD).  A given application needs to be configured slightly differently in each environment (each environment has a separate database, for example).  You want this re-configuration to be handled by some sort of automated mechanism so that your release managers don't have to manually configure each application every time it is deployed to a different environment.</p>
  
  <h2>Desired Features</h2>
  
  <p>I would like to design an organization-wide configuration solution with the following properties (ideally):</p>
  
  <ul>
  <li>Supports "one click" deployments (only the environment needs to be specified, and no manual re-configuration during/after deployment should be necessary).</li>
  <li>There should be a single "system of record" where a shared environment-dependent property is specified (such as a database connection string that is shared by many applications).</li>
  <li>Supports re-configuration of deployed applications (in the event that an environment-specific property needs to change), ideally without requiring a re-deployment of the application.</li>
  <li>Allows an application to be run on the same machine, but in different environments (run a PROD instance and a DEV instance simultaneously).</li>
  </ul>
  
  <h2>Possible Solutions</h2>
  
  <p>I see two basic directions in which a solution could go:</p>
  
  <ol>
  <li>Make all applications "environment aware".  You would pass the environment name (DEV, QA, etc) at the command line to the app, and then the app is "smart" enough to figure out the environment-specific configuration values at run-time.  The app could fetch the values from flat files deployed along with the app, or from a central configuration service.</li>
  <li>Applications are not "smart" as they are in #1, and simply fetch configuration by property name from config files deployed with the app.  The values of these properties are injected into the config files at deploy-time by the install program/script.  That install script takes the environment name and fetches all relevant configuration values from a central configuration service.</li>
  </ol>
  
  <h2>Question</h2>
  
  <p>How would/have you achieved a configuration solution that solves these problems and supports these desired features?  Am I on target with the two possible solutions?  Do you have a preference between those solutions?  Also, please feel free to tell me that I'm thinking about the problem all wrong.  Any feedback would be greatly appreciated.</p>