rosenpapazov.rustfs installs RustFS, an S3-compatible object store written in Rust, on Ubuntu and the RHEL family. It covers a single disk on one box up to multi-pool erasure-coded clusters with TLS, and it provisions buckets, policies, users and service accounts. This post covers how to use it and the design decisions behind it.


Why RustFS, and why a role

Three things pushed me here at the same time.

MinIO stopped being a safe default. For years, “I need S3 on my own hardware” meant MinIO. Over 2025 the community edition was steadily cut back: in May the web console lost most of its admin features, in October prebuilt binaries and Docker images stopped coming (source only from then on), and in December the project went into maintenance mode. If you run object storage you plan to keep for years, that is reason enough to look elsewhere.

I needed self-hosted S3 for real work. That means repeatable installs, secrets that don’t end up in Git, TLS between the nodes, and something a colleague can run without asking me.

And I was curious. RustFS is a Rust re-implementation of the same idea: S3 API, erasure coding across disks and nodes, a web console. It also uses a very similar operational model (RUSTFS_VOLUMES with {1...4} expansion, pools, and an rc CLI that feels like mc). The homelab is where I try that kind of thing first.

Hand-rolled install scripts don’t survive the second cluster, so this became a role. It is on Galaxy as rosenpapazov.rustfs, with the source on GitHub.

What it does

In one run, the role:

  1. Installs the rustfs server binary and the rc CLI from GitHub releases, either downloaded once on the controller and copied out, or downloaded on each host. Both track the latest release by default (rustfs_version: "latest", rustfs_rc_version: "latest"); pin them with an exact version such as rustfs_version: "1.0.7".
  2. Prepares the data disks. It formats block devices as XFS and mounts them by UUID, or uses directories that are already mounted.
  3. Creates the service user and renders /etc/default/rustfs and a hardened systemd unit.
  4. Generates the root credentials and the inter-node RPC secret, or takes yours, and stores them vaulted on the controller.
  5. Optionally sets up TLS with a self-signed CA kept on the controller, or with certificates you provide.
  6. Starts the cluster, waits for /health/ready, and provisions buckets, policies, groups, users and service accounts through rc.

Supported targets are Ubuntu 22.04, 24.04 and 26.04, and RHEL 9 and 10 family distributions, on x86_64 and aarch64.

Quick start

ansible-galaxy role install rosenpapazov.rustfs,v1.0.2
ansible-galaxy collection install ansible.posix community.crypto community.general

The role encrypts every secret it generates with your default vault id, so ansible.cfg needs a vault_password_file:

[defaults]
vault_password_file = ~/.vault-pass

An inventory with one host in the rustfs group:

[rustfs]
rustfs-a ansible_host=192.0.2.11

And the playbook:

- name: "Install RustFS"
  hosts: rustfs
  become: true
  roles:
    - role: rosenpapazov.rustfs

That gives you a single-node, single-disk RustFS on /var/lib/rustfs/disk0 with generated root credentials. For real use, settings go in group_vars/rustfs.yml.

Topologies

RustFS uses the same three shapes as MinIO, and the role derives the right one from the inventory:

Hosts in rustfs_cluster_group Disks per host Mode
1 1 SNSD, no redundancy
1 2 or more SNMD, protected against disk loss only
4 or more per pool 1 or more MNMD, protected against disk and node loss

A four-node cluster with two disks per node and TLS looks like this:

# group_vars/rustfs.yml
rustfs_tls_mode: "self-signed"
rustfs_tls_extra_sans:
  - "s3.example.org"
rustfs_disks:
  - path: "/data/rustfs0"
    device: "/dev/sdb"
  - path: "/data/rustfs1"
    device: "/dev/sdc"
rustfs_buckets:
  - name: "app-data"
    quota: "100G"

From that, the role computes:

RUSTFS_VOLUMES="https://rustfs{1...4}:9000/data/rustfs{0...1}"

To grow the cluster you add a pool to rustfs_pools. Each pool becomes another space-separated entry in RUSTFS_VOLUMES, with node numbering continuing where the previous pool stopped.

Design decisions

This is the part I enjoyed most. Most of these come from a failure mode I wanted to rule out completely.

Cluster membership never depends on the play

