Ansible - Generate Rundeck Inventory
Refreshed June 2026: the original version of this post generated Rundeck’s
resources.xmlby hand, with a templated play and a couple ofsedcleanups. You do not need any of that now. The official Rundeck Ansible plugin reads your Ansible inventory directly, so Rundeck and Ansible stay in sync with zero generation step.
Background
What I wanted in 2015 was simple: have Rundeck show the same hosts that Ansible was already managing, without hand-maintaining resources.xml. My approach back then was a tasks file that pinged the hosts, templated out a resources.xml, and then cleaned up the result with sed. It worked, mostly, but it was fragile and it was solving a problem that Rundeck now solves for you.
The Modern Way: Ansible Resource Model Source
The Rundeck Ansible plugin ships an Ansible Resource Model Source. Point it at your inventory and Rundeck imports the hosts as nodes. Host groups come across as tags, and facts are discovered automatically. There is nothing to generate and nothing to keep in sync.
Setup, once the plugin is installed on your Rundeck server:
- Open your project and go to Project Settings > Edit Nodes.
- Choose Add a new Node Source and select Ansible Resource Model Source.
- Set the path to your Ansible inventory file and, if you use one, your
ansible.cfg.
That is the whole job. The same inventory Ansible runs against is now the node list Rundeck sees, and it updates whenever your inventory changes. The plugin also provides a node executor and file copier, so Rundeck can run through ansible and ansible-playbook directly. See the official Integrate with Ansible guide for the current options.
If You Want A Generated File Instead
If you specifically need a resource file (for an air-gapped Rundeck, or a setup where the plugin is not an option), generate it from the inventory Ansible already knows about rather than templating XML by hand. ansible-inventory dumps the full inventory:
ansible-inventory -i inventory.yml --list
Feed that into a small converter and serve it through Rundeck’s URL or script resource source. Rundeck also accepts a YAML resource format, which is far less painful to produce than the old resources.xml plus sed dance.
Why Not The Old Way
The 2015 tasks file pinged hosts, wrote XML from a Jinja template, then ran sed twice to strip characters the template left behind. Every one of those steps was a place to break, and the quoting in those sed calls was its own small adventure. The plugin removes the entire pipeline. Let Rundeck read the inventory and move on.
Conclusion
Same goal, a decade later: keep Rundeck and Ansible looking at the same hosts. The answer now is to stop generating anything and let the Ansible Resource Model Source do it.
Enjoy!
Comments