> so if you feel your module has too many arguments, adjust the pattern but
try to
> understand why it recommends what it does and try to stay within the
overall goals
sure, and again, what i like about it is that it allows to have two apps,
myapp1,
and myapp2, which uses two differents $jmxtrans_outputs.
you mean something like this?
again, this does not allow to have two apps, myapp1, and myapp2, with two
differents $jmxtrans::outputs.
node 'mynode' {
$tomcat_conf = {
hostname => 'host1.example.com',
port => 8080,
jmx_port => 9200,
jmx_username => 'my_tomcat_jmx_username',
jmx_password => 'my_tomcat_jmx_password',
}
class {jmxtrans::output:
host => 'graphite_dev.example.com',
port => 2003,
username => 'my_graphite_username',
password => 'my_graphite_password',
}
class { myapp:
tomcat_conf => $tomcat_conf,
market => 'US',
products => ['p1', 'p2', 'p3']
}
}
class myapp($tomcat_conf, $market, $products) {
# it installs several packages, as tomcat, imagemagick... and
configuration files...
class { tomcat:
tomcat_conf => $tomcat_conf,
}
# package { imagemagik: ensure => installed }
# ...
}
class tomcat($tomcat_conf) {
# package { tomcat: ensure => installed }
# config file, using $tomcat_conf.{hostname, port, jmx_port,
jmx_username, jmx_password}
#...
$tomcat_jmx = {
host => $tomcat_conf[hostname],
port => $tomcat_conf[jmx_port],
username => $tomcat_conf[jmx_username],
password => $tomcat_conf[jmx_password],
}
jmxtrans::connection { $name:
input => $tomcat_jmx,
template_source => "myapp/tomcat_jmxtrans.json.erb",
# require => Class[jmxtrans]
}
}
# todo: replace $template_source with $objects (the objects to be
monitored, instead of passing a full template)
define jmxtrans::connection ($input, $template_source) {
notify {"jmxtrans::connection::input: $input": }
notify {"jmxtrans::connection::output: $jmxtrans::output": }
file { "/tmp/jmxtrans_${hostname}_${name}.json":
content => "template that uses \ninput_host:
${input[host]}\ninput_port: ${input[port]}\ninput_username:
${input[username]}\ninput_password: ${input[password]}\noutput_host:
${jmxtrans::output[host]}\noutput_port:
${jmxtrans::output[port]}\noutput_username:
${jmxtrans::output[username]}\noutput_password:
${jmxtrans::output[password]}\n",
# content => template(template_source),
}
}
class jmxtrans::output ($host, $port, $username, $password) {
}
On Wednesday, December 4, 2013 10:42:39 PM UTC+1, R.I. Pienaar wrote:
>
>
>
> ----- Original Message -----
> > From: "David Portabella" <[email protected] <javascript:>>
> > To: [email protected] <javascript:>
> > Sent: Wednesday, December 4, 2013 9:35:05 PM
> > Subject: [Puppet Users] Re: dependency injection in puppet
> >
> > calling hiera from inside jmxtrans::connection would contradict the
> > argument:
> > "modules that have configuration should be configurable in a single
> way
> > and single place",
> > explained here:
> >
> http://www.devco.net/archives/2012/12/13/simple-puppet-module-structure-redux.php
>
>
> It also says:
>
> "As before I will show a simple module for a common scenario. Rather than
> considering this module a blueprint for every module out there you should
> instead study its design and use it as a starting point when writing your
> own modules. You can build on it and adapt it but the basic approach
> should
> translate well to more complex modules."
>
> so if you feel your module has too many arguments, adjust the pattern but
> try to
> understand why it recommends what it does and try to stay within the
> overall goals
>
>
> you do not need to pass in all the arguments, your inner modules can
> reference
> like $jmxtrans::foo for example this removes a lot of the duplication if
> you
> go this route.
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/15579f6d-30d2-4237-a02a-855e7db8d2d8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.