Recently I've been thinking about writing an automation management tool like Ansible or Chef. My idea is to have a controller that on each distinct execution of the automation "script" compiles a Roc-based DSL to WASM and sends it to a node that executes it, then they communicate via ssh or some other protocol.
One thing that Ansible has that annoys me is that variables can be defined in many places and then values get overridden in a predefined order that's hard to remember for me. One of those places is inventories that define the nodes and groups those nodes belong to (e.g. webservers, routers, databases), so an inventory in roc could look like this:
nodes = [
{ host: "192.168.0.1", name: "router", groups: [ Router { outPorts: [8080, 25] }, Home] },
{ host: "192.168.0.2", name: "server", groups: [
Web { port: 8080, dbCred: { user: "postgres", password: Secret "dbpass" } },
Mail { port: 25 },
Home,
] },
{ host: "10.0.0.10", name: "database", groups: [ Database, Vpn ] },
{ host: "10.0.0.20", name: "website2", groups: [ Web, Vpn ] },
]
groups = [
Web { config: "config common to all web servers" }
Home { }
],
and then you could write scripts like:
main = \{ node, global } ->
for group in node.groups
when group is
Web { .. } -> setupWeb! host
Mail { .. } -> setupMail! host
_ -> { /* etc */ }
setupWeb = \host ->
install! Nginx
template! { src: WebsiteConfig, dest: "/etc/ ..."}
(now when I look at this it looks weird, but I want to write this up quickly, I believe you get the idea)
It would also need a way of matching for a node that is a webserver in location Home, an algorithm to merge variables in groups and some configuration utilities like access to package managers, network configuration, templating for config files etc. Also for simple things this is probably not that useful, but my use case is managing several different production environments, where each has individual configuration and contains 10-50 nodes.
Does anyone have any opinions on how Roc might be used in this project? Lately I have not been following every new added feature so there might be something that I'm missing.
One thing that I already see might be difficult with this setup is "dynamic inventory" where the inventory is fetched from some third-party source.
(also, sorry if the example does not look like valid Roc, I have not actually started implementing this yet)
I’ve thought for a while that Roc would be good for a use case like this! Also for modeling IaC like Terraform
Last updated: Jul 06 2025 at 12:14 UTC