Ask Your Question

Best practice for configuration injection and complex configuration file composition

asked 2013-06-25 00:50:21 -0500

I have a product that I need to configure. Well, it's Sonatype's Nexus - Manen/Ivy repository management software. It is configured by a huge file called nexus.xml. As far as I know I can't split it into smaller files. So, many of configuration aspects go in that file. The main part of that file that I would like to "externalize" is repository definitions. Basically I would like to achieve something similar to this:

class { 'nexus': } # configure base product with default configuration

# Injects a snippet inside nexus.xml, create directories etc.
nexus::repository { 'my_repo_1':

# Injects a snippet ...
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-06-25 11:40:15 -0500

ramindk gravatar image

The concat module is one solution. You might need to think about how to make it work with an XML file. However if you were storing all the data required in Hiera it might be simpler to handle it with a template that loops over keys in a hash rather than stitching files together.

edit flag offensive delete link more


Concat would be my first pick if you were going to wrap the pieces of nexus.xml as defined types to be called from other modules. If you don't ...(more)

Ancillas gravatar imageAncillas ( 2013-06-25 12:22:07 -0500 )edit

Thanks for the link. I didn't know about this module. Even though I hoped for something more generic on Puppet level. Thanks anyway.

Andrey Adamovich gravatar imageAndrey Adamovich ( 2013-06-26 08:57:11 -0500 )edit

answered 2013-06-25 11:57:20 -0500

GregLarkin gravatar image

Could you use iteration within a Puppet ERB file that you create from your basic nexus.xml?

For instance, if you've defined your list of repositories in an ENC or in hiera, fetch the values into a manifest variable, effectively resulting in:

$reposlist = [my_repos_1, my_repos_2, my_repos_3]

Then in nexus.xml.erb, you would have something like:

  <% @reposlist.each do |repos| -%>
      <id><%= repos %></id>
      <name><%= repos %></name>
        <url>http://<%= repos %>.mydomain.tld/maven2/</url>
    <% end -%>

Then load up some other manifest variables with repository IDs, URLs, etc. and inject them into ... (more)

edit flag offensive delete link more


I was thinking of this approach, but the problem is that repository configuration is not just a name and passing more parameters with this approach is harder. You can, of ...(more)

Andrey Adamovich gravatar imageAndrey Adamovich ( 2013-06-26 08:55:53 -0500 )edit

I wonder if this problem would be a good candidate for solving with a custom type?

GregLarkin gravatar imageGregLarkin ( 2013-06-26 09:32:10 -0500 )edit

It's probably the only proper way, but it's too much coding :)

Andrey Adamovich gravatar imageAndrey Adamovich ( 2013-06-26 11:31:12 -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: 2013-06-25 00:50:21 -0500

Seen: 783 times

Last updated: Jun 25 '13