stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajkumar Rajaratnam <>
Subject Re-organizing puppet module structure
Date Tue, 19 Aug 2014 11:24:17 GMT

Currently we are having an agent puppet module, which includes all agent
extensions (puppet/modules/agent/templates/extensions/*).

All the cartridges need these extensions, but with different behaviors
(implementation of these extensions could be different from cartridge to
cartridge). For example, if it is a php cartridge, we need to do certain
stuffs when the instance is started. If it is a mysql cartridge, we want to
do something else. With current puppet module structure, we have to
hard-code cartridge types in extensions to achieve specific behavior based
on cartridge.

For example, in instance-started extension;

<%- if @type == 'mysql' -%>
<%= scope.function_template(['agent/extensions/addons/_mysql.erb']) -%>
<%- end -%>

<%- if @type == 'ruby' -%>
<%= scope.function_template(['agent/extensions/addons/_ruby.erb']) -%>
<%- end -%>

IMO, this is not a proper way.

I guess the proper way is to have some default extensions in agent module
and allow cartridges to override and/or add more extensions specific to
them. This way, we don't have to hard-code anything in agent extensions.
Modules which need custom extension behavior can override default
extensions and/or add more extensions. If they don't override an extension,
default extension will be copied to the instance.

I am thinking of implementing it as below;

We introduce two optional parameters to agent class.
      $templates : templates which needs to be overridden
      $module : which module to look up for these templates

node /ruby/ inherits base {
  require java
  class {'agent':
           module => 'ruby',
           templates =>
  class {'ruby':}
  Class['stratos_base'] -> Class['java'] -> Class['ruby'] ~> Class['agent']

We keep these templates in the relevant module (ruby in this case) with
appropriate directory structure (ruby/templates/agent/extensions and
ruby/templates/agent/bin) and pass these to the agent class, which will
copy right extensions (default + custom) to the instance.

WDYT about this approach?


Rajkumar Rajaratnam
Software Engineer | WSO2, Inc.
Mobile +94777568639 | +94783498120

View raw message