# Infrastructure as a Code

**URL:** <https://forum.openwrt.org/t/infrastructure-as-a-code/253761>\
**Category:** Installing and Using OpenWrt\
**Created:** [September 19, 2026, 6:36am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761 "2026-09-19T06:36:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![h4k1](https://forum.openwrt.org/user_avatar/forum.openwrt.org/h4k1/32/136397_2.png) [@h4k1](https://forum.openwrt.org/u/h4k1)\
**Post date:** [September 19, 2026, 6:36am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/1 "2026-09-19T06:36:35Z")

</div>

Hello!  
I would like you to ask for your ways to OpenWRT Infrastructure as a Code (IaaC) management.

OpenWRT Community created few interesting projects/setups like:

- [My fully automated OpenWrt router setup with Ansible - #6 by dekarl](https://forum.openwrt.org/t/my-fully-automated-openwrt-router-setup-with-ansible/248999/6)
- [Ansible collection community.openwrt 1.0.0 released!](https://forum.openwrt.org/t/ansible-collection-community-openwrt-1-0-0-released/245805)
- [Uapi: an http api as control plane for IaC (infrastructure as code)](https://forum.openwrt.org/t/uapi-an-http-api-as-control-plane-for-iac-infrastructure-as-code/253138)

So there are quite nice stack, although a wiki is missing a article about implementing such IaaC approach.

I created this topic to discuss your ways to obtain that that approach.

I am personally started to use [pyinfra](https://docs.pyinfra.com/en/3.x/), although as of now I am still in stage of preparing the setup, thus I did not create a topic in [https://forum.openwrt.org/c/community-builds-projects-packages](https://forum.openwrt.org/c/community-builds-projects-packages), and I wanted to hear from you about the approaches to maybe change/improve mine.

---

<div class="post-metadata">

**Author:** ![jasrusable](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jasrusable/32/55860_2.png) [@jasrusable](https://forum.openwrt.org/u/jasrusable)\
**Post date:** [September 19, 2026, 6:47am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/2 "2026-09-19T06:47:45Z")

</div>

I built OpenWrt Configurator to be a simple and easy to use UCI-like infrastructure/config-as-code tool: [https://github.com/jasrusable/openwrt-configurator](https://github.com/jasrusable/openwrt-configurator)

---

<div class="post-metadata">

**Author:** ![raspbeguy](https://forum.openwrt.org/user_avatar/forum.openwrt.org/raspbeguy/32/135696_2.png) [@raspbeguy](https://forum.openwrt.org/u/raspbeguy)\
**Post date:** [September 19, 2026, 6:50am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/3 "2026-09-19T06:50:59Z")

</div>

I wanted a reliable way to manage openwrt with Terraform. I developed uapi as control plane called by my terraform provider. I am using exclusively uapi to manage my router since a few months, it works well.

---

<div class="post-metadata">

**Author:** ![\_bernd](https://forum.openwrt.org/user_avatar/forum.openwrt.org/_bernd/32/124645_2.png) [@\_bernd](https://forum.openwrt.org/u/_bernd)\
**Post date:** [September 19, 2026, 7:16am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/4 "2026-09-19T07:16:31Z")

</div>

For myself I use bash based tooling and each device gets its firmware build with a local image builder and then I flash everything.

🤷

---

<div class="post-metadata">

**Author:** ![h4k1](https://forum.openwrt.org/user_avatar/forum.openwrt.org/h4k1/32/136397_2.png) [@h4k1](https://forum.openwrt.org/u/h4k1)\
**Post date:** [September 19, 2026, 7:48am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/5 "2026-09-19T07:48:16Z")

</div>

> [@\_bernd](#):
>
> For myself I use bash based tooling and each device gets its firmware build with a local image builder and then I flash everything.

In case you want to change something you reflash the device?

---

<div class="post-metadata">

**Author:** ![\_bernd](https://forum.openwrt.org/user_avatar/forum.openwrt.org/_bernd/32/124645_2.png) [@\_bernd](https://forum.openwrt.org/u/_bernd)\
**Post date:** [September 19, 2026, 8:08am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/6 "2026-09-19T08:08:29Z")

</div>

Yes.

For really small changes like adding an extra vlan I have small helper scripts which just place the config and restart the network

But the norm is reflash and reboot.  
In a home network the frequency of chances are quiet low. Even in most Soho environments so if you don't reflash every single day it should be no issue...

---

<div class="post-metadata">

**Author:** ![russoz](https://forum.openwrt.org/user_avatar/forum.openwrt.org/russoz/32/126732_2.png) [@russoz](https://forum.openwrt.org/u/russoz)\
**Post date:** [September 23, 2026, 6:42am UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/7 "2026-09-23T06:42:02Z")

</div>

Hi @h4k1

I am the maintainer of the community.openwrt collection in Ansible - by the way, [Ansible collection community.openwrt 1.8.0 released!](https://forum.openwrt.org/t/ansible-collection-community-openwrt-1-8-0-released/253832) yesterday.

I cannot do the comparison with the other projects and, TBH, I am a big defender of testing things and finding what makes sense for you. I used Ansible to manage my home computers, and I was sick and tired of that lousy router provided by the ISP, so when I decided to buy a new one, I _wanted_ to have something that I could use Ansible to configure. OpenWrt was hitting the sweet spot between features and affordability, then I used an existing Ansible role to manage the router and, eventually, I wanted to improve it. Long story short, now I am taking care of the OpenWrt collection.

The announcement above already spills the beans on what we are doing right now: natively, Ansible works with Python and Powershell. We had to come up with a framework of sorts to make it work with shell script (derived from that previously existing Ansible role - it was the base for the collection code), but using shell script for it is quite cumbersome, so we are [writing a similar framework to run the modules in `ucode`](https://github.com/ansible-collections/community.openwrt/pull/272). My plan is to eventually migrate all the modules to ucode and remove the legacy shell-based stuff.

If any of that catches your eye, by all means, hop on the bandwagon. If you'd rather go with `pyinfra`, by all means, go and make something awesome there 🙂 I am happy to share our experience on c.openwrt, so that you don't fall on the same traps we did before. The first thing I would say is: if you do not want to force the installation of Python on the router (our case), go straight to ucode, don't even think twice.

---

<div class="post-metadata">

**Author:** ![h4k1](https://forum.openwrt.org/user_avatar/forum.openwrt.org/h4k1/32/136397_2.png) [@h4k1](https://forum.openwrt.org/u/h4k1)\
**Post date:** [October 3, 2026, 10:11pm UTC](https://forum.openwrt.org/t/infrastructure-as-a-code/253761/8 "2026-10-03T22:11:04Z")

</div>

@russoz Cool job, thank you very much! I have chosen pyinfra just to be a hipster lmao. Literally that was the only reason to do so (okay, IaaS in Python instead of YAML seems nice too), as I have used Ansible in my job, so I wanted to try sth new. In general [pyinfra](https://pyinfra.com/) is using plain ssh connection via [paramiko](https://pypi.org/project/paramiko/), and luckily I did not need anything more than apk (opkg is supported as well).

The most wanted feature for me as of now is Firewall as a Code - pyinfra have support for `iptables` only, thus it is unusable with `pyinfra`, although luckily there is sth to work on.

I think I would like to create a PyPI package for such solution - it should maintain a firewall state, and compare it with the generation. I do not like current OpenWRT solution, as when there is many rules (like I have) it becomes hard to read.
