Provisioning an app (bosun add)

Everything bosun add creates on disk — ACLs, .env, deploy.conf, systemd units, RVM/gemsets — and why.

sudo bosun add myapp     # one-time per app, run as root/sudo

This provisions /var/www/myapp with:

Existing accounts created before this feature: bosun add (first app on a box), bosun bootstrap, and argus-tty add/add-admin/add-deployer all retrofit every current developer/admin/deployer account onto webapps/rvm automatically now — no separate sudo argus-tty reconfigure step needed just for this. An account with an already-open session still needs a fresh login to pick up new group membership (a PAM limit, not something any script can work around).

Why a per-app .env file instead of the box-wide /etc/environment: /etc/environment is sourced into every login shell and PAM session on the host — including admins'. Any sudoers rule broad enough to let developers edit it (even a "restricted" wrapper) is a realistic path to tampering with root's environment (LD_PRELOAD, BASH_ENV, arbitrary vars) on next login — a bigger hole than argus-tty's whitelist model is designed to allow. shared/.env confines each app's secrets to that app's own directory permissions instead — and, on top of that, its own permissions are tighter than the rest of the app tree (root + a named-user ACL grant for webapp-svc only, not the webapps group — see permissions.md): even a compromised or malicious developer/deployer account has no standing read access to it at all.

add/do-release wire this up with no gem dependency (deliberately not dotenv-rails — a plain .env file does nothing on its own without something to read it, and we didn't want that something to be a Gemfile addition every app has to carry): the puma-<app>/sidekiq-<app> systemd units load it via EnvironmentFile=-shared/.env (read by root, so .env's tight permissions don't matter there), and, redundantly, the puma-exec/ sidekiq-exec wrapper scripts also source it before exec'ing — they run as webapp-svc, which has the ACL grant. For anything run by hand — rails console, rake, migrations — use bosun run (e.g. bosun run console myapp) instead of invoking bundle/rails directly; it elevates to webapp-svc to load the same deploy.conf/shared/.env before running whatever command you pass it, without requiring the calling developer/admin's own account to read .env directly.

RVM / gemsets: this toolkit does not install RVM as part of add — run sudo bosun bootstrap once per host instead (root, one-time; see walkthrough.md). It installs RVM in multi-user mode (a system-wide /usr/local/rvm and an rvm group). Once that group exists, every developer/admin/deployer account (new, or retrofitted automatically by bootstrap itself) is added to it automatically — as is the webapp-svc service account, which also needs rvm membership to actually load the gems it runs — so ruby/bundle/rails/gemset commands work with no sudo needed.

bootstrap also cleans up conflicting per-user RVM installs every time it runs (not just on first install) — e.g. ~ubuntu/.rvm from someone having run RVM's installer directly on some account before this toolkit's multi-user /usr/local/rvm existed. A per-user install auto-loads via a line in that account's .bashrc/.bash_profile, and RVM's own scripts aren't safe to load twice — the symptom is a login (or anything with a login-shell shebang) crashing with ... unbound variable (e.g. rvm_bash_nounset or _system_name), which has nothing to do with whatever command happened to trigger it. bootstrap finds every /home/*/.rvm and /root/.rvm, strips the auto-load line from that account's shell rc files, and leaves the actual .rvm directory in place (never auto-deletes gemset data) — remove it yourself once you've confirmed nothing still depends on it.