Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Optional daemons a VM can opt into via `service_roles.<name>.config` — see `ca
| `traefik` | Installs Traefik as a systemd service from its official release binary, optionally enabling the dashboard and Let's Encrypt via ACME. | Ubuntu 22.04/24.04, Debian 12, AlmaLinux |
| `docker` | Installs Docker Engine from its official repo, optionally adding users to the `docker` group. | Ubuntu 22.04/24.04, Debian 12, AlmaLinux |
| `tailscale` | Installs Tailscale, optionally joining your tailnet automatically when an auth key is provided. | Ubuntu 22.04/24.04, Debian 12, AlmaLinux |
| `stash` | Installs the Stash backup agent from its checksum-pinned release binary and registers the machine to one of the customer's S3 buckets. | Ubuntu 22.04/24.04, Debian 12, AlmaLinux (x86_64 only) |
| `fail2ban` | Installs and enables Fail2ban, optionally overriding the default ban time and retry threshold. | Ubuntu 22.04/24.04, Debian 12, AlmaLinux |
| `ufw` | Installs and enables UFW, applying default incoming/outgoing policies and a port allowlist before enabling. | Ubuntu 22.04/24.04, Debian 12 (not packaged for RedHat family) |
| `grafana` | Installs and enables Grafana from its official repo, optionally setting the admin password and root URL. | Ubuntu 22.04/24.04, Debian 12, AlmaLinux |
Expand Down
34 changes: 32 additions & 2 deletions agents/backup-agent/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# backup-agent installers (placeholder)
# backup-agent (Stash)

No install scripts exist yet — today the registration flow (`docs/backup.agent/registration.md` in `NextDeveloper/S3`) only documents a bare CLI command the customer runs manually. When a real installer is built for Linux/Windows/macOS, it belongs here, following the same pattern as `agents/vm-service`.
Stash is the PlusClouds backup agent ([plusclouds/backup.agent](https://github.com/plusclouds/backup.agent)).

## Linux virtual machines

Stash is installed through the `stash` service role, not through a script in this directory: see `capabilities/service-roles/stash/`.

What the role does on each boot:

1. Downloads the `stash.linux` release pinned in the role to `/usr/local/bin/stash`, unless that exact build is already there. The download is verified against the SHA-256 pinned next to the version.
2. If the machine has no `/etc/plusclouds/stash.yaml` yet and the platform supplied a registration token, runs `stash register`. Registration writes the config and installs and starts the `stash` systemd unit.
3. Does nothing else on a machine that is already registered, apart from upgrading the binary when the pinned release changes.

A failure in the role never fails the boot playbook.

### Role config

| Key | Set by | Meaning |
| --- | --- | --- |
| `bucket` | customer | Name of the S3 bucket in their account to back up to. Empty = install only. |
| `registration_token` | platform | One-time, short-lived token created when the machine's metadata is built. Not a customer key, not listed in `defaults.yml`. |
| `register_endpoint` | platform | API base URL passed to `stash register --endpoint`. |

The platform resolves `bucket` inside the customer's own account and only then adds the token. The S3 secret never travels through the metadata: Stash receives it from the registration call.

### Moving to a newer Stash release

Change `stash_version` and `stash_sha256` together in `capabilities/service-roles/stash/linux.yml`, taking the checksum of `stash.linux` from the release page, then regenerate the manifest.

## Windows and macOS

Not covered yet. Stash is installed and registered by hand there (`stash register --endpoint <url> --token <token>`).
6 changes: 6 additions & 0 deletions capabilities/service-roles/stash/defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bucket:
default: ""
description: >-
Name of the S3 bucket in your account that this machine backs up to.
Empty = Stash is installed but left unregistered (register it later
with `stash register`).
147 changes: 147 additions & 0 deletions capabilities/service-roles/stash/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
# Installs the Stash backup agent (plusclouds/backup.agent) and registers the
# machine to an S3 bucket.
#
# This file is included on every boot, so every task has to be safe to repeat:
# the binary is only downloaded when it is missing or is not the pinned build,
# and registration only happens while the machine has no Stash config yet.
#
# Two values in the role config are not customer keys and are therefore not
# listed in defaults.yml: `registration_token` and `register_endpoint`. The
# platform adds them when it builds this machine's metadata, after resolving
# the customer's `bucket` inside their own account. The token is one-time and
# short-lived. Without them Stash is installed and left unregistered.
#
# Nothing here may fail the boot playbook: the rest of first boot (agent
# deployment, post-boot script) runs after the service roles. Any failure ends
# up in the rescue section at the bottom.
- name: Set Stash role defaults
set_fact:
# The release and its SHA-256 are pinned together. To move to a newer
# Stash, change both, taking the checksum of `stash.linux` from the
# release page.
stash_version: "3.2.4"
stash_sha256: "92bc9f59010be887c99cbc8ce1838da270c661af2e348007773a51dc56606774"
stash_bucket: "{{ service_roles.stash.config.bucket | default('') }}"
stash_registration_token: "{{ service_roles.stash.config.registration_token | default('') }}"
stash_register_endpoint: "{{ service_roles.stash.config.register_endpoint | default('') }}"
stash_registered_now: false
no_log: true

- name: Install and register Stash
block:
# Stash publishes a single Linux build, for amd64.
- name: Stop on architectures Stash has no build for
debug:
msg: >-
Stash is not installed: it is only built for x86_64 and this
machine is {{ ansible_facts.architecture }}.
when: ansible_facts.architecture != "x86_64"

- name: Install Stash on a supported architecture
when: ansible_facts.architecture == "x86_64"
block:
- name: Check whether this machine is already registered
stat:
path: /etc/plusclouds/stash.yaml
register: stash_config_before

# get_url leaves an existing file alone when it already matches the
# checksum, and never puts a download in place that does not match.
- name: Download the pinned Stash binary
get_url:
url: "https://github.com/plusclouds/backup.agent/releases/download/v{{ stash_version }}/stash.linux"
dest: /usr/local/bin/stash
checksum: "sha256:{{ stash_sha256 }}"
owner: root
group: root
mode: "0755"
timeout: 120
register: stash_binary

# A freshly written file under /usr/local/bin can carry the wrong
# SELinux context, in which case systemd cannot execute it.
- name: Restore SELinux context for the Stash binary (RedHat family)
command: restorecon -v /usr/local/bin/stash
when:
- ansible_facts.os_family == "RedHat"
- stash_binary.changed
changed_when: true

- name: Check for the Stash systemd unit
stat:
path: /etc/systemd/system/stash.service
register: stash_unit

- name: Restart Stash after a binary upgrade
systemd:
name: stash
state: restarted
when:
- stash_binary.changed
- stash_config_before.stat.exists
- stash_unit.stat.exists

# The token goes in through the environment, not the command line,
# which every local user could read. On success `stash register`
# prints the agent API key and the S3 secret key, so the result is
# never logged. It also installs and starts the systemd unit itself.
- name: Register this machine with the platform
command:
argv:
- /usr/local/bin/stash
- register
- --endpoint
- "{{ stash_register_endpoint }}"
environment:
STASH_REGISTER_TOKEN: "{{ stash_registration_token }}"
register: stash_register
when:
- not stash_config_before.stat.exists
- stash_registration_token | length > 0
- stash_register_endpoint | length > 0
changed_when: stash_register.rc == 0
failed_when: false
no_log: true

- name: Record whether registration succeeded
set_fact:
stash_registered_now: "{{ (stash_register.rc | default(1)) == 0 }}"

# Covers a machine that was registered by hand, or before Stash
# installed its own service.
- name: Install the Stash service on an already registered machine
command: /usr/local/bin/stash service install
when:
- stash_config_before.stat.exists
- not stash_unit.stat.exists
changed_when: true

- name: Debug - Stash status
debug:
msg: >-
{%- if stash_config_before.stat.exists -%}
Stash {{ stash_version }} is installed and this machine was already registered.
{%- elif stash_registered_now | bool -%}
Stash {{ stash_version }} installed and registered{{ ' to bucket ' ~ stash_bucket if stash_bucket | length > 0 else '' }}.
{%- elif stash_registration_token | length > 0 -%}
Stash {{ stash_version }} installed, but registration failed. The
registration token is one-time and short-lived: restart the machine
from the panel to get a new one.
{%- elif stash_bucket | length > 0 -%}
Stash {{ stash_version }} installed, but not registered: the platform
supplied no registration token for bucket {{ stash_bucket }}. Check
that the bucket exists in this account.
{%- else -%}
Stash {{ stash_version }} installed, but not registered: no bucket was
set in the role config. Register by hand with `stash register`.
{%- endif -%}

rescue:
# Only the task name is shown: a failed task's result can hold the
# registration token.
- name: Debug - Stash role failed
debug:
msg: >-
The Stash role did not complete (failed at: {{ ansible_failed_task.name | default('unknown task') }}).
The rest of the boot configuration continues.
6 changes: 6 additions & 0 deletions capabilities/service-roles/stash/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: "Installs the Stash backup agent and registers this machine to one of your S3 buckets, so its backups can be scheduled from the panel."
supported_os:
- "Ubuntu 22.04"
- "Ubuntu 24.04"
- "Debian 12"
- "AlmaLinux"
5 changes: 4 additions & 1 deletion checksums.sha256
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
458dddd48ebfe444988be472725f4f040272b667d2ddc109b4150f53179de6aa agents/backup-agent/README.md
18e6c912255647aa52fa804ff6d6c2a7eba278da4910b3ddefa137fda4c79fc1 agents/backup-agent/README.md
daec070d647ec6cd3df8737d227c968dc54dab4a7fc725ae182f604b24081eb3 agents/storaged/README.md
59e6e7806dd415e0af3c767d5ed3c664a5f6177dbe5a0e408cd9bbf095140cd1 agents/vm-service/agent.yaml
17e55e6851ad47b57e3ce1df834e9edcaa1f8141d78e22862f95bb7e22164cda agents/vm-service/cleanup.sh
Expand Down Expand Up @@ -121,6 +121,9 @@ a77c002180aef7e8311ccc9d868cacd219a14452a689ea056d6ac6a803fab3a7 capabilities/s
baa771754d48ad67c1844550c66542fb86c3a2ec8f7acb1f32c2f3ba015e6085 capabilities/service-roles/redis/defaults.yml
83bc1792f8a198456b8568be6dd783453e00647501df1584df288fd820c157b3 capabilities/service-roles/redis/linux.yml
427e449622ffc8cfd71b13d05ffb78a17b7ab11ca1f3eb567bb57948cca30f37 capabilities/service-roles/redis/meta.yml
fefb04422f2d673e55b5a973599ef0b59b44e57333bd16b37c7a427c90bb42eb capabilities/service-roles/stash/defaults.yml
0a5a462d751d2ecf27cfe10b27c7f8baba29f026d068b8710e5fb12b7176ebd2 capabilities/service-roles/stash/linux.yml
d2992fef02d82b8cfea095c2757b26b7a902a680a402b27c67b67cf41757b73a capabilities/service-roles/stash/meta.yml
5815ac7c97ccdb35ce1cddcb0598fffb87e1051ecf41f9d706096cf8aeb2f5cb capabilities/service-roles/tailscale/defaults.yml
3708f6c79ea11e95679570dce0c1b2db7d50a7c3b7d379b999324ca39fc55aa8 capabilities/service-roles/tailscale/linux.yml
83b497c159928099e78fe26926768c69eb8aa993638de59542ac604a31ab0547 capabilities/service-roles/tailscale/meta.yml
Expand Down
7 changes: 5 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"generated_at": "2026-10-10T19:53:45Z",
"generated_at": "2026-11-20T07:31:06Z",
"files": {
"agents/backup-agent/README.md": {"sha256": "458dddd48ebfe444988be472725f4f040272b667d2ddc109b4150f53179de6aa", "size": 348},
"agents/backup-agent/README.md": {"sha256": "18e6c912255647aa52fa804ff6d6c2a7eba278da4910b3ddefa137fda4c79fc1", "size": 1901},
"agents/storaged/README.md": {"sha256": "daec070d647ec6cd3df8737d227c968dc54dab4a7fc725ae182f604b24081eb3", "size": 395},
"agents/vm-service/agent.yaml": {"sha256": "59e6e7806dd415e0af3c767d5ed3c664a5f6177dbe5a0e408cd9bbf095140cd1", "size": 2726},
"agents/vm-service/cleanup.sh": {"sha256": "17e55e6851ad47b57e3ce1df834e9edcaa1f8141d78e22862f95bb7e22164cda", "size": 352},
Expand Down Expand Up @@ -124,6 +124,9 @@
"capabilities/service-roles/redis/defaults.yml": {"sha256": "baa771754d48ad67c1844550c66542fb86c3a2ec8f7acb1f32c2f3ba015e6085", "size": 367},
"capabilities/service-roles/redis/linux.yml": {"sha256": "83bc1792f8a198456b8568be6dd783453e00647501df1584df288fd820c157b3", "size": 2152},
"capabilities/service-roles/redis/meta.yml": {"sha256": "427e449622ffc8cfd71b13d05ffb78a17b7ab11ca1f3eb567bb57948cca30f37", "size": 229},
"capabilities/service-roles/stash/defaults.yml": {"sha256": "fefb04422f2d673e55b5a973599ef0b59b44e57333bd16b37c7a427c90bb42eb", "size": 213},
"capabilities/service-roles/stash/linux.yml": {"sha256": "0a5a462d751d2ecf27cfe10b27c7f8baba29f026d068b8710e5fb12b7176ebd2", "size": 6550},
"capabilities/service-roles/stash/meta.yml": {"sha256": "d2992fef02d82b8cfea095c2757b26b7a902a680a402b27c67b67cf41757b73a", "size": 233},
"capabilities/service-roles/tailscale/defaults.yml": {"sha256": "5815ac7c97ccdb35ce1cddcb0598fffb87e1051ecf41f9d706096cf8aeb2f5cb", "size": 770},
"capabilities/service-roles/tailscale/linux.yml": {"sha256": "3708f6c79ea11e95679570dce0c1b2db7d50a7c3b7d379b999324ca39fc55aa8", "size": 2191},
"capabilities/service-roles/tailscale/meta.yml": {"sha256": "83b497c159928099e78fe26926768c69eb8aa993638de59542ac604a31ab0547", "size": 207},
Expand Down
Loading