# `mix ash_vault.local.init`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/mix/tasks/ash_vault.local.init.ex#L1)

Create and initialise a key root for `AshVault.KeyProviders.Local`.

    mix ash_vault.local.init /var/lib/my_app/ash_vault_keys

With no argument the root is read from configuration:

    config :ash_vault, AshVault.KeyProviders.Local, root: "/var/lib/my_app/ash_vault_keys"

The task creates the directory at mode `0700` and writes the sentinel file
`.ash_vault_root` into it. `AshVault.KeyProviders.Local` refuses to start against a
root without that sentinel, and never creates one itself.

## Why this step exists

The key root is supposed to live on its own volume, separate from the database. If
that volume fails to mount — a reordered systemd unit, a degraded array, an NFS
server that is not up yet — a provider that created its own root would quietly build
an empty key store on the *underlying* filesystem: no tombstones, no key material,
and a freshly minted version 1 for every tenant that was ever crypto-erased.

The sentinel lives on the mounted volume, so its absence distinguishes "the key
store is not here" from "the key store is empty". Running this task is therefore an
explicit operator decision, taken once, with the volume mounted.

> #### Do not run this to make a start-up error go away {: .error}
>
> If `AshVault.KeyProviders.Local` refuses to start on a root that you know was
> already initialised, the sentinel is missing because the *volume* is missing.
> Running this task then creates a second, empty key store over the top of the mount
> point and resurrects every destroyed tenant. Check the mount first.

## Options

  * `--force` — write the sentinel even if the directory already exists and is
    non-empty. Without it, a non-empty directory with no sentinel is treated as a
    probable unmounted volume and the task refuses.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
