19.12.11

Automate Configuration Management Using Tokens! | Javalobby

Automate Configuration Management Using Tokens! | Javalobby


Problem:

Your application has numerous config files, and the values in these config files differ on every server or every environment. You hate manually updating the values every time you deploy your applications to a new environment, because that takes up too much of your time and inevitably leads to costly mistakes.

Solution:
  • Use “master” config files that have ALL environmental details replaced with tokens
  • Move copies of these files to folders denoting the environments they’ll be deployed to
  • Use a token replacement operation to replace the tokens
  • Deploy over the top of your code deployments, in doing so replacing the default config files
XArgs
xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input. Under the Linux kernel before version 2.6.23, arbitrarily long lists of parameters could not be passed to a command,[1] so xargs breaks the list of arguments into sublists small enough to be acceptable.

Example with find

 find /path -type f -print0 | xargs -0 rm
In the above example, the find utility feeds the input of xargs with a long list of file names. xargs then splits this list into sublists and calls rm once for every sublist.

The previous example is more efficient than this functionally equivalent version which calls rm once for every single file:
 find /path -type f -exec rm '{}' \;

Note however that with modern versions of find, the following variant does the same thing as the xargs version:
 find /path -type f -exec rm '{}' +

Ant
Replace Task
Copy Task

No comments: