--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
You can't. The whole purpose of facts is to allow Puppet to make decisions based on client data. Variables=server, facts=client.
On Thu, Sep 1, 2011 at 3:41 PM, Douglas Garstang <doug.g...@gmail.com> wrote:
So, after reading this doc:http://projects.puppetlabs.com/projects/1/wiki/Adding_Facts
it's not readily apparent to me how I can create facts that are derived from variables defined at the node level in puppet, rather than at the O/S level on the client. I want to be able to set a variable that defines a server type in the node, and access that. Anyone?Doug.--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@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...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
You can't. The whole purpose of facts is to allow Puppet to make decisions based on client data. Variables=server, facts=client.
Create a variable for server_class in your node definition.
--
And then assign classes based on that. Standard if logic or case statement as you prefer.On Thu, Sep 1, 2011 at 4:57 PM, Douglas Garstang <doug.g...@gmail.com> wrote:
On Thu, Sep 1, 2011 at 4:56 PM, Aaron Grewell <aaron....@gmail.com> wrote:
Create a variable for server_class in your node definition.And then....?
Ah. I don't know how mcollective works so I'm not sure how to address that. If there's a YAML data file involved then you could push it with Puppet...
--
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel,Are you referring to the 'Class Filters' section on http://docs.puppetlabs.com/mcollective/reference/integration/puppet.html ?If so, that's not really the same thing. Classes.txt lists classes included on a server. That's not what I am looking for. Life isn't always as simple as assuming that all machines within a certain functional group include the same class. You'd think so, but hey, I work for a startup, so not everything is engineered that well.
All I want to be able to do is set a variable on a per node basis that defines a functional grouping, ie a class of server, and query that with mcollective. Should not be difficult to do.
All I want to be able to do is set a variable on a per node basis that defines a functional grouping, ie a class of server, and query that with mcollective. Should not be difficult to do.
Class is an unbelievably overloaded term, but I'm gathering you mean it
in the context of identifying a group of machines, and will assume so
for the purposes of this post. I've hacked around this problem a couple
of ways in the past:
- Derive the class from the FQDN
Previous organisations have had FQDN structures like
sitename-app-01.staging.mycompany.net, and I've just written a simple
fact to extract the class from that; e.g. staging-app. I don't really
recommend this approach, as it can be brittle, it overloads DNS, and
it's not very granular. But it worked.
- Use a "helper" file
If you've got the node classification available on the puppetmaster
(e.g. node foo { $class=abc }), I've used a template to write a file
with the class details out somewhere useful like
/etc/mycompany/machine_class.
This guy seems to have taken this idea and run with it:
http://nuknad.com/2011/02/11/self-classifying-puppet-nodes/
If I was wanting to do this the "right" way, I'd be looking at hooking
mcollective up to an external node classifier in some way - that way
both Puppet and MCollective are referencing the same source of "truth".
No tips on how to actually to do this - it's just where I'd start looking.
Cheers,
Matt
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
----- Original Message -----
>
> At the end of the day, this all seems to be a limitation with
> mcollective. It can only read facts from one source, either facter
> or a yaml file. I believe facter is the current source, and people
> have written scripts that rely on that. I can write a custom fact,
> but.... then the issue becomes that I don't know if it's possible
> for a custom fact written in ruby and dropped into
> $module/lib/puppet can access variables defined in the node.
>
using the yaml file built by a template method that was linked to
any variables you set at the node level, top scope or in the class
that creates the yaml file is put in the yaml file.
Therefore you can use these files in mcollective filters, so if you
just set variables in the node to do whatever you want they will show
up in the yaml file and be usable.
As the wiki says:
"plus it lets you get any in-scope variables (for example, parameters from your external node classifier) available as mcollective filters for free."
http://projects.puppetlabs.com/projects/mcollective-plugins/wiki/FactsFacterYAML
Mcollective thus gets a combination of facts, variables etc all in one
place. You can even create many yaml files and it will read the lot for
you, one local the node, one by puppet, maybe even with facter -y etc.
and if all this fails, you can trivially write your own fact source that
does whatever you want.
--
----- Original Message -----
> Btw, Rip or anyone, any suggestion on how to sort alphabetically the
> scope variables so that the generated yaml doesn't change at (almost)
> every puppet run?
>
> content => inline_template("<%= scope.to_hash.reject { |k,v| k.to_s
> =~ /(uptime_seconds|timestamp|free)/ }.to_yaml %>")
no, unfortunately the usual method for doing this with yaml doesnt work
in puppet, probably because of their yaml not being normal yaml.
http://snippets.dzone.com/posts/show/5811
maybe one of the devs can say, I tried various methods non that I didnt
consider a hack would work.
I also filed a bug to see if certain resources can be excluded from reporting
but this got no love