Is there an “official” way to track state between module calls? I’ve come up with one option where I read a state file on each invocation, update the data and then write out the state file at the end, but it seems like this should be able to be done in memory without having to constantly read/write to a file.
I did attempt to accomplish this task by using a fact and at first it seemed like it was going to work. I was reading the fact in the setup module. However, the data returned from the setup module seems to always be the facts as they would appear at the beginning of the run and don’t include any modifications (including variables updated/added with set_fact). This isn’t super surprising, but leaves me back where I began – trying to figure out a way to track state that doesn’t rely on a bunch of file access.
If the answer is that it’s just not possible given the way ansible works, that’s fine, I just figured I would check as it seems like I must be missing something.
I did look at the stats module early on, but you make a really good point. I’ll revist that module and see if I can steal some ideas from it. If not, I can always stick with a state tracking file.