Skip to content

feat: station setup wizard in site_config - #72

Merged
MateoLostanlen merged 12 commits into
mainfrom
feat/station-setup-app
Jul 30, 2026
Merged

feat: station setup wizard in site_config#72
MateoLostanlen merged 12 commits into
mainfrom
feat/station-setup-app

Conversation

@MateoLostanlen

Copy link
Copy Markdown
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 fe51 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MateoLostanlen
MateoLostanlen merged commit ce18969 into main Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants