On 12/12/2012, at 9:09 PM, Torsten Curdt <
tcu...@vafer.org> wrote:
>>> I am wondering if we should expose information on whether a dep needs a new session and then have babushka handle the creation of a new session if needed.
>>
>> The issue with this is that then you have deps that only run properly in a specific state, that isn't the default. I'd rather avoid dependencies of state.
>
> Not sure we are on the same page here. Could you elaborate?
>
> Right now I would have to split provisioning into sessions manually. Think of it as provisioning phases:
>
> babuska tcurdt:vserver-phase1
> babuska tcurdt:vserver-phase2
That's exactly what I do. For example, when provisioning our CI agents (which are vagrant VMs), I have two deps:
'ci prepared' # Sets the locale and installs the correct ruby
'ci provisioned' # Does everything else
The locale issue is only one of a more general case: sometimes the running babushka would run differently because of a change that a dep made. Whether that's a new locale, or a new ruby that babushka will run against next time, etc.
> Also keeping track of the interdependencies manually
This isn't an issue, because 'ci provisioned' requires 'ci prepared'. By the time you get to running 'provisioned', 'prepared' should already be met -- but there's no need to manually track dependencies. The requirements are still just the actual requirements of each dep; there's just an initial subset that run separately.
> Now if a dependency was marked as "needs new session" babushka could analyse the tree and create new sessions whenever necessary. Does that make sense?
>
> It's essentially what I am doing manually for a Vagrant deployment.
>
> How does that introduce state?
The state is that session that babushka would be creating. It's not the real session, only a simulation.
For example, say you run "postgres.bin", which calls "set.locale"; the locale is set, and postgres is installed within the simulated environment, so the locale is correct. Babushka says "all done" and drops you back to a shell -- but that shell still has the old locale, and so creating a database using it wouldn't do what you expect.
The state involved in constructing that temporary session is the problem. This stuff can only be reliable when it's running against an actual, current session, otherwise it's hypothetical and will cause surprises.
>> My principle is to do things how I'd do them manually, which is just to log out of the box and back in.
>
> Yuck - that's not really an option for me. Especially not with Vagrant. "Just keep running until there is no error anymore". Meh.
As I explained above, I don't think that's what this is :) It's not about retrying after a failure at all.
It's simply being honest about the fact that after you change locale, rubies, or whatever, the current session is no longer valid: it no longer represents the system, and so should be replaced with a new one before continuing.
> Yeah, I saw it in the code but how do pass the variables to specific dependency? Can you give an example?
You can only pass an argument to the top-level dep -- that's by design, because I intended dep parameters to feel as much like method parameters as possible.
If you have to pass a value to a specific dep, one option is to run that dep separately in the Vagrantfile first. Then when the dep that requires it is run, it will already be met.
>> (Old-style vars are deprecated and about to be removed.)
>
> What's the old style?
Dep parameters are a replacement for vars -- whose removal date has now passed, woohoo I can delete so much code now! :)
They were inline-defined, e.g.
met? { shell('whoami') == var(:user) }
The main problem with vars was that they were global across all deps, and hence were a whole bunch of set state. It was really hard to tell why a certain var had the value that it did, i.e. which dep set it, and when. It also led to a lot of cases where changing a dep would break something in another dep.
Dep parameters have totally fixed that; I'm really pleased with how they've turned out.
Cheers
Ben