This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Nas

TrueNAS pools, datasets, and storage namespaces

The DNS Terraform package manages this owner’s DNS records through its dedicated Vault AppRole. The separate TrueNAS root manages the existing pool, filesystem datasets, and Nextcloud lifecycle metadata with its own state. Existing NAS resources are adopted through that root; appliance installation remains outside these roots. Namespaces and child datasets are managed independently by AppRole under approles/, with separate state and plan/apply targets.

This diagram describes the maintained architecture source, not live inventory or service health. The Mermaid source is authoritative; Bazel renders its light and dark SVGs.

Truenas architectureTruenas architecture

1 - AppRole storage projects

Each <approle>/ directory is a standalone Terraform root with its own state, plan/apply targets and fixed namespace under default/encrypted/approles. It owns the namespace, ACLs, shares and child datasets through the shared dataset module. No parent input or remote-state dependency is needed.

The shared NAS root owns accounts, the encrypted parent and appliance-wide settings. It does not load AppRole projects. Group membership creates an account; a namespace is created when its storage project is applied. Add another project only when declaring that AppRole’s storage.

Projects use the NAS operator identity, the shared connection injector and a separate backend under that identity’s tf_backend/approles/<approle> path. This separates state and lifecycle; it does not restrict TrueNAS administrator API permissions to a dataset path. The consumer AppRole receives only its own NAS account credential, not the provisioning key.

Apply the shared NAS prerequisites first, then the selected AppRole storage project. The development project owns its namespace and runner cache. VM provisioning consumes the resulting Xen Orchestra storage repository through its own development identity.

1.1 - Development NAS storage

This standalone Terraform root owns default/encrypted/approles/src_infra_dev, its private namespace share and the runner cache dataset/share. The namespace permits XCP-ng to traverse to the cache without connecting to the namespace share. The cache grants XCP-ng MODIFY access and limits SMB clients to its host. The reusable dataset module owns encryption inheritance and private ACL defaults. The cache share is named src_infra_dev_runner_cache: SMB names are NAS-wide, and TrueNAS forbids slashes in them.

The root has its own HTTP state backend at alwaldend.com/vault1/approles/src_infra_nas/tf_backend/approles/src_infra_dev. It authenticates as the existing NAS operator and reuses the shared NAS API connection. Its tf=approle_src_infra_dev selection chooses this backend; truenas selects the connection injector. The development AppRole does not gain NAS administrator credentials. There are no Terraform input variables or remote-state reads, and the shared NAS root does not load this project.

Under separately authorized live scope:

  1. Apply Vault NAS groups/grants, then //infra/nas/truenas:tf.apply for accounts, the shared encrypted parent and mandatory SMB encryption. Unlock the parent.
  2. Review/apply //infra/nas/approles/src_infra_dev:tf.plan/tf.apply for this namespace and cache.
  3. Apply //infra/xcp_ng/tf:tf.apply for the storage repository, then the runner VM root and Ansible for disk attachment and mounting.

Run the named targets through bazel run. Each NAS apply covers its complete root; other AppRole states are outside this project. Follow the VM provisioning guide for initial disk attachment. Formatting and offline provider validation use :tf_tests.fmt_test and :tf_tests.validate_test.

The authorized rollout created this namespace/cache and its ACLs/shares in this independent state. Its subsequent plan has no changes. If an earlier shared-state revision was applied elsewhere, reconcile its ownership before applying either root; preserve existing data.

2 - DNS Terraform

This root packages the owner’s canonical DNS declarations through the shared DNS module and keeps state in the owner AppRole’s Vault HTTP backend. The root contains DNS resources only. dns_enabled defaults to true after verified adoption. Keep it enabled to retain existing records; disabling it would propose deletion.

The DNS migration procedure owns credential provisioning, reconciliation, and recovery. The adoption record contains import and verification evidence. Use the //infra/nas/dns:tf wrappers for operational commands and //infra/nas/dns:tf_tests.fmt_test for offline source validation.

Operational Terraform calls require the DNS AppRole policy grants and credential fields described by the migration procedure. Provider configuration and authentication require real credentials and live access.

3 - OpenSpec

3.1 - Specifications

3.1.1 - Infra nas

3.1.1.1 - NAS infrastructure Specification

Describe the TrueNAS-related configuration surface currently owned by infra/nas. The baseline is checked-in source at revision 550d7e79b1f5fdbc2b6017b75178471d6914082f, observed on 2026-09-08. The directory contains an AL configuration, DNS declarations, Vault wrappers, and brief documentation. It does not contain a TrueNAS provisioning playbook or Terraform configuration, and this baseline makes no claim about live NAS configuration or availability.

Source baseline limitation: the owning BUILD file restricts the AL target’s visibility to //infra/harvester:__subpackages__, although infra/harvester does not exist in this revision. This declaration does not establish a working consumer integration.

The project SHALL declare its AL configuration through //infra/nas:al. That configuration SHALL depend on the shared //infra:al configuration. The project’s Vault command map SHALL use its own AL target.

Sources: project description and configuration and command targets.

  • WHEN a maintainer inspects the NAS target declarations
  • THEN the AL target includes al.lua and the shared infrastructure AL dependency
  • AND the Vault command map references that NAS AL target

The NAS DNS declaration SHALL expose the NAS host and root names as A records, and SHALL distinguish the DC1 and global cloud aliases. The DC1 cloud alias SHALL target nas.alwaldend.com., while the global alias SHALL target ingress.alwaldend.com.. The DNS filegroup SHALL remain visible only within the infrastructure tree.

Sources: DNS declarations and DNS target visibility.

  • WHEN a DNS consumer selects the entries tagged dc1 and global
  • THEN it receives the NAS destination for the DC1 cloud alias and the ingress destination for the global cloud alias.

3.1.2 - Owned dns

3.1.2.1 - owned-dns Specification

Define NAS DNS management through the owner’s tf root, including canonical declarations, scoped credentials, and offline source checks before adopting live records.

The tf root SHALL consume this owner’s canonical dnsconfig.json through the shared DNS Terraform module, preserving declared record identities and views. DNS resources SHALL default to disabled until the authorized adoption revision and SHALL retain enabled ownership after existing records are imported into the owner’s state. Reconciliation against unchanged declarations and adopted state SHALL propose no record additions, changes, replacements, or deletions.

  • WHEN the checked-in root is evaluated with default inputs before its authorized adoption revision
  • THEN it reads this owner’s declaration and disables managed DNS records
  • AND the package contains the module and declaration inputs
  • WHEN the authorized adoption freezes the old central writers and enables the owner’s record management
  • THEN the owning root imports existing records by exact provider ID into its state while preserving their declared identities and views
  • WHEN the adopted root uses its checked-in source defaults
  • THEN DNS ownership remains enabled and the package retains the module and canonical declaration inputs
  • WHEN the owning root plans against its adopted state and unchanged declarations
  • THEN it proposes no record additions, changes, replacements, or deletions

The DNS wrapper SHALL select src_infra_nas through the repository AL flow and keep secret values in injected variables. DNS injection SHALL select the root’s existing Terraform stage label. Real DNS credentials and Vault policy grants SHALL be prerequisites for operational Terraform calls. RouterOS DNS credentials SHALL be isolated from unrelated RouterOS resources. The package SHALL expose a format test that does not authenticate to Vault or contact DNS providers.

  • WHEN the package format test executes
  • THEN it checks the packaged Terraform configuration without live credentials
  • AND existing non-DNS authentication and backend paths remain unchanged
  • WHEN the wrapper selects its Terraform stage labels
  • THEN it selects DNS credential injection through the owner AppRole
  • AND disabled DNS resources do not imply offline provider configuration

4 - TrueNAS

This root preserves the adopted default RAIDZ2 pool, seven datasets and Nextcloud lifecycle settings. Existing imported addresses remain unchanged. Settings are inline HCL; there is no JSON configuration interface.

This root owns the encrypted default/encrypted/approles parent and one account for each entity member of Vault’s truenas_admins and truenas_user groups. Vault owns membership: the NAS AppRole is an administrator, and the user group projects the other canonical AppRoles. The shared parent permits traversal without listing. NAS groups mirror Vault membership. Only truenas_admins grants the FULL_ADMIN privilege. Ordinary accounts have no administrative privilege; no account gets SSH login, web shell or sudo rights. Long account names are shortened deterministically; namespace and share names retain the full AppRole. SMB transport encryption is mandatory.

The reusable dataset module owns filesystem defaults, private ACLs and optional DEFAULT_SHARE exports. This root does not load the AppRole storage projects. Each project owns its namespace, ACLs, shares and child datasets in its own Terraform state, with independent plan/apply targets. The development project owns the runner cache. Namespaces are created by their project’s apply, not account provisioning. VM provisioning consumes the XO repository and does not authenticate to TrueNAS.

64-character passwords are generated by the pinned random provider and retained only in Vault-backed state and Vault KV. NAS publishes each account at secrets/alwaldend.com/vault1/shared/read/approle/<approle>/nas. Existing shared-read policies let each AppRole read its own account. XCP-ng reads its own account for the cache connection; the development NAS project owns its traversal and MODIFY grants. Coordinate password rotation with clients. Increment nas_password_version to regenerate passwords and update TrueNAS together; the same version drives password keepers and the write-only rotation trigger.

The existing NAS API credential comes from its Vault truenas entry. State uses tf_backend/truenas, separate from DNS. The provider is pinned to 1.9.3; TLS verification is enabled. API roles are method-based and do not enforce dataset path restrictions. Both shared and AppRole storage roots use NAS’s administrator identity; namespace accounts do not receive that credential. AppRole state uses distinct backend paths and does not depend on this root’s state outputs.

Apply the Vault NAS access groups, account-publisher and lookup grants before planning this root. Unlock the encrypted root before provisioning namespaces or mounting shares. The authorized rollout provisioned the accounts and shared settings; the subsequent plan has no changes.

bazel run //infra/nas/truenas:tf.plan
bazel test //infra/nas/truenas:tf_tests.fmt_test //infra/nas/truenas:tf_tests.validate_test