The obvious way to build RUSTFS_VOLUMES is to iterate over ansible_play_hosts. That works until someone runs ansible-playbook site.yml --limit rustfs-b to fix a single node. Then the play contains one host, the role renders a single-node volume string, and the node restarts thinking it is alone.

So cluster membership comes from rustfs_cluster_group (or explicit rustfs_pools) and never from the play. cluster-facts.yml opens with this comment:

# Pure computation from the inventory: the result is identical on every host and independent of --limit.

Nodes are named rustfs1, rustfs2, … in inventory order. The role writes those names into /etc/hosts on every node, inserted at the top of the file so they win over the distribution’s 127.0.1.1 <hostname> line. RustFS exits immediately if a peer name doesn’t resolve, so this is a requirement, not a nice-to-have. Using stable synthetic names also means the volume string doesn’t depend on whatever the machines are called in DNS this year.

The test harness has a scenario just for this (mnmd-limit). It converges a four-node cluster, runs again with --limit node2, and asserts that /etc/default/rustfs and /etc/hosts are byte-identical on all nodes.

Validation runs early and fails loudly. A pool with 2 or 3 hosts is rejected, since erasure coding across nodes needs at least four. Disk paths must follow <prefix><N> counting from 0 without gaps, because that is the only shape the {0...N} expansion can express. Every node must have the same disk paths, because RUSTFS_VOLUMES is shared:

- name: "Cluster facts | Validate identical data disks on all cluster nodes"
  loop: "{{ __rustfs_cluster_hosts }}"
  loop_control:
    loop_var: __rustfs_peer
  ansible.builtin.assert:
    that:
      - hostvars[__rustfs_peer]['rustfs_disks'] | d(rustfs_disks) | map(attribute='path') | list == __rustfs_disk_paths
    quiet: true
    fail_msg: >-
      RUSTFS_VOLUMES is shared by all nodes, so every node needs the same data disk paths.      

Secrets: generated once, vaulted, never plaintext on the controller

Set rustfs_access_key, rustfs_secret_key or rustfs_rpc_secret to auto (the default) and the role generates them. The difficult part isn’t generating a random string. It is making sure that:

  • every node of the cluster gets the same value,
  • a re-run, or a run with --limit, reuses that value instead of rotating it,
  • the controller copy is encrypted, and
  • no plaintext copy ever sits on the controller’s disk, not even briefly.

set-passwords.yml resolves a value in a fixed order. It takes the first existing copy on any play host, then the vaulted controller copy, and only generates a new value once (run_once) if both are missing. Missing copies are then written back. The host copy is plain, 0600 root:root, because the service needs it. The controller copy is vaulted and is never rewritten once it exists.

Ansible has no module for vault encryption, so the role pipes the secret into ansible-vault on stdin:

# ansible-vault has no module; content is passed on stdin so no plaintext ever touches the disk, creates keeps it idempotent
- name: "Vault encrypt | Encrypt content into {{ __rustfs_vault_file }}"
  run_once: true
  delegate_to: localhost
  become: false
  no_log: true
  environment:
    ANSIBLE_CONFIG: "{{ ansible_config_file }}"
  ansible.builtin.command:
    cmd: "ansible-vault encrypt --output {{ __rustfs_vault_file | quote }} -"
    stdin: "{{ __rustfs_vault_content }}"
    creates: "{{ __rustfs_vault_file }}"

Reading it back is just lookup('ansible.builtin.file', ...), which decrypts vaulted files transparently. You can commit the secrets directory next to your inventory if you want to, because everything in it is vault ciphertext. The test suite checks that every file there starts with $ANSIBLE_VAULT;.

One small detail: the generated root access key uses uppercase letters and digits only. A / in an access key breaks request signing with some clients.

A CA on the controller, with keys that only exist vaulted

With rustfs_tls_mode: self-signed, the role builds a small PKI in rustfs_controller_tls_dir: an ECDSA P-256 CA and one certificate per node. The SANs are the node name, its address, localhost, 127.0.0.1 and anything in rustfs_tls_extra_sans. Entries that look like IPs become IP: SANs, everything else becomes DNS:.

The private keys are created with the community.crypto *_pipe modules, which return the key in memory instead of writing a file. The key then goes straight into vault-encrypt.yml. No plaintext private key is ever written on the controller.

