On Sep 26, 2013, at 8:45 AM, Andy Parker <[email protected]> wrote:
> On Wed, Sep 25, 2013 at 7:59 PM, John Julien <[email protected]> wrote: > A third option is that an external fact has an optional metadata file > (myfacts.sh and myfacts.meta). That file can describe things like: > > * What facts do you expect to get out of the script > * What confines the script has > * Maybe a description of it? > > I encountered this same question when I played around with a rewrite of > facter (https://github.com/zaphod42/facter-rewrite) in which everything was > an external fact. I didn't implement this, but it was what I was thinking of > at the time. > > The confines can be expressed either as an s-expression style or a small > language: > > { > "confine": ["and", ["=", "osfamily", "RedHat"], ["=~", "kernelversion", > "2\.6"]] > } > > Let's just implement this for Linux :) j/k > > This is an interesting proposal. A bit complicated, but as a result very > flexible. If you recall, my main selling point for this enhancement was to > include those who are not as likely to write a fact in Ruby because it is too > complex for them. With that in mind, what are your feelings on a simplified > version of this where we only allow the confine evaluation to be a collection > of fact(s) equalling a specific value. So that might look like. > myfact.sh > myfact.sh.confine: > {'osfamily': 'RedHat', 'lsbmajdistrelease': 6} > > > Agreed, the last thing that is needed is to present a solution that we say is > to make things "easier" and then have people start the simple case by having > to learn an abstract language expressed in data structures :) > > How about a hybrid approach: > > myfacts.sh > myfacts.meta > > where meta can still contain the description, confine, etc. However instead > of immediately forcing the author to write s-expressions they can do a > simplified version as you propose. That way, we can start with the simple > equality matching (that is what a hash as the value of the confine means), > and grow to the full expressions (which would be arrays at the value of the > confine) if the need arises. > Perhaps we could implement both of our suggestions. So we have the ability to have a .confine file with simple syntax or a .meta with more advanced syntax. Internally the .confine file is just morphed into ["and", ["=", "osfamily", "RedHat"], ["=", "lsbmajdistrelease", "6"]] and passed through the same logic processor. So those that need some basic confine statements can use the .confine file. Those who want to do some more advanced things can use the .meta as well. If a confine appears in 2 places, the .meta takes precedence. As for halting the run, currently factor displays an error and continues when an external fact has a problem. Are you suggesting we change factor to halt on error for all external facts, or just the ones with malformed confine statements?
signature.asc
Description: Message signed with OpenPGP using GPGMail
