Backport using OrderedDict when parsing pillar top file
Master module, accepted into salt repo but they moved it to salt/modules/saltutil
Adds a visible error when jinja templating fails?
Absolutely no idea, I don't think I did this
Fixes cached grain access race condition.

When highstating, pillar items is called first. If using master module and
attempting to use cached grain information from data.p, there is a race
condition as data.p is opened w+ to write the up to date pillars. So if one
minion truncates its data.p because it finished first, and some other minion
needs grains from the first minion's data.p, there will be no information and
cached_grains call will silently fail.

Also, previous code was susceptible to errors caused by nodes that errorred
during salt-cloud provisioning: grains should only be referenced if a minion
has an entry in pki and a cached grain (because all minions must have an initial
grains file from provisioning). If either of those conditions is not met, grains
aren't even looked up for that minion (because the lookup would most certainly
fail).