The catch is that the pipe modules regenerate on every call, so idempotency has to be built by hand. The role first reads every existing certificate and asks whether it is still valid 30 days from now. That threshold is fixed in the task, not a variable:

- name: "TLS self-signed | Read node certificate information"
  community.crypto.x509_certificate_info:
    path: "{{ rustfs_controller_tls_dir }}/{{ __rustfs_node_names[__rustfs_tls_host] }}.crt"
    valid_at:
      soon: "+30d"

A planning step then decides what to reissue:

{%- if (not k.stat.exists)
       or i.subject_alt_name is not defined
       or not i.valid_at.soon
       or (i.subject_alt_name | map('lower') | sort) != (__rustfs_tls_node_sans[h] | map('lower') | sort)
       or i.authority_key_identifier != __rustfs_tls_ca_info.subject_key_identifier -%}

A certificate is reissued when its key or file is missing, when its SANs changed, when it expires within 30 days, or when it was signed by a different CA. Otherwise nothing happens, and a second run reports changed=0.

Worth knowing: RustFS only trusts a private CA for node-to-node traffic if ca.crt sits in its TLS directory, next to the certificate. Adding the CA to the system trust store is not enough, so the role installs it as ca.crt in rustfs_tls_dir.

Disks: refuse rather than regret

Formatting disks is where automation can do real damage, so disks.yml is deliberately paranoid. Before touching a device it:

  • resolves symlinks (/dev/disk/by-id/... → /dev/sdX),
  • walks the device chain behind / with lsblk --inverse and refuses anything in it,
  • refuses a device that is mounted anywhere other than its intended path, and
  • never passes -f to mkfs.xfs unless you set force: true on that disk.

It mounts by filesystem UUID rather than label, so a device that already carries XFS with a different label still works.

A hardened unit that still runs everywhere

The systemd unit is Type=notify with Restart=always, OOMScoreAdjust=-1000, ProtectSystem=strict (only the data disks and log directory are writable), PrivateDevices, NoNewPrivileges, RestrictSUIDSGID and friends. RequiresMountsFor lists every data path, so the service won’t start on an empty mount point and fill your root filesystem.

Restart=always matters for cluster bootstrap. A fresh RustFS node answers HTTP 503 until a quorum of peers is up, so the first start of a cluster doesn’t block on the other nodes. Each node starts, gets restarted by systemd if it gives up too early, and the role waits until /health/ready answers on every node.

ProtectKernelTunables and ProtectControlGroups are behind rustfs_unit_protect_kernel, because they fail with 226/NAMESPACE in rootless containers and some LXC setups. Everything else stays on.

Restarts: parallel by default, rolling on request

A changed binary, unit, environment file or certificate notifies one handler topic. rustfs_restart_strategy: parallel restarts everything at once, which is the default because it avoids running mixed versions in one cluster. rolling loops over the play hosts and restarts one node at a time, waiting for /health/ready before touching the next.

Handlers only restart a service that is already running. On a first install the service is started by the normal flow instead. There is also a downgrade guard: if the requested version is older than the installed one, the role fails instead of quietly downgrading your storage.

Provisioning with rc: probe, compare, then write

RustFS doesn’t have an Ansible module, but it does have rc. Every provisioning task follows the same pattern: run a read-only probe (rc admin … info --json), compare the result with the desired state, and only write when they differ. rc exits with code 5 for “not found”, so the probes use failed_when: rc not in [0, 5] and branch on that.

Some of rc’s behaviours shaped the rules:

  • Credentials are create-only; policy attachment is reconciled every run. rc admin user add on an existing user silently resets its password, and secrets can’t be read back. Changing them would break every application that uses them, so a user or service account is only ever created, never re-created. Generated user secrets go through the same vaulted set-passwords.yml as the root credentials. What is reconciled on existing users is their policies: when policies is set, the user’s policy list is replaced as a whole, so the inventory is the source of truth. Group memberships are only ever added.
  • Policies are diffed semantically. policy create is an upsert, but rewriting on every run would break idempotency, and the server returns documents with its own key order. The role normalises both documents before comparing: single Action/Resource values become lists, those lists are sorted, and statements are compared as a set of key-sorted JSON strings. Reordering your YAML doesn’t cause a write. Changing a permission does.
  • Service account policies are snapshots. An optional policy is resolved to its document on the server and embedded when the account is created. Later changes to the named policy do not propagate.

