Author Posts

July 25, 2018 at 3:14 pm

According to this page in the DSC documentation, "Typically (though not necessarily always), DSC applies the resources in the order that they appear within the configuration." The author suggests using DependsOn when order would definitely matter, as in the case of a prerequisite.

However, to make things as consistent as possible in my environment, I'd like to run in order all the time, every time. That way there is no chance of two machines being different in an unexpected way because the configuration was applied in a different order for each.

Does anyone know exactly what the circumstances are under which the resources aren't applied in order? Maybe they are so rare and avoidable that DSC does, for my purposes, always run things in order.

If nobody knows, what are my options for getting things to run in order all the time? One would be to put a DependsOn property on every resource, referencing the previous resource.

What about the MOF? Is it guaranteed to always run in order? I suspect not, since the DependsOn parameter shows up there as well. But if I'm wrong and it is always run in order, I could tailor or at least check it to verify the ordering.

July 25, 2018 at 3:43 pm

However, to make things as consistent as possible in my environment, I'd like to run in order all the time, every time. That way there is no chance of two machines being different in an unexpected way because the configuration was applied in a different order for each.

Not possible.

The LCM was designed to eventually be multi-threaded, so there's no predictability in the order resources execute. Now, between you and me? They'll run in the order listed, after it unwinds DependsOn dependencies. But that's today; we might not be able to rely on that in the future, especially as the new, cross-platform, C++ LCM under development may well implement multi-threading.

What about the MOF? Is it guaranteed to always run in order? I suspect not, since the DependsOn parameter shows up there as well. But if I'm wrong and it is always run in order, I could tailor or at least check it to verify the ordering.

You may have a misunderstanding. The MOF is the only thing that "runs" on the LCM. The configurations script you write doesn't "run" per se; it simply generates a MOF. The MOF is the thing you care about.

what are my options for getting things to run in order all the time? One would be to put a DependsOn property on every resource, referencing the previous resource.

Yes, you could do that, but I've literally never run into a situation where it's necessary. Remember, the goal of DSC is to -eventually- comply with the entire config. In all the work I've done with all the clients I have, I've never run into a situation where applying resources in different sequences changes anything. Except in obvious cases where A has to be done before B (like, must join the domain before you can do things in the domain).