Develop
Build an app
From an empty repository to an app with container, VM image and update – in six steps.
The idea
An iac app only describes its target state – as an Ansible role: packages, users, files,
configuration. Plus a profile (iac.json) with ports, services and health check. iac-core takes
care of the rest:
- create the container and the VM, plus the one-liners
ct.sh,vm.shandadopt.sh - build and test the VM image, the CI
- firewall, starting services, health check,
update, modules
So an app repository stays small:
iac-myapp/
├── iac.json profile
├── tasks/main.yml the target state (Ansible) ← what matters
├── handlers/main.yml restarts
├── templates/, files/ configuration files, systemd units
├── tests/smoke.sh checks only this app needs
├── README.md, CHANGELOG.md, AGENTS.md (+ pointers for AI tools)
└── .forgejo/workflows/ lint.yml, image.yml – unchanged from the template
Ansible runs locally inside the guest – no controller, no inventory, no SSH from outside.
1. Prepare
mkdir -p ~/repositories/iac && cd ~/repositories/iac
git clone https://git.heyer.systems/iac/iac-core.git
git clone https://git.heyer.systems/iac/iac-example.git
On your machine you’ll need shellcheck, jq, ansible-core, systemd (lint) and Docker (testing
without Proxmox). Start by reading iac-example in
the order its README suggests: a small app that shows each feature exactly once.
2. Create the skeleton
iac-core/tools/new-app.sh myapp # creates iac-myapp/, never overwrites anything
The skeleton is mandatory, even when an AI tool writes the repository – don’t create the files
by hand. .forgejo/workflows/, AGENTS.md and the pointers for AI tools stay exactly as the
template creates them. Already started a repository? new-app.sh fills in whatever is missing.
3. Profile: iac.json
{
"name": "myapp",
"title": "My App",
"description": "One sentence for the website.",
"category": "web",
"tags": ["wiki", "markdown"],
"upstream": { "type": "debian", "repo": "myapp" },
"supports": ["lxc", "vm"],
"defaults": {
"lxc": { "cpu": 1, "ram": 512, "disk": 4 },
"vm": { "cpu": 1, "ram": 1024, "disk": 8 }
},
"ports": [{ "port": 80, "proto": "tcp", "description": "Web", "access": "public" }],
"services": ["myapp"],
"health": { "url": "http://127.0.0.1/" },
"access": "Web: http://{ip}/"
}
ports becomes the firewall, iac-core starts and checks services, health must answer after
every installation. category and tags place the app in the catalog. All fields:
app reference.
4. Target state: tasks/main.yml
Plain Ansible, limited to the built-in modules (ansible.builtin.*):
- name: Package myapp
ansible.builtin.apt:
name: myapp
install_recommends: false
- name: Configuration
ansible.builtin.template:
src: config.yml.j2 # templates/config.yml.j2
dest: /etc/myapp/config.yml
owner: root
group: root
mode: "0644"
notify: Restart myapp # handlers/main.yml
And the matching handler in handlers/main.yml:
- name: Restart myapp
ansible.builtin.systemd_service:
name: myapp
state: restarted
daemon_reload: true
when: not iac_build # no systemd in the image build
Stick to three rules:
- Idempotent – a second run changes nothing. Using modules instead of
command/shellgives you that for free. - Restarts only via
notify– so anupdatewithout changes doesn’t interrupt the service. - You don’t start services yourself – iac-core does that for everything in
services.
Software from outside Debian (GitHub release, own download page)? The role iac_version picks the
version to install, and the download is checked against the release’s checksum:
versions.
If the app has a login, it’s usable right after the installation. An open setup wizard on
the network isn’t. The app creates the first user with a password from secrets, access says
where it is: first login.
5. Test
iac-core/tools/lint.sh iac-myapp # typos, wrong fields, Ansible syntax, sandbox
iac-core/tools/dev-container.sh iac-myapp # install + smoke test, without Proxmox
iac-core/tools/dev-container.sh iac-myapp # second run: idempotent? (changed=1)
To poke around: docker exec -it iac-dev-myapp bash, the log is in /var/log/iac/iac.log.
An app counts as done once these points have actually run – writing them down isn’t enough:
-
lint.shwithout errors – including the sandbox of the systemd units (pattern:iac-netbox/files/netbox.service; exception only with# iac: no-sandbox – <reason>) -
dev-container.shtwice: smoke test green,changed=1in the second run - right after the installation all
portsare open andhealthanswers, without anyone setting something up in the browser - with a login: logging in with the hint from
accessworks - not from Debian: role
iac_version, download with checksum, the tested version pinned iniac.json("version", versions) – Renovate raises it later. Installed withIAC_APP_VERSION=<older version>, the update path (app reference) really moves to the pinned version - with
vminsupports:.forgejo/workflows/image.ymlexists (from the template) - steps outside the guest (reverse proxy, DNS, clients): a setup guide in
docs/GUIDE.md(app reference)
6. Publish
- Create the repository
iac-myappin the organisation iac (public) and push. Then protect it –mainand its tags – like every repository of the organisation:iac-core/tools/forgejo-protect.sh --apply(needs a token of an owner in~/.config/iac/forgejo-token; without--applyit only shows what is missing). - The CI lints every push. Every night (22:00 UTC) the VM image of an app that changed since its latest image is built, started in a test VM and only published if all checks pass.
- Once an hour the website reads all public
iac-*repositories. After that, the app page with its generator is live, along with the one-liners/myapp/ct.shand/myapp/vm.sh.
Next: app reference – all fields, variables, helper roles and common mistakes.