A typical provisioning block:

rustfs_buckets:
  - name: "app-data"
    quota: "100G"
    versioning: true
rustfs_policies:
  - name: "app-data-rw"
    document:
      Version: "2012-10-17"
      Statement:
        - Effect: "Allow"
          Action: ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListBucket"]
          Resource: ["arn:aws:s3:::app-data", "arn:aws:s3:::app-data/*"]
rustfs_users:
  - access_key: "APPUSER"
    secret_key: "auto"
    policies: ["app-data-rw"]
rustfs_service_accounts:
  - access_key: "APPSVC01"
    secret_key: "auto"
    parent: "APPUSER"

Quota, versioning, anonymous access and tags are reconciled on every run. object_lock can only be set at bucket creation, because that is how S3 object lock works.

One honest limitation: rc accepts a new user’s secret only as a positional argument. It has no environment variable and no file option, even though rc admin user passwd already has --password-from-env and --password-file (checked against rc 0.1.38). While a user or service account is being created, the secret is briefly visible in the process list of the first node. no_log keeps it out of Ansible’s output, but I’d rather say it here than have you find it. It is tracked upstream as rustfs/cli#438, and the role will switch to an env or file option once rc has one.

Check mode that actually works

--check runs all the read-only probes and skips every write. It works even against a host that has never been converged. File ownership is left out until the service user exists, and the service start is skipped until the unit exists. That sounds minor, but it is what lets you run --check --diff in CI against fresh machines.

No load balancer, on purpose

The role doesn’t manage a load balancer. Everyone already has one: HAProxy, nginx, a cloud LB, or something on the router. Bundling one would mean maintaining three. Point yours at the nodes (S3 API on rustfs_port, console on rustfs_console_port, health check GET /health/ready), and add every client-facing name to rustfs_tls_extra_sans if the LB passes TLS through.

Proxy headers: what RustFS 1.0.7 actually does

This section describes RustFS 1.0.7, the current release as I write this. The role installs whatever is latest unless you pin rustfs_version, so check again if you run something newer. What follows is from the 1.0.7 source (crates/trusted-proxies/src/simple.rs), not from the docs. Trusted-proxy handling is on by default (RUSTFS_TRUSTED_PROXY_ENABLED=true), and the default implementation is simple.

Who is trusted. In simple mode, a proxy is trusted because of where it is on the network, not because it is on a list. Any peer with a private, loopback or link-local address (RFC 1918, 127.0.0.0/8, 169.254.0.0/16, ::1, fc00::/7, fe80::/10) counts as a trusted proxy. From a public address, all proxy headers are ignored, and the client is the TCP peer. RUSTFS_TRUSTED_PROXY_NETWORKS (default 127.0.0.1,::1) only applies to the legacy implementation.

What is read from a trusted proxy:

  • X-Forwarded-For, rightmost value only. Simple mode trusts exactly one hop, so the client is the address your load balancer saw. Behind two proxies, that is the first proxy.
  • X-Forwarded-Proto (only http or https) and X-Forwarded-Host, last value.
  • Forwarded (RFC 7239) and X-Real-IP are never used as a source of the client address.

Where the 400 comes from. A request from a trusted (private) peer is rejected with HTTP 400 when it carries X-Forwarded-For, Forwarded or X-Real-IP but no usable X-Forwarded-For value. So Forwarded on its own gets a 400, and so does nginx’s common proxy_set_header X-Real-IP $remote_addr without X-Forwarded-For. If a valid X-Forwarded-For is also present, the request passes and the other headers are ignored. The safe rule is: always send X-Forwarded-For, and treat everything else as decoration.

Why it matters. The resolved address is what RustFS logs and rate-limits on, and it is the value of aws:SourceIp in bucket and IAM policy conditions. If a policy has an IP allowlist, it is evaluated against X-Forwarded-For.

⚠️ aws:SourceIp can be spoofed from your private network. In simple mode, every private, loopback or link-local peer is a trusted proxy. Anything on the private network that can reach a node directly can send its own X-Forwarded-For and pick the “client IP” that IP-allowlist policies see. If you rely on aws:SourceIp, firewall the nodes so that only the load balancer can reach the S3 port, and the other nodes the RPC port. Or switch to legacy with an explicit RUSTFS_TRUSTED_PROXY_NETWORKS list (see below).

HAProxy:

backend rustfs_s3
    option forwardfor                      # X-Forwarded-For (appended)
    http-request set-header X-Forwarded-Proto https if { ssl_fc }
    option httpchk GET /health/ready
    server rustfs1 192.0.2.11:9000 check
    server rustfs2 192.0.2.12:9000 check
    server rustfs3 192.0.2.13:9000 check
    server rustfs4 192.0.2.14:9000 check

nginx:

location / {
    proxy_pass http://rustfs_s3;
    proxy_set_header Host              $http_host;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_request_buffering off;       # stream large uploads
    client_max_body_size 0;
}

Keep Host as the client sent it. S3 signatures cover the host header, so rewriting it breaks every signed request.

The trade-offs of simple mode:

  • Spoofing from inside, covered in the warning above. This is where RUSTFS_TRUSTED_PROXY_IMPLEMENTATION=legacy with an explicit RUSTFS_TRUSTED_PROXY_NETWORKS list is worth the extra configuration.
  • Turning it off (rustfs_env_extra: { RUSTFS_TRUSTED_PROXY_ENABLED: "false" }) removes the 400 and the spoofing surface, but then every request appears to come from the load balancer. Logs, rate limits and aws:SourceIp all see the LB’s address, and X-Forwarded-Proto is ignored too.
  • RFC 7239 is only parsed by the legacy implementation, and only with RUSTFS_TRUSTED_PROXY_ENABLE_RFC7239=true (default false).

The role passes any of these through rustfs_env_extra:

rustfs_env_extra:
  RUSTFS_TRUSTED_PROXY_IMPLEMENTATION: "legacy"
  RUSTFS_TRUSTED_PROXY_NETWORKS: "192.0.2.5,192.0.2.6"   # your load balancers

Testing: rootless podman with real systemd

An Ansible role is only as good as its second run, so testing got as much attention as the role itself.

The local harness (tests/) boots systemd-enabled Ubuntu and Rocky containers with rootless podman and drives them through the containers.podman.podman connection plugin, with no SSH and no sudo. One command runs the whole lifecycle:

tests/setup.sh
tests/run.sh mnmd      # up -> converge -> verify -> idempotency -> check mode -> down
Scenario What it covers
snsd, snsd-rhel, snsd-rhel10, snsd-resolute (Ubuntu 26.04) Single node, plain HTTP, full provisioning
snmd Four data directories on one node
mnmd, mnmd-rhel10, mnmd-resolute (Ubuntu 26.04) Four nodes, self-signed TLS, cluster formation
mnmd-limit --limit node2 leaves config byte-identical everywhere
xfs-device Real XFS on a loop device (needs rootful podman, otherwise SKIP)

verify.yml doesn’t just check that the service runs. On every node it checks /health/ready, that the unit is enabled, the env file’s mode and owner, and that rc admin info cluster reports the expected servers and online disks. Then it does a real put/get/delete round trip, both as the provisioned user and as its service account. run.sh then asserts changed=0 in the PLAY RECAP of a second converge, and that --check passes.

The images are minimal on purpose, with no unzip, no xfsprogs and no apt lists, so the role has to install everything it needs. A “fat” test image would hide missing-package bugs.

CI runs yamllint and ansible-lint, then a Molecule single-node scenario on Ubuntu 22.04, 24.04 and 26.04 and Rocky 9 and 10. The vault password is generated per run. Tagging a release imports it into Galaxy and creates a GitHub release from the changelog.

Wrapping up

The role is at 1.0.2, MIT-licensed, and every variable is documented in defaults/main.yml and validated by meta/argument_specs.yml.

# requirements.yml
roles:
  - name: "rosenpapazov.rustfs"
    version: "v1.0.2"

If you’re moving off MinIO, or just want S3 on your own disks without hand-maintaining it, give it a try. Issues and PRs are welcome, especially from anyone running it on hardware I don’t have.


Series: Ansible and Automation

  • Part 1: An Ansible Role for RustFS (you are here)