feat: station setup wizard in site_config - #72
Merged
Conversation
MateoLostanlen
commented
Jul 14, 2026
Member
- Turns the site_config Streamlit app into a full station setup wizard: API org/user/camera creation (capturing camera and pose ids), host_vars generation with ansible-vault encryption, idempotent hosts_prod updates, and init-one-engine launch through the pyro-ansible container.
- Non-secret inputs and API results persist to gitignored per-site drafts so a Streamlit restart loses nothing; secrets stay in memory and the vault file is never written unencrypted.
- Hardens init_script API helpers: no credential printing, request timeouts, real errors on non-2xx responses.
Remove credential print in get_token, add request timeout, and raise a real error on non-2xx responses instead of an assert.
Single-page Streamlit app covering the whole new-engine flow: create org/user/cameras in the alert API (capturing camera and pose ids into config_json), write host_vars/<site>/vars.yml and an ansible-vault encrypted vars.vault.yml in the sister repo, idempotently add the host to inventory/hosts_prod (auto reverse_ssh_port, site group), and run make init-one-engine through the pyro-ansible container. Non-secret inputs and API results are auto-saved to per-site drafts (gitignored) so a Streamlit restart loses nothing; secrets stay in memory only.
- never write vars.vault.yml in plaintext: fail if ansible-vault or the vault password file is unavailable - recover pose ids from the API for pre-existing cameras - block vars.yml writing until every camera has a captured API id - reconcile ansible_host/reverse_ssh_port of an existing hosts_prod entry - gate init-one-engine launch on host_vars files and inventory entry
The template repo is public; the camera and wifi password fields now start empty instead of embedding the fleet default.
Empty default with a wifi-address placeholder instead of reusing the static IP default, which led operators to put the future static address into ansible_host.
Ask the current Pi IP first, then the static IP / watchdog defaults below it.
New section 7: after init-one-engine installs the OpenVPN client, detect the Pi's 192.168.255.x address via tun0 (ad-hoc ansible through the container) or enter it manually, then update ansible_host in hosts_prod so later deploys go through the VPN. Sidebar shows whether ansible_host is already a VPN address.
Step 6 no longer shells out to `docker exec pyro-ansible make init-one-engine` — it just prints the `make ansible-up` / `make init-one-engine` commands to run from the terminal. Adds a step 8 that prints `make deploy-one-engine` once ansible_host is on the VPN. build_vars_yml now emits `watchdog_type` (no_watchdog/shelly) and `shelly_ip`, which is what check_vars asserts and engine_cron reads. The previous `shelly_enabled` / `shelly_watchdog_ip` keys are not used by any role, so deploy-engines failed on the generated vars.yml.
- Step 3 lists existing organizations in a dropdown (with refresh); creating an org now only happens via the explicit 'Create organization' button - 'Create cameras' and 'Create user' error out if the organization does not exist instead of silently creating it - Camera and wifi passwords can be pre-filled from CAM_PWD / WIFI_PASSWORD in the root .env (optional, empty by default)
fe51
approved these changes
Jul 30, 2026
fe51
left a comment
Member
There was a problem hiding this comment.
Thanks @MateoLostanlen for this PR and having taken in account my feedbacks.
I have tested it but not reviwed. It works.
I Think we can merge and add further improvments later.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.