Greetings,
I''m trying to wrap my head around a solution to a problem I''m
facing with
an exported resources configuration I have. I''m using the following
simple
config to build a munin configuration:
@@file { "/etc/munin/munin.conf.d/${::fqdn}.node":
content => "[All Hosts;${::fqdn}]
address ${ipaddress_eth0}
use_node_name yes\n\n",
tag => ''munin-node'',
}
File <<| tag == ''munin-node'' |>>
I''d like to add the following configuration lines to specifically one
of
the nodes:
diskstats_latency.sda.avgrdwait.warning 0:5
diskstats_latency.sda.avgwrwait.warning 0:5
Is there a way to cleanly append those configuration lines to the content
of the exported resource on that node without redeclaring the entire
contents of the file? This is what I don''t want to do, but would
illustrate what I''m trying to accomplish:
$content = $::fqdn ? {
''host1.example.tld'' => "[All Hosts;${::fqdn}]
address ${ipaddress_eth0}
use_node_name yes
diskstats_latency.sda.avgrdwait.warning 0:5
diskstats_latency.sda.avgwrwait.warning 0:5\n\n",
default => "[All Hosts;${::fqdn}]
address ${ipaddress_eth0}
use_node_name yes\n\n",
}
@@file { "/etc/munin/munin.conf.d/${::fqdn}.node":
content => $content,
tag => ''munin-node'',
}
The above could get very unwieldy with a lot of nodes with different
configurations. Is there a way to separate the $content assignment to a
node file (manifests/nodes/host1.example.tld.pp)?
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/1SGkucfT5gYJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Hi Alex, concat will help you build a file from pieces. http://forge.puppetlabs.com/ripienaar/concat I would use a template to build each stanza of config and use concat to build that into a file. I am not in front of my puppet config from work right now so I can''t send you a decent example but will try and remember to do that on monday. Hope that helps. On 20 October 2012 00:03, Alex C <cline@vivisimo.com> wrote:> Greetings, > > I''m trying to wrap my head around a solution to a problem I''m facing with an > exported resources configuration I have. I''m using the following simple > config to build a munin configuration: > > @@file { "/etc/munin/munin.conf.d/${::fqdn}.node": > content => "[All Hosts;${::fqdn}] > address ${ipaddress_eth0} > use_node_name yes\n\n", > tag => ''munin-node'', > } > > File <<| tag == ''munin-node'' |>> > > I''d like to add the following configuration lines to specifically one of the > nodes: > > diskstats_latency.sda.avgrdwait.warning 0:5 > diskstats_latency.sda.avgwrwait.warning 0:5 > > Is there a way to cleanly append those configuration lines to the content of > the exported resource on that node without redeclaring the entire contents > of the file? This is what I don''t want to do, but would illustrate what I''m > trying to accomplish: > > $content = $::fqdn ? { > ''host1.example.tld'' => "[All Hosts;${::fqdn}] > address ${ipaddress_eth0} > use_node_name yes > diskstats_latency.sda.avgrdwait.warning 0:5 > diskstats_latency.sda.avgwrwait.warning 0:5\n\n", > default => "[All Hosts;${::fqdn}] > address ${ipaddress_eth0} > use_node_name yes\n\n", > } > > @@file { "/etc/munin/munin.conf.d/${::fqdn}.node": > content => $content, > tag => ''munin-node'', > } > > The above could get very unwieldy with a lot of nodes with different > configurations. Is there a way to separate the $content assignment to a > node file (manifests/nodes/host1.example.tld.pp)? > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/1SGkucfT5gYJ. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Friday, October 19, 2012 9:03:39 AM UTC-5, Alex C wrote:> > Greetings, > > I''m trying to wrap my head around a solution to a problem I''m facing with > an exported resources configuration I have. I''m using the following simple > config to build a munin configuration: > > @@file { "/etc/munin/munin.conf.d/${::fqdn}.node": > content => "[All Hosts;${::fqdn}] > address ${ipaddress_eth0} > use_node_name yes\n\n", > tag => ''munin-node'', > } > > File <<| tag == ''munin-node'' |>> > > I''d like to add the following configuration lines to specifically one of > the nodes: > > diskstats_latency.sda.avgrdwait.warning 0:5 > diskstats_latency.sda.avgwrwait.warning 0:5 > > Is there a way to cleanly append those configuration lines to the content > of the exported resource on that node without redeclaring the entire > contents of the file? >You cannot append to the already-declared content property, but you may be able to build the content you want in the first place. For example, you could initially declare the file along these lines: $munin_extra = hiera(''munin_extra'') @@file { "/etc/munin/munin.conf.d/${::fqdn}.node": content => "[All Hosts;${::fqdn}] address ${ipaddress_eth0} use_node_name yes ${munin_extra}\n\n", tag => ''munin-node'', } if you''re not already using hiera and you don''t want to start, then you could achieve something similar via conditional statements and data in your manifests, or perhaps more flexibly by converting your content to a template and putting whatever processing logic you want into it. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/EKz49aJBJCMJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
We''re not ready to roll out hiera just yet.
I ended up storing the extra config in a parameter in puppet-dashboard and
I''m appending that variable to the existing configuration:
$extra = regsubst($::munin_extra, ''\\n'', "
", ''G'')
@@file { "/etc/munin/munin.conf.d/${::fqdn}.node":
content => "[All Hosts;${::fqdn}]
address ${ipaddress_eth0}
use_node_name yes
${extra}\n\n",
tag => ''munin-node'',
}
It''s not the most elegant solution, but it will work for the 4 or 5
nodes
that I have that need additional configuration options for munin.
Thanks for the ideas everyone!
-- Alex
On Monday, October 22, 2012 9:10:06 AM UTC-4, jcbollinger
wrote:>
>
>
> On Friday, October 19, 2012 9:03:39 AM UTC-5, Alex C wrote:
>>
>> Greetings,
>>
>> I''m trying to wrap my head around a solution to a problem
I''m facing with
>> an exported resources configuration I have. I''m using the
following simple
>> config to build a munin configuration:
>>
>> @@file { "/etc/munin/munin.conf.d/${::fqdn}.node":
>> content => "[All Hosts;${::fqdn}]
>> address ${ipaddress_eth0}
>> use_node_name yes\n\n",
>> tag => ''munin-node'',
>> }
>>
>> File <<| tag == ''munin-node'' |>>
>>
>> I''d like to add the following configuration lines to
specifically one of
>> the nodes:
>>
>> diskstats_latency.sda.avgrdwait.warning 0:5
>> diskstats_latency.sda.avgwrwait.warning 0:5
>>
>> Is there a way to cleanly append those configuration lines to the
content
>> of the exported resource on that node without redeclaring the entire
>> contents of the file?
>>
>
>
> You cannot append to the already-declared content property, but you may be
> able to build the content you want in the first place. For example, you
> could initially declare the file along these lines:
>
> $munin_extra = hiera(''munin_extra'')
> @@file { "/etc/munin/munin.conf.d/${::fqdn}.node":
> content => "[All Hosts;${::fqdn}]
> address ${ipaddress_eth0}
> use_node_name yes
> ${munin_extra}\n\n",
> tag => ''munin-node'',
> }
>
> if you''re not already using hiera and you don''t want to
start, then you
> could achieve something similar via conditional statements and data in your
> manifests, or perhaps more flexibly by converting your content to a
> template and putting whatever processing logic you want into it.
>
>
> John
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/AxTHFGR6x9AJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.