Environment Specific Configuration Management

1,115 views
Skip to first unread message

Derek Stainer

unread,
Jun 17, 2013, 12:15:11 PM6/17/13
to dropwiz...@googlegroups.com
I'm curious how folks manage configuration files, specifically, what tools/processes do you guys use to do two things:
  1. Propagate new properties across environments
  2. Manage environment specific properties, i.e. database urls, usernames and passwords
Thanks
Derek

Justin Rudd

unread,
Jun 17, 2013, 1:24:15 PM6/17/13
to dropwiz...@googlegroups.com
We started off with separate YAML files per environment (production and US, production and UK, production and JP, dev and US, etc.), but that got old really quick. So I built a little code around Typesafe Config (https://github.com/typesafehub/config). It is kind of a hack, but since it only happens at start up time, I'm OK with it.

Basically I write all my configuration using HOCON (https://github.com/typesafehub/config/blob/master/HOCON.md). I then pull it through the following code...

        final Config defaults = getDefaults(allConfig, domain, realm);
        final Config domainAndRealmConfig = getDomainAndRealmConfig(allConfig, domain, realm);
        final Config domainConfig = getDomainConfig(allConfig, domain, realm);
        final Config realmConfig = getRealmConfig(allConfig, realm);

        return combine(defaults, domainAndRealmConfig, domainConfig, realmConfig);

Combine has the following precedence (which makes sense for me)...

domainAndRealm -> domainOnly -> realmOnly -> defaults

Then once they are combined, I then use "Config.resolve" to do my substitutions (it's documented in the HOCON file). You can add as many levels as you need, but just a domain and realm cover my needs.

Here is where the hack comes in, Typesafe Config can serialize its representation as JSON. So I convert it to a Jackson JsonNode and then using the YAMLFactory, write it out as YAML that get's parsed by Dropwizard.

Using Typesafe Config, I get includes, substitutions, etc. So I can have all my DB connections for an environment in one file. That file gets included in all my services. So when a URL changes, I change it one place.




Derek

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Coda Hale

unread,
Jun 17, 2013, 2:00:12 PM6/17/13
to dropwiz...@googlegroups.com
A configuration management tool like Chef, Puppet, or cfengine will be your best bet here.


On Mon, Jun 17, 2013 at 9:15 AM, Derek Stainer <derek....@gmail.com> wrote:
Derek

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Coda Hale
http://codahale.com

Graham O'Regan

unread,
Jun 17, 2013, 4:15:53 PM6/17/13
to dropwiz...@googlegroups.com, dropwiz...@googlegroups.com
If you aren't running puppet/chef already then you may find ansible a more palatable option. We've ported our configuration files to it's jinja templates and it only took a couple of hours to automate 



Graham O'Regan

unread,
Jun 20, 2013, 9:03:15 AM6/20/13
to dropwiz...@googlegroups.com
I had a think about this the other day and came up with another possible option if you aren't running on a managed platform. Using Maven for the build you could use its profile support to modify the yml file as part of your build. For example, if you add this to your pom.xml;

<build>
...
<resources>
     <resource>
       <directory>src/main/resources</directory>
       <filtering>true</filtering>
       <includes>
         <include>app.yml</include>
       </includes>
     </resource>
</resources>
...
</build>

And then parameterise your app.yml (or whatever  you call it) expressions;

database:
  driverClass: com.mysql.jdbc.Driver
  user: ${database.user}
  password: ${database.password}
  url: jdbc:mysql://${database.hostname}/${database.name}

Then you can set these properties in your pom.xml;

<properties>
<database.user>username</database.user>
<database.password>password</database.password>
<database.hostname>localhost</database.hostname>
</properties>

and then override the settings using a profile;

<profiles>
<profile>
<id>test</id>
<properties>
<database.user>test_username</database.user>
<database.password>test_password</database.password>
<database.hostname>test.mydomain.com</database.hostname>
</properties>
</profile>
...
<profiles>

If you build without specifying a profile then the default settings will be used and the app.yml will be filtered and copied to target/classes/app.yml. If you specify a profile then it will use those settings instead, just run with "mvn -P test install" for the example above.

HTH,

Graham

Konyu Godwin

unread,
Jun 9, 2024, 11:42:55 AMJun 9
to dropwizard-user
There is a growing number of people who wish to buy shrooms online. It is often hard to tell which form of products to buy since you cannot see it physically. This is sometimes peculiar to newbies who haven’t tried shrooms before. They just don’t know how to go about it. Shroom Edibles are not so popularly discussed as often as you think. A lot of experienced shroom users have not even had a taste of these Psilonauts Psilocybin Chocolate Bar goodness that offer a premium psychedelic trip.
https://t.me/trippyworld710/911
https://t.me/trippyworld710/908?single
https://t.me/trippyworld710/882?single
https://t.me/trippyworld710/879?single
https://t.me/trippyworld710/877
https://t.me/trippyworld710/872?single
https://t.me/trippyworld710/870
https://t.me/trippyworld710/865
https://t.me/trippyworld710/864
https://t.me/trippyworld710/863?single
https://t.me/trippyworld710/859?single
https://t.me/trippyworld710/848
https://t.me/trippyworld710/844
https://t.me/trippyworld710/841
https://t.me/trippyworld710/837
https://t.me/trippyworld710/833
https://t.me/trippyworld710/831?single
https://t.me/trippyworld710/829?single
https://t.me/trippyworld710/823?single
https://t.me/trippyworld710/821
https://t.me/trippyworld710/817
https://t.me/trippyworld710/816
https://t.me/trippyworld710/815
https://t.me/trippyworld710/811
https://t.me/trippyworld710/810
https://t.me/trippyworld710/808
https://t.me/trippyworld710/806
https://t.me/trippyworld710/803
https://t.me/trippyworld710/790
https://t.me/trippyworld710/783?single
https://t.me/trippyworld710/780
https://t.me/trippyworld710/779?single
https://t.me/trippyworld710/769
https://t.me/trippyworld710/754
https://t.me/trippyworld710/741
https://t.me/trippyworld710/737
https://t.me/trippyworld710/732
https://t.me/trippyworld710/730
https://t.me/trippyworld710/727
https://t.me/trippyworld710/724
https://t.me/trippyworld710/704
https://t.me/trippyworld710/679?single
https://t.me/trippyworld710/655
https://t.me/trippyworld710/649?single
https://t.me/trippyworld710/648
https://t.me/trippyworld710/647
https://t.me/trippyworld710/570?single
https://t.me/trippyworld710/557?single
https://t.me/trippyworld710/552?single
https://t.me/trippyworld710/547
https://t.me/trippyworld710/545?single
https://t.me/trippyworld710/537
https://t.me/trippyworld710/522
https://t.me/trippyworld710/519?single
https://t.me/trippyworld710/484?single
https://t.me/trippyworld710/448?single
https://t.me/trippyworld710/446
https://t.me/trippyworld710/211
https://t.me/trippyworld710/198
https://t.me/trippyworld710/183?single
https://t.me/trippyworld710/182

Konyu Godwin

unread,
Jun 9, 2024, 11:44:13 AMJun 9
to dropwizard-user

Konyu Godwin

unread,
Jun 9, 2024, 11:45:32 AMJun 9
to dropwizard-user
On Thursday, June 20, 2013 at 2:03:15 PM UTC+1 graham...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages