Ask Your Question

Where to place application specific config/data?

asked 2014-07-20 13:16:38 -0500

josh gravatar image

I use the puppetlabs/apache and camptocamp/tomcat modules to configure a server for a Tomcat/Apache application. This server has profiles::apache and profiles::tomcat assigned to it which basically just include the ::apache and ::tomcat modules. All of my data is stored in hiera (for apache vhosts, tomcat instance config, etc).

This works well for getting the Tomcat instance and Apache configured, but I still need a solution for puppetizing the actual deployment of an application. This would include things like:

  • Placing a WAR file on the Tomcat server
  • Dropping the web application configuration down (erb template)

My problem is that I do not know where to place this within Puppet. I don't want to make my profiles::tomcat class too specific for one certain application. I was thinking that I could use create_resources to create file resources to drop the WAR and it 's associated configuration template down, and then store all of the actual data back in Hiera. If I did this, where would I put the associated ERB template config? In the profile module?

Is this a good solution? Any other recommendations on how to handle this?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-21 15:05:55 -0500

dbschofield gravatar image

Since the applications are being deployed to your tomcat profile and you have the possibility of deploying many applications then create an application define on top of your tomcat profile.

define profile::tomcat::application(
  $source = "${url_to_app_repo}/${title}",
  #Install the app
  file { "${profile::tomcat::home}/webapps/${title}":
    source => $source
  #Install the config for the app
  file { "${app_config_dir}/${title}/":
    source => "${source}/"

profile::tomcat::application{ 'my_nifty_app.war' :}

Use the create_resources function to create the application resources from your hiera data.

Note this doesn't address the removal of old applications. For that I recommend a good Tomcat custom module that implements the purge resource function.

My 2 cents, hope it helps.

edit flag offensive delete link more


Hi - thanks for the tip. Where would the source files actually be located, though? In the profiles module?

josh gravatar imagejosh ( 2014-07-24 09:53:31 -0500 )edit

No, you don't want company specific files in our modules. If I understand right the source files are your applications being produced by your company. So I suspect your company has a build process that leaves them sitting in some repo and accessible by a URL. Essentially the war's and ear's can be pulled directly from the repo or use the puppet file server to upload them from the master. The configs are bit trickier because they need to change based on the target server being a dev/test/prod server. Personally I stay away from templates for app configs. Instead the developers maintain the configs and the profile::tomcat::application define pulls the correct configs based on an environment variable and app name.

dbschofield gravatar imagedbschofield ( 2014-07-24 21:05:26 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-07-20 13:16:38 -0500

Seen: 841 times

Last updated: Jul 21 '14