Fact evaluation basically works in two steps.
- Define all possible resolutions for a fact and score them. Each definition has two parts:
- Metadata / criteria to use for scoring
- A block of code (unexecuted) to be run ONLY if the fact "wins"
- Pick the highest-scored fact resolution (the winner), and execute it's code block to set the fact value
The problem in your code is that you've pre-empted Facter's normal process by forcing it to choose a winner early, before all the possible resolutions had been defined. You put your Facter.value('datacenter') in the metadata / criteria section of your custom fact resolution.
When Facter started reading defintions and reached this one, it was forced to stop, score all the definitions it knew about already, and pick a winner from them, in order to come back with a value for Facter.value('datacenter').
Any definitions it hadn't finished reading in effect never made it into the race. So even if they would have won, it didn't matter. They got skipped, disqualified.
Once Facter.value('datacenter') was resolved, the race was over. Any subsequent calls returned the early winner. No re-dos.