Does Ansible Remember Between Runs? No State File, No Record. Every Playbook Run Starts by Asking the Machines What Is True Now.
Does Ansible Remember Between Runs? No State File, No Record. Every Playbook Run Starts by Asking the Machines What Is True Now. Ansible remembers nothing between runs, and that is a design decision, not a missing feature. Ansible is a configuration management tool: you describe the state you want a fleet of machines to be in, as YAML playbooks, and Ansible connects to each machine over SSH, works out what differs from your description, and changes only that. There is no database of past runs b
Does Ansible Remember Between Runs? No State File, No Record. Every Playbook Run Starts by Asking the Machines What Is True Now.
Ansible remembers nothing between runs, and that is a design decision, not a missing feature. Ansible is a configuration management tool: you describe the state you want a fleet of machines to be in, as YAML playbooks, and Ansible connects to each machine over SSH, works out what differs from your description, and changes only that. There is no database of past runs behind it, no state file on the control node, and no agent left running on the machines. When a run ends, the knowledge it built up ends with it.
That sounds like a gap until you see what replaces memory. Ansible does not need to recall what a machine looked like yesterday because it asks the machine what it looks like right now, at the start of every run. The trade is deliberate, and understanding exactly what is re-asked, what little can be cached, and what is gone for good explains both Ansible's simplicity and the blind spot every automation and AI agent layered on top of it inherits.
Facts: re-learned from scratch on every run
At the start of a play, Ansible runs its setup module on each managed host and collects facts: the operating system and version, IP addresses, CPU and memory, mounted disks, network interfaces, and dozens of similar details. Those facts become variables your tasks and templates can branch on, so a playbook can install one package name on Debian systems and another on Red Hat systems without you hard-coding either.
None of that survives the run. The facts are gathered into memory for that execution, used, and discarded. Run the same playbook an hour later and Ansible gathers the same facts again, because from its point of view there is no earlier run to consult. If a machine changed in between, the new facts simply reflect the new reality. If nothing changed, the gathering work is repeated anyway. Freshness is guaranteed precisely because nothing is remembered.
There is one optional exception. Fact caching can store gathered facts in a backend such as a JSON file or Redis, with a configurable timeout, so consecutive runs can reuse recent facts instead of re-collecting them. It is off by default, it holds machine descriptions rather than run history, and when the timeout expires the cache is treated as absent. It speeds up large fleets. It does not give a playbook a past.
Idempotence: the substitute for memory
Tools that keep state can compare yesterday with today. Ansible instead makes each task check before it acts. A task that asks for a package to be present first inspects whether the package is installed, and only installs it when it is missing. A template task renders the file and rewrites it only when the rendered content differs from what is on disk. That is why a run reports each task as ok or changed: ok means the machine already matched the description, changed means the run actually modified something.
Run a well-written playbook twice and the second run should report changed=0 across the fleet. That property, idempotence, is what makes playbooks safe to run on a schedule or from a CI pipeline without side effects piling up. But notice what it proves and what it does not. It proves the machines now match the description. It says nothing about why a change was needed, who or what caused the drift, what the previous run decided, or what an operator noted while reviewing the output. The playbook converges the present. It keeps no account of how the present came to be.
The gaps show up in predictable places. Remove a task from a playbook and nothing removes the thing that task used to manage, because Ansible holds no record that it ever created it; retiring something takes an explicit task that says absent. Variables registered during a run, and facts a playbook sets for itself with set_fact, live only for that execution and the hosts it touches. Handlers, loops, and conditionals all resolve inside the run and leave no trace the next run can read.
What this means for agents driving Ansible
Scheduled automation built on Ansible inherits the same shape. A nightly playbook run by cron, AWX, or an AI agent starts each night with facts and a description, and nothing else. It cannot know that last night's run already tried a fix and watched it fail, that a service was deliberately left stopped for maintenance, or that a human approved an exception for one host on Tuesday. Unless someone builds that record somewhere else, every run re-derives the world from the machines and the YAML, and every decision made along the way evaporates when the run finishes.
That record is the piece worth adding, and it belongs outside the playbook. Vilix AI is a shared memory layer that the tools in a stack connect to over MCP, so an agent preparing tonight's run can read what previous runs did, decided, and learned before it touches a single host. It is cloud-hosted with zero infrastructure to run, and the same memory is available everywhere the agent works, not locked inside one control node. It keeps full conversation history, not just extracted facts, so the reasoning behind a change survives alongside the change itself. There is a free plan that stays free forever, a 7-day Pro trial that needs no card, and your memory can be exported or deleted at any time.
Ansible's answer to memory is to have none and re-ask the machines instead. For converging configuration, that answer is elegant and proven. For automation that is expected to learn from its own history, the history has to live somewhere. Give the runs a memory they share, and each night starts from everything the previous nights already know.