Translating Ansible roles to Python turns infrastructure logic into ordinary code: unit-testable with pytest, checkable with type checkers and linters, and free of the expressive ceiling of a YAML DSL with a templating dialect. Until now the problem has been intractable, because Python had no configuration-management library shaped like Ansible to translate into — an AI asked to rewrite a role improvises a different pile of subprocess and SSH calls every time, losing idempotence, fleet orchestration, dry-run preview and change reporting along the way. Reemote is that library: a Python framework whose facts, operations and module vocabulary line up with Ansible's, giving the translation a bounded, reviewable destination. It is ready to use and download today, with documentation at reemote.org and the full source, examples and tests in the EPL-2.0 git repository.
The problem
An Ansible role is not merely a list of commands. It inherits its operational guarantees from the engine that runs it: lock-step execution across the fleet, --check mode previewing changes against live state, and per-task, per-host reporting of what actually changed. A translation into ordinary Python with no target framework loses all three. The generated script shells out to apt-get, checks a return code, and wraps the sequence in a try/except — it reproduces the role's happy path while discarding the machinery that made it safe to run on production infrastructure.
The cause is structural, not a deficit of model capability. A large language model generates by matching patterns, and translation succeeds when a canonical target idiom exists to converge on. "Translate an Ansible role to Python" has had no such destination: what Python offered instead were wrappers that launch Ansible itself, general SSH-execution libraries, and raw building blocks. With no pattern to match, every generation re-derives a different arrangement of those primitives, and spending more tokens produces longer, better-commented output but not convergence.
Why it is interesting
The prize is real. In Python, infrastructure logic becomes testable with standard frameworks, analysable before deployment, and expressible without a DSL's limits — variables become typed data structures instead of a templating dialect, and complex computations live beside the deploy instead of being shelled out to a second toolchain.
And the diagnosis points at a fix that is tractable. If the bottleneck is a missing target idiom rather than a weak model, then building the idiom changes the problem's shape: with a library whose vocabulary lines up one-to-one with Ansible's, translation collapses from "design a configuration-management system" to "map each task onto the operation that already does this." That second task is exactly what models are good at, and it is bounded enough that a human can review the output the way they would review any pull request. For this migration, the choice of library dominates the choice of model.
The solution
Reemote is configuration management as a Python library rather than a CLI. A deploy is a plain synchronous generator yielding operation requests; plans, report, hosts = await run(inventory, deploy) executes it. Five properties make it a translation target:
- Async end to end on asyncssh — the runtime supplies fleet-wide concurrency with per-host ordering, so the generated code never invents it.
-
Structured results — a run returns a plan and a per-operation report of what changed, why, and the exact commands sent;
dry=Truerestores the lost dry-run as data a program can assert on. -
A one-to-one module vocabulary — twenty modules cover package managers, files, services, firewalls, system configuration, keys, databases and containers, so
apt_repositorymaps toapt.repo,lineinfiletofiles.edit,get_urltofiles.download,servicetosystemd.service. - Pure functional deploys — the runner executes every deploy twice, plan then apply, and raises if the passes disagree; typical model mistakes are caught at plan time, and the code is testable without servers.
- No awareness of the controller's file system — content is an explicit string or a caller-opened stream, never a controller path, so a converted program is self-contained and portable.
It is ready to use, with the migration guide working through every construct that does not map one-to-one.
What follows from the solution's structure
Because the target is a library with a fixed vocabulary and pure, testable deploys, every correct conversion becomes a reusable pattern — and the repository ships them. Alongside the library source, the EPL-2.0 repo contains close to four hundred runnable example programs, executed by the example runner and exercised by the test suite. You can read them, copy them, and hand them to a model as context without a licensing question hanging over the output.
Ten of them are automated translations of Ansible Galaxy roles, under examples/roles/: Jeff Geerling's Apache, Docker, Java, Memcached, NFS, nginx, NTP, PHP and PHP Xdebug roles, and DataDog's official agent role. Each covers the role's default path on one operating-system family and ships with an offline test suite driving it end-to-end against a simulated host through the real execution driver; the central assertion is idempotence — a second run against the same state reports no changes and queues no handlers. All ten pass. Between them they demonstrate handlers as a second deploy pass, role variables in the inventory, pre-rendered templates, and a build-from-source branch.
The practical consequence: when you migrate your own role, do not ask the model for "Python" — ask it for the shape of the closest converted role. The model then imitates a verified, tested, in-repo program, and its job shrinks from designing an architecture to adapting one that already works. The same programs give a human reviewer a known-good standard to judge the output against.
The structure also makes the conversion itself mechanisable, and Reemote Control, the licensed edition, is where that is taken further. It contains Python equivalents of many programs from Ansible Galaxy — ready to run rather than ready to translate, for when the migration you want is to adopt a maintained equivalent, not to author it. And it ships skills that drive the conversion: packaged agent workflows carrying the module vocabulary, the construct recipes, and the determinism discipline, which direct an agent to audit a role's tasks, map each onto an existing operation, prove and rank any capability gaps rather than paper over them with shell one-liners, shape the program on the converted roles, and verify it with offline idempotence tests. The conversion stops being a prompt you hope works and becomes a workflow you can run again on the next role.
Ansible Galaxy's value was never the YAML — it was the accumulated, working configuration knowledge. Transpiled to Python, that knowledge carries over: the open repository proves the method and seeds the corpus, and Reemote Control is where much of the catalogue, and the machinery to grow it, lives.
More information
- Documentation: https://reemote.org/
- Ansible role migration guide: https://reemote.org/migrating/
- Converted roles: https://github.com/kimjarvis/reemote/tree/main/examples/roles
- Source repository: https://github.com/kimjarvis/reemote (EPL-2.0)
-
PyPI:
pip install reemote
Top comments (10)
This is pretty amazing on so many levels! Transpiling Ansible into Python is a fantastic technical achievement. What this short article fails to mention is why you might want to do it. I can think of plenty of reasons, here are some:
Thanks Rick,
That's right, driving deploys from python is the primary use case. We use NiceGUI as a wrapper for GUI applications and FastAPI to create end points for a deploy.
I certainly wouldn't be trusting AI with my Playbooks.
But, this library isn't just about AI, it seems to be a complete configuration management system. I'm wondering why I haven't heard of it before.
The web site has tutorial, which is easy to follow. There is a way to run the examples using docker containers so you don't need a server to try it out. There are hundreds of examples.
This software is part of a commercially available application. It was released in November 2026 (two weeks ago).
It is being released to the open source community under the EPL-2.0 to foster collaborative development, improve software reliability, and encourage community contributions and issue identification.
The library looks like its been AI generated in China. Not that there is anything wrong with that, but its telling. US DevOps has been all about Ansible. Maybe, the Chinese government have decided they don't want to go down that route. I wouldn't be surprised.
I've visited China a couple of times for business and I've experienced their enterprise software market first hand. Its a very different world. Its all about service and competition is cutthroat. Very difficult to sell anything and very difficult to keep it sold if you ever manage it. Customers seem to really care how deliverables are written and ask endless technical questions. They have a particular aversion to PHP. Somehow, I can't see them putting up with Ansible for very long.
Ansible is used in China. There is no edict against using it. But, products containing Ansible (or especially PHP) just don't tend to sell here. As you say the Chinese market is very different, enterprise customers take a great interest in the internals of anything you try to sell them. If they see Ansible being used anywhere in an enterprise product, in an upgrade script for instance, or PHP being used for maintenance scripts, they just shy away, and they don't tell you why.
In the US you cannot really make a technical or business case for re-writing or transpiling working Ansible into Python. But, if you find that Chinese customers aren't buying your product for some mysterious reason. Then you have a business case right there.
Very interesting. What is the difference between this library and Pyinfra ?
They are close. Reemote started as a Pyinfra fork. Pyinfra is not Async (yet). So, Reemote was written from the ground up to be Async.
I this from Neusoft ? Who sells the licensed edition ?
No, TPF Software Services S.A.