On Jun 9, 2008, at 3:31 PM, Ashley Penney wrote:

> 1/ When the client starts and has no environment = set, it should  
> send no information on its environment to the server.  The server  
> should check if a client returns no information, and if so it should  
> set the clients environment to whatever it has set for environment =  
> under [puppetmasterd].

> 2/ A client should never require knowledge of environments =.  If an  
> environment is set, it should send it to the server and the server  
> should parse its environments = list for a match.  If one is found,  
> proceed, if not, fail.

This is more work than you think, unfortunately.

First, realize you're being a bit loose with the definition of  
'client'; you probably mean 'puppetd', but there are clients in  
puppetmasterd and servers in puppetd, and of course 'puppet' (the  
executable) can be chock full of clients.

Rather than talking about clients vs. servers, we need to introduce a  
difference between specifying an environment and using an environment  
-- you could specify just about anything, but when going to use the  
environment, it needs to be valid.  In general, clients would specify  
an environment and servers would use them.

This means that the default environment would need to become '' (the  
empty string) on the client (which we would normally translate to  
nil), and some valid value on the server, AFAICT.

This effectively means that the puppet default environment is *always*  
nil, and users can set their own server-side default or whatever.

Given that 99% of users won't bother setting a server-side default, we  
can't really require that they do -- it would become just another  
arbitrary requirement for bootstrapping, which is a bit silly, esp.  
for those users not using environments.

This, in turn, means that the whole system now needs to be able to  
function without an environment, because we can't guarantee that the  
user has ever specified a default server-side environment.  This issue  
(and the ensuing profusion of "unless environment.nil?" conditionals)  
led me to the current state of environments.

The only resolution I can see to this problem is differentiating  
between a 'default' environment and a 'specified' environment, such  
that there's always one if we need one.  When sending our environment  
info to the server, we would only do so if an environment had been  
specified; we would never send the 'default' environment.  The server,  
in turn, could use the 'default' environment if it got nothing from  
the client.

If this is a design decision we want to make, we need to enhance node/ 
environment.rb to provide it.  I think the best way to do that would  
be something like this:

* Create a 'current' class-level method in Environment that only  
returns a value if an environment is specified.

* Modify the Environment#initialize method to use that 'current'  
method, and fail if 'current' returns nil.

* Modify all places that use environments to use Environment.new,  
rather than a string.

"Using" an environment would mean using an actual environment  
instance; specifying one would be done through the  
'Environment.current' method.

Thus, if you're using an environment, you have to create an env  
instance and you get all of the validation you want.  If you're just  
passing around a string, all bets are off and you get nothing,  
including not having those patches accepted.

> I do not think this would require any new APIs or significant  
> development, but I am unfamilar with the internals of puppet so if  
> anyone knows differently please let me know.  If you think that it  
> would be a mistake for the server to control this functionality, I'd  
> like to hear your reasoning.


I think my above discussion covers the amount of work.  I don't think  
it's a ton of work, necessarily, but it's non-trivial.

There's already environment work theoretically scheduled for  
0.24.x[1], so it could possibly be thrown in there, but it's  
relatively cross-cutting in that the modules and parser use the  
environment stuff pretty heavily (and really, they're just about the  
only ones that do), and they'd need to be modified.

I assume no one throwing out the +1's is volunteering to do this work...

1 - http://reductivelabs.com/redmine/issues/show/1183

-- 
Ninety-eight percent of the adults in this country are decent,
hard-working, honest Americans. It's the other lousy two percent that
get all the publicity. But then--we elected them. --Lily Tomlin
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to