project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Feature] Add Ansible support

Open stdevel opened this issue 3 months ago • 11 comments

Describe the feature

As PegaProx has a REST API, it would be nice having the possibility to automate configuration via Ansible. This would enable rapid deployments and configuration.

Use Case

I'm often creating a larger number of PVE installations, to speed up the deployment I'm using Terraform and Ansible. Having those machines also integrated and configured within PegaProx would save me time.

Alternatives considered

Manual configuration

How important is this for you?

It is a nice to have feature that would improve my workflow.

Checklist

  • [x] I have searched existing issues and discussions to make sure this hasn't been requested before; might be related to #104 though (OpenAPI spec?)

stdevel avatar Aug 15 '26 09:08 stdevel

Makes sense — with the REST API already there, Ansible (and Terraform, per #104) are the natural next step for anyone provisioning Proxmox at scale.

You've actually put your finger on the real enabler: a documented OpenAPI/Swagger spec. Once the API surface is described formally, both an Ansible collection and a Terraform provider can largely be generated and kept in sync from it, rather than hand-maintaining each. So the practical order is spec first, tooling second — and it means the two requests (#104 + this) share the same foundation.

I can't put a timeline on it — we're a small volunteer team with a long roadmap — but it's a sensible direction and I've noted it alongside #104. If anyone in the community wants to prototype a collection against the current API in the meantime, we're happy to help point at the right endpoints.

(Unrelated: if PegaProx saves you time, a small donation via https://opencollective.com/pegaprox helps us carve out hours for exactly this kind of automation work. No pressure.)

mkellermann97 avatar Aug 15 '26 13:08 mkellermann97

Hey @stdevel,

thanks for raising this issue and also thanks for the nice chat at the FrOSCon!

As I just also recently created the Ansible modules for Proxmox (cluster, storage, node, [...]), as well as for Sylve (vm, jail), I can also work at the Ansible module for PegaProx. It might make more sense do directly get this into the upstream Ansible collections, so I personally would immediately push it there - ack?

For Terraform, we should probably keep it in #104. I'm not suited for that one ;)

@MrMasterbay, @mkellermann97: Feel free to assign me this task.

Cheers, gyptazy

gyptazy avatar Aug 16 '26 13:08 gyptazy

Thanks @gyptazy — that'd be brilliant, and honestly the ideal outcome. Given you already maintain the Proxmox (and Sylve) Ansible modules, a PegaProx module going straight into the upstream collections makes a lot of sense: better discoverability and one less thing to carry in-tree. Go for it — consider it yours. 👍

One pointer from our side when you start: PegaProx auth is token-based (Settings → API Tokens) with per-token scoped permissions, so the module should lean on a scoped API token rather than the session cookie. Happy to hand you the exact endpoints + permission slugs whenever you're ready — just ping.

Terraform staying in #104 sounds right. Assigning this one to you.

— Marcus

mkellermann97 avatar Aug 16 '26 13:08 mkellermann97

wrote a role to install pegaprox if anyone is interested (as a start, you might want to get rid of nginx): https://github.com/selfhostx/ansible/tree/main/roles/pegaprox . does not help with populating preferences etc. so slightly off-topic here

stefanux avatar Aug 19 '26 22:08 stefanux

Hey @stefanux,

wrote a role to install pegaprox if anyone is interested (as a start, you might want to get rid of nginx): https://github.com/selfhostx/ansible/tree/main/roles/pegaprox . does not help with populating preferences etc. so slightly off-topic here

Thanks for creating this, appreciated! Even this is a slightly different scope, it a great value and addition.

Just to make sure we all are on the same page: Within the issue’s scope, @stdevel wishes to be able to orchestrate the PegaProx API by a module, to perform actions like creating clusters, managing them (e.g., running periodic node updates, deleting outdated snapshots and more), so that you can automate the tasks you usually would click within the PegaProx interface.

Cheers, gyptazy

gyptazy avatar Aug 20 '26 04:08 gyptazy

Having a role to install PegaProx in the first place is also very valuable. So if a Ansible Collection is created anyway, it could also become part of it? Just thinking out loud 🙂

stdevel avatar Aug 20 '26 06:08 stdevel

@stdevel Installation roles are seperate from modules which configure pegaprox (see community.proxmox), sorry i hijacked this issue, created #723 for this task

stefanux avatar Aug 20 '26 17:08 stefanux

Hey everyone,

within the last days I started with some integrations and think that my first approach by having a single module pegaprox wasn't that good. Rather than having a single module, we should probably go the same way like the Proxmox collections did, and create different sub modules like:

  • pegaprox
    • Core
    • Orchestrating PegaProx itself
  • pegaprox_cluster
    • Cluster Management
    • Adding/renaming/deleting clusters
  • pegaprox_nodes
    • [...]
  • pegaprox_security
  • pegaprox_pbs
  • pegaprox_storage
  • pegaprox_vms [...]

I think this makes it a bit easier to use rather than having a full fledged module with thousands of options which might not even be combined at all.

Cheers, gyptazy

gyptazy avatar Sep 21 '26 09:09 gyptazy

Splitting it the way the Proxmox collections did makes sense to me — one module that has to cover clusters, VMs and backups ends up with a parameter list nobody can read, and the sub-module split is what people coming from community.proxmox will expect anyway.

Not my call on the shape though, tagging Nico.

Marcus

mkellermann97 avatar Sep 21 '26 13:09 mkellermann97

The blocker named in this thread a month ago is gone: the OpenAPI spec now exists, generated from the route table rather than hand-written, and it lands on Testing as docs/openapi.json (plus a readable docs/openapi.md).

@gyptazy - that should be the thing you were waiting on for the sub-module split. A few notes from building it, because two of them will bite a generator:

  • The spec is generated from the live Flask URL map, so it cannot drift from the routes by accident. A test compares the two on every run and fails if a route appears, disappears or changes its permissions without the spec following.
  • A missing @require_auth does not mean "unauthenticated". 14 of the 838 operations authenticate inline instead, and a first pass that trusted the decorator alone marked them public - which would have been wrong and, in a generated client, dangerous. Every operation therefore carries x-pegaprox-auth: decorator | inline | public (801 / 14 / 23 today), so you can tell the three apart instead of guessing.
  • operationIds are deduplicated deterministically, so regenerating gives you the same names.

Auth is unchanged from what was said earlier: a scoped API token from Settings -> API Tokens, with per-token permissions - and the permission each route needs is in the spec, which should make it straightforward to document what a given module actually requires.

Terraform stays out of scope on our side (see #104), so this is the tooling path we are backing.

mkellermann97 avatar Sep 28 '26 20:09 mkellermann97

Hey @mkellermann97,

awesome news, thanks!

gyptazy avatar Sep 28 '26 20:09 gyptazy