Ask Your Question

contain module inside other module?

asked 2014-06-30 12:45:18 -0500

kwhite gravatar image

I've seen that it's bad practice to contain a module inside another module. I'm trying to create a module that will manager a bunch of other modules. I was wondering if this will cause issues or have any problems? I'm using contains and not includes to do this.

Currently I have modules for apache, mysql, nfs mounts, and other settings. Each module main class has parameters that can be passed to the module depending on the specific deployment of our company's application. I'm trying to create a main module, named after our application, that will manage these other modules and the parameters that will be passed to them.

So if the main application module (let's start calling this mainapp) is passed true to the mysql_replication setting in the mainapp there are conditionals that will pass that to the appropriate mysql module.

Something like the following:

if $mysql_replication == true {
    class {'mysqlmodule':
        replication => true
    contain mysqlmodule

I'm just unsure if this is the correct way to do this. Mainly using one module to control the other modules and pass parameters to them.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-06-30 13:05:18 -0500

Gary S gravatar image

I think you need to call the required classes from a wrapper class like so;

class mainapp { 
anchor { 'mainapp::begin': } ->
class { '::mysqlmodule': } ->
class { '::httpdmodule': } ->
anchor { 'mainapp::end': }

You should be able to carry out the required 'if' logic within that construct. Oh and you'll need puppetlabs-stdlib module installed in order to use anchors.

Hope this helps.

edit flag offensive delete link more


Awesome, that's about how it is, thanks

kwhite gravatar imagekwhite ( 2014-06-30 13:47:18 -0500 )edit

Isn't this now deprecated, and replaced with chaining arrows -> and ~> ?

felipe1982 gravatar imagefelipe1982 ( 2016-06-01 01:44:47 -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-06-30 12:45:18 -0500

Seen: 100 times

Last updated: Jun 30 '14