vault (Add): OpenBao API certs with the ADR-0005 names, signed by tofu (#50) #182

Merged
ginjiruu merged 1 commit from openbao-api-name-50 into master 2026-11-21 01:49:09 +00:00
Owner

Closes #50 (part 1 of 3: signing).

What: tofu signs each think's OpenBao API CSR through a scoped pki-infra role (openbao-api) and exports the leaves as output openbao_api_certs. The CSRs in vault/openbao-api/ were generated on each think from its existing /var/lib/openbao-tls/api.key. Their public keys match the certs each think serves today, and the private keys never left the hosts. auto_renew re-signs 30 days before expiry.

SANs: <host>, <host>.int, <host>.hosts.caosh.int, openbao.int, secrets.infra.caosh.int.animeteamspeak.moe (machine-configs ADR-0005), localhost, the host IP, 127.0.0.1. They're a superset of today's SANs, so swapping the certs breaks no client.

Deviation from the #50 plan (on purpose): names come from the c1 PowerDNS through external-dns, as you asked, not from a host-level server. So the bootstrap paths stay on IPs: OpenBao api_addr/retry_join, the host OpenBao agents, and the IP SANs. A resolver that runs on c1 can't sit in their path, and the node resolvers are public anyway. The name is for clients: tofu runners, ESO, browsers, people.

Sequence:

  1. this PR: role + signatures
  2. lab/clusters openbao-api-name-50: DNS records, c1 coredns forward for caosh.int, output published to openbao-config-outputs
  3. machine-configs: leaf + pki/pki-infra.crt committed to pki/openbao/, comin rolls the thinks
  4. then: openbao-config VAULT_ADDR → https://secrets.infra.caosh.int.animeteamspeak.moe:8200; the plan must stay clean
Closes #50 (part 1 of 3: signing). **What:** tofu signs each think's OpenBao API CSR through a scoped `pki-infra` role (`openbao-api`) and exports the leaves as output `openbao_api_certs`. The CSRs in `vault/openbao-api/` were generated on each think from its existing `/var/lib/openbao-tls/api.key`. Their public keys match the certs each think serves today, and the private keys never left the hosts. `auto_renew` re-signs 30 days before expiry. **SANs:** `<host>`, `<host>.int`, `<host>.hosts.caosh.int`, `openbao.int`, **`secrets.infra.caosh.int.animeteamspeak.moe`** (machine-configs ADR-0005), `localhost`, the host IP, `127.0.0.1`. They're a superset of today's SANs, so swapping the certs breaks no client. **Deviation from the #50 plan (on purpose):** names come from the c1 PowerDNS through external-dns, as you asked, not from a host-level server. So the bootstrap paths stay on IPs: OpenBao `api_addr`/`retry_join`, the host OpenBao agents, and the IP SANs. A resolver that runs on c1 can't sit in their path, and the node resolvers are public anyway. The name is for clients: tofu runners, ESO, browsers, people. **Sequence:** 1. this PR: role + signatures 2. lab/clusters `openbao-api-name-50`: DNS records, c1 coredns forward for `caosh.int`, output published to `openbao-config-outputs` 3. machine-configs: leaf + `pki/pki-infra.crt` committed to `pki/openbao/`, comin rolls the thinks 4. then: openbao-config `VAULT_ADDR` → `https://secrets.infra.caosh.int.animeteamspeak.moe:8200`; the plan must stay clean
Collaborator

tf-controller plan output:


OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

OpenTofu will perform the following actions:

  # vault_pki_secret_backend_role.openbao_api will be created
  + resource "vault_pki_secret_backend_role" "openbao_api" {
      + allow_any_name                     = false
      + allow_bare_domains                 = true
      + allow_glob_domains                 = false
      + allow_ip_sans                      = true
      + allow_localhost                    = true
      + allow_subdomains                   = false
      + allow_wildcard_certificates        = true
      + allowed_domains                    = [
          + "openbao.int.animeteamspeak.moe",
          + "secrets.infra.caosh.int.animeteamspeak.moe",
          + "think-01",
          + "think-01.int.animeteamspeak.moe",
          + "think-01.hosts.caosh.int.animeteamspeak.moe",
          + "think-02",
          + "think-02.int.animeteamspeak.moe",
          + "think-02.hosts.caosh.int.animeteamspeak.moe",
          + "think-03",
          + "think-03.int.animeteamspeak.moe",
          + "think-03.hosts.caosh.int.animeteamspeak.moe",
        ]
      + allowed_domains_template           = false
      + allowed_uri_sans_template          = (known after apply)
      + backend                            = "pki-infra"
      + basic_constraints_valid_for_non_ca = false
      + client_flag                        = true
      + cn_validations                     = (known after apply)
      + code_signing_flag                  = false
      + email_protection_flag              = false
      + enforce_hostnames                  = true
      + generate_lease                     = false
      + id                                 = (known after apply)
      + issuer_ref                         = (known after apply)
      + key_bits                           = 2048
      + key_type                           = "any"
      + key_usage                          = (known after apply)
      + max_ttl                            = "31536000"
      + name                               = "openbao-api"
      + no_store                           = false
      + not_before_duration                = (known after apply)
      + require_cn                         = true
      + serial_number_source               = (known after apply)
      + server_flag                        = true
      + signature_bits                     = (known after apply)
      + ttl                                = (known after apply)
      + use_csr_common_name                = false
      + use_csr_sans                       = false
    }

  # vault_pki_secret_backend_sign.openbao_api["think-01"] will be created
  + resource "vault_pki_secret_backend_sign" "openbao_api" {
      + alt_names             = [
          + "think-01",
          + "think-01.int.animeteamspeak.moe",
          + "think-01.hosts.caosh.int.animeteamspeak.moe",
          + "openbao.int.animeteamspeak.moe",
          + "secrets.infra.caosh.int.animeteamspeak.moe",
          + "localhost",
        ]
      + auto_renew            = true
      + backend               = "pki-infra"
      + ca_chain              = (known after apply)
      + certificate           = (known after apply)
      + common_name           = "think-01"
      + csr                   = <<-EOT
            -----BEGIN CERTIFICATE REQUEST-----
            MIHOMHUCAQAwEzERMA8GA1UEAwwIdGhpbmstMDEwWTATBgcqhkjOPQIBBggqhkjO
            PQMBBwNCAAR+FOD1h22b4JzOYvEj5ZTB4ZLXf+82SLEbC8f9S0Y0FFKufzG2mULY
            Sy8i6roP8LUeJ+nj5tz7vPCKjz/bJb7FoAAwCgYIKoZIzj0EAwIDSQAwRgIhAJy5
            d9tQLhPxe/TGBW8LRfJVioXPoSjy5sLkXrETg96+AiEA76UkWCF4FRCHCqb9X/zs
            SNzgqAocmzkYxtePG068CzA=
            -----END CERTIFICATE REQUEST-----
        EOT
      + expiration            = (known after apply)
      + format                = "pem"
      + id                    = (known after apply)
      + ip_sans               = [
          + "10.30.20.21",
          + "127.0.0.1",
        ]
      + issuing_ca            = (known after apply)
      + min_seconds_remaining = 2592000
      + name                  = "openbao-api"
      + renew_pending         = (known after apply)
      + serial_number         = (known after apply)
      + ttl                   = "8760h"
    }

  # vault_pki_secret_backend_sign.openbao_api["think-02"] will be created
  + resource "vault_pki_secret_backend_sign" "openbao_api" {
      + alt_names             = [
          + "think-02",
          + "think-02.int.animeteamspeak.moe",
          + "think-02.hosts.caosh.int.animeteamspeak.moe",
          + "openbao.int.animeteamspeak.moe",
          + "secrets.infra.caosh.int.animeteamspeak.moe",
          + "localhost",
        ]
      + auto_renew            = true
      + backend               = "pki-infra"
      + ca_chain              = (known after apply)
      + certificate           = (known after apply)
      + common_name           = "think-02"
      + csr                   = <<-EOT
            -----BEGIN CERTIFICATE REQUEST-----
            MIHNMHUCAQAwEzERMA8GA1UEAwwIdGhpbmstMDIwWTATBgcqhkjOPQIBBggqhkjO
            PQMBBwNCAAShBW9FL0Xtk4J+0AlZ8jLDd+5dVCVvyYRFBL2DjFer1pNJt3oKJMYx
            z/lGJIWEFHdV9AhPIuBzn+za/eMnbO6HoAAwCgYIKoZIzj0EAwIDSAAwRQIhAJxc
            mfQ/jZoui/OJJqwlrRsB7bBb33aZTUM+BnW/bxfQAiBPdKJUTzSa5Q+00o9XkAD5
            D7dJzsTj+BnQmeoqaqDqag==
            -----END CERTIFICATE REQUEST-----
        EOT
      + expiration            = (known after apply)
      + format                = "pem"
      + id                    = (known after apply)
      + ip_sans               = [
          + "10.30.20.22",
          + "127.0.0.1",
        ]
      + issuing_ca            = (known after apply)
      + min_seconds_remaining = 2592000
      + name                  = "openbao-api"
      + renew_pending         = (known after apply)
      + serial_number         = (known after apply)
      + ttl                   = "8760h"
    }

  # vault_pki_secret_backend_sign.openbao_api["think-03"] will be created
  + resource "vault_pki_secret_backend_sign" "openbao_api" {
      + alt_names             = [
          + "think-03",
          + "think-03.int.animeteamspeak.moe",
          + "think-03.hosts.caosh.int.animeteamspeak.moe",
          + "openbao.int.animeteamspeak.moe",
          + "secrets.infra.caosh.int.animeteamspeak.moe",
          + "localhost",
        ]
      + auto_renew            = true
      + backend               = "pki-infra"
      + ca_chain              = (known after apply)
      + certificate           = (known after apply)
      + common_name           = "think-03"
      + csr                   = <<-EOT
            -----BEGIN CERTIFICATE REQUEST-----
            MIHNMHUCAQAwEzERMA8GA1UEAwwIdGhpbmstMDMwWTATBgcqhkjOPQIBBggqhkjO
            PQMBBwNCAATQiwFlNaY/RkNrmoW0kQPHXHj+gWSw98KTevoqgb6FdZyf+pEc75uz
            R0AuU4RUFKd6oOPxbxLWhMCYwK+YTyJuoAAwCgYIKoZIzj0EAwIDSAAwRQIgVqYf
            b6DytPDCOzNM4p03xixyVPbu52rJU2fOLu39n88CIQDei6TcSXL34igI2IRPswQR
            OMXIVaQWDLJhrx6JjkCiYw==
            -----END CERTIFICATE REQUEST-----
        EOT
      + expiration            = (known after apply)
      + format                = "pem"
      + id                    = (known after apply)
      + ip_sans               = [
          + "10.30.20.23",
          + "127.0.0.1",
        ]
      + issuing_ca            = (known after apply)
      + min_seconds_remaining = 2592000
      + name                  = "openbao-api"
      + renew_pending         = (known after apply)
      + serial_number         = (known after apply)
      + ttl                   = "8760h"
    }

Plan: 4 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + openbao_api_certs = {
      + think-01 = (known after apply)
      + think-02 = (known after apply)
      + think-03 = (known after apply)
    }

To apply this plan, please merge this pull request.

tf-controller plan output: ```hcl OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create OpenTofu will perform the following actions: # vault_pki_secret_backend_role.openbao_api will be created + resource "vault_pki_secret_backend_role" "openbao_api" { + allow_any_name = false + allow_bare_domains = true + allow_glob_domains = false + allow_ip_sans = true + allow_localhost = true + allow_subdomains = false + allow_wildcard_certificates = true + allowed_domains = [ + "openbao.int.animeteamspeak.moe", + "secrets.infra.caosh.int.animeteamspeak.moe", + "think-01", + "think-01.int.animeteamspeak.moe", + "think-01.hosts.caosh.int.animeteamspeak.moe", + "think-02", + "think-02.int.animeteamspeak.moe", + "think-02.hosts.caosh.int.animeteamspeak.moe", + "think-03", + "think-03.int.animeteamspeak.moe", + "think-03.hosts.caosh.int.animeteamspeak.moe", ] + allowed_domains_template = false + allowed_uri_sans_template = (known after apply) + backend = "pki-infra" + basic_constraints_valid_for_non_ca = false + client_flag = true + cn_validations = (known after apply) + code_signing_flag = false + email_protection_flag = false + enforce_hostnames = true + generate_lease = false + id = (known after apply) + issuer_ref = (known after apply) + key_bits = 2048 + key_type = "any" + key_usage = (known after apply) + max_ttl = "31536000" + name = "openbao-api" + no_store = false + not_before_duration = (known after apply) + require_cn = true + serial_number_source = (known after apply) + server_flag = true + signature_bits = (known after apply) + ttl = (known after apply) + use_csr_common_name = false + use_csr_sans = false } # vault_pki_secret_backend_sign.openbao_api["think-01"] will be created + resource "vault_pki_secret_backend_sign" "openbao_api" { + alt_names = [ + "think-01", + "think-01.int.animeteamspeak.moe", + "think-01.hosts.caosh.int.animeteamspeak.moe", + "openbao.int.animeteamspeak.moe", + "secrets.infra.caosh.int.animeteamspeak.moe", + "localhost", ] + auto_renew = true + backend = "pki-infra" + ca_chain = (known after apply) + certificate = (known after apply) + common_name = "think-01" + csr = <<-EOT -----BEGIN CERTIFICATE REQUEST----- MIHOMHUCAQAwEzERMA8GA1UEAwwIdGhpbmstMDEwWTATBgcqhkjOPQIBBggqhkjO PQMBBwNCAAR+FOD1h22b4JzOYvEj5ZTB4ZLXf+82SLEbC8f9S0Y0FFKufzG2mULY Sy8i6roP8LUeJ+nj5tz7vPCKjz/bJb7FoAAwCgYIKoZIzj0EAwIDSQAwRgIhAJy5 d9tQLhPxe/TGBW8LRfJVioXPoSjy5sLkXrETg96+AiEA76UkWCF4FRCHCqb9X/zs SNzgqAocmzkYxtePG068CzA= -----END CERTIFICATE REQUEST----- EOT + expiration = (known after apply) + format = "pem" + id = (known after apply) + ip_sans = [ + "10.30.20.21", + "127.0.0.1", ] + issuing_ca = (known after apply) + min_seconds_remaining = 2592000 + name = "openbao-api" + renew_pending = (known after apply) + serial_number = (known after apply) + ttl = "8760h" } # vault_pki_secret_backend_sign.openbao_api["think-02"] will be created + resource "vault_pki_secret_backend_sign" "openbao_api" { + alt_names = [ + "think-02", + "think-02.int.animeteamspeak.moe", + "think-02.hosts.caosh.int.animeteamspeak.moe", + "openbao.int.animeteamspeak.moe", + "secrets.infra.caosh.int.animeteamspeak.moe", + "localhost", ] + auto_renew = true + backend = "pki-infra" + ca_chain = (known after apply) + certificate = (known after apply) + common_name = "think-02" + csr = <<-EOT -----BEGIN CERTIFICATE REQUEST----- MIHNMHUCAQAwEzERMA8GA1UEAwwIdGhpbmstMDIwWTATBgcqhkjOPQIBBggqhkjO PQMBBwNCAAShBW9FL0Xtk4J+0AlZ8jLDd+5dVCVvyYRFBL2DjFer1pNJt3oKJMYx z/lGJIWEFHdV9AhPIuBzn+za/eMnbO6HoAAwCgYIKoZIzj0EAwIDSAAwRQIhAJxc mfQ/jZoui/OJJqwlrRsB7bBb33aZTUM+BnW/bxfQAiBPdKJUTzSa5Q+00o9XkAD5 D7dJzsTj+BnQmeoqaqDqag== -----END CERTIFICATE REQUEST----- EOT + expiration = (known after apply) + format = "pem" + id = (known after apply) + ip_sans = [ + "10.30.20.22", + "127.0.0.1", ] + issuing_ca = (known after apply) + min_seconds_remaining = 2592000 + name = "openbao-api" + renew_pending = (known after apply) + serial_number = (known after apply) + ttl = "8760h" } # vault_pki_secret_backend_sign.openbao_api["think-03"] will be created + resource "vault_pki_secret_backend_sign" "openbao_api" { + alt_names = [ + "think-03", + "think-03.int.animeteamspeak.moe", + "think-03.hosts.caosh.int.animeteamspeak.moe", + "openbao.int.animeteamspeak.moe", + "secrets.infra.caosh.int.animeteamspeak.moe", + "localhost", ] + auto_renew = true + backend = "pki-infra" + ca_chain = (known after apply) + certificate = (known after apply) + common_name = "think-03" + csr = <<-EOT -----BEGIN CERTIFICATE REQUEST----- MIHNMHUCAQAwEzERMA8GA1UEAwwIdGhpbmstMDMwWTATBgcqhkjOPQIBBggqhkjO PQMBBwNCAATQiwFlNaY/RkNrmoW0kQPHXHj+gWSw98KTevoqgb6FdZyf+pEc75uz R0AuU4RUFKd6oOPxbxLWhMCYwK+YTyJuoAAwCgYIKoZIzj0EAwIDSAAwRQIgVqYf b6DytPDCOzNM4p03xixyVPbu52rJU2fOLu39n88CIQDei6TcSXL34igI2IRPswQR OMXIVaQWDLJhrx6JjkCiYw== -----END CERTIFICATE REQUEST----- EOT + expiration = (known after apply) + format = "pem" + id = (known after apply) + ip_sans = [ + "10.30.20.23", + "127.0.0.1", ] + issuing_ca = (known after apply) + min_seconds_remaining = 2592000 + name = "openbao-api" + renew_pending = (known after apply) + serial_number = (known after apply) + ttl = "8760h" } Plan: 4 to add, 0 to change, 0 to destroy. Changes to Outputs: + openbao_api_certs = { + think-01 = (known after apply) + think-02 = (known after apply) + think-03 = (known after apply) } ``` To apply this plan, please **merge** this pull request.
ginjiruu merged commit 666fe2844a into master 2026-11-21 01:49:09 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/iac!182
No description provided.