github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/configuration/vault.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: vault Stanza - Agent Configuration
     4  sidebar_title: vault
     5  description: |-
     6    The "vault" stanza configures Nomad's integration with HashiCorp's Vault.
     7    When configured, Nomad can create and distribute Vault tokens to tasks
     8    automatically.
     9  ---
    10  
    11  # `vault` Stanza
    12  
    13  <Placement groups={['vault']} />
    14  
    15  The `vault` stanza configures Nomad's integration with [HashiCorp's
    16  Vault][vault]. When configured, Nomad can create and distribute Vault tokens to
    17  tasks automatically. For more information on the architecture and setup, please
    18  see the [Nomad and Vault integration documentation][nomad-vault].
    19  
    20  ```hcl
    21  vault {
    22    enabled = true
    23    address = "https://vault.company.internal:8200"
    24  }
    25  ```
    26  
    27  ## `vault` Parameters
    28  
    29  - `address` - `(string: "https://vault.service.consul:8200")` - Specifies the
    30    address to the Vault server. This must include the protocol, host/ip, and port
    31    given in the format `protocol://host:port`. If your Vault installation is
    32    behind a load balancer, this should be the address of the load balancer.
    33  
    34  - `allow_unauthenticated` `(bool: true)` - Specifies if users submitting jobs to
    35    the Nomad server should be required to provide their own Vault token, proving
    36    they have access to the policies listed in the job. This option should be
    37    disabled in an untrusted environment.
    38  
    39  - `enabled` `(bool: false)` - Specifies if the Vault integration should be
    40    activated.
    41  
    42  - `create_from_role` `(string: "")` - Specifies the role to create tokens from.
    43    The token given to Nomad does not have to be created from this role but must
    44    have "`update`" capability on "`auth/token/create/<create_from_role>`" path in
    45    Vault. If this value is unset and the token is created from a role, the value
    46    is defaulted to the role the token is from. This is largely for backwards
    47    compatibility. It is recommended to set the `create_from_role` field if Nomad
    48    is deriving child tokens from a role.
    49  
    50  - `task_token_ttl` `(string: "")` - Specifies the TTL of created tokens when
    51    using a root token. This is specified using a label suffix like "30s" or "1h".
    52  
    53  - `ca_file` `(string: "")` - Specifies an optional path to the CA
    54    certificate used for Vault communication. If unspecified, this will fallback
    55    to the default system CA bundle, which varies by OS and version.
    56  
    57  - `ca_path` `(string: "")` - Specifies an optional path to a folder
    58    containing CA certificates to be used for Vault communication. If unspecified,
    59    this will fallback to the default system CA bundle, which varies by OS and
    60    version.
    61  
    62  - `cert_file` `(string: "")` - Specifies the path to the certificate used
    63    for Vault communication. If this is set then you need to also set
    64    `tls_key_file`.
    65  
    66  - `key_file` `(string: "")` - Specifies the path to the private key used for
    67    Vault communication. If this is set then you need to also set `cert_file`.
    68  
    69  - `namespace` `(string: "")` - Specifies the [Vault namespace](https://www.vaultproject.io/docs/enterprise/namespaces)
    70    used by the Vault integration. If non-empty, this namespace will be used on
    71    all Vault API calls.
    72  
    73  - `tls_server_name` `(string: "")` - Specifies an optional string used to set
    74    the SNI host when connecting to Vault via TLS.
    75  
    76  - `tls_skip_verify` `(bool: false)` - Specifies if SSL peer validation should be
    77    enforced.
    78  
    79    !> It is **strongly discouraged** to disable SSL verification. Instead, you
    80    should install a custom CA bundle and validate against it. Disabling SSL
    81    verification can allow an attacker to easily compromise your cluster.
    82  
    83  - `token` `(string: "")` - Specifies the parent Vault token to use to derive child tokens for jobs
    84    requesting tokens.
    85    Visit the [Vault Integration Guide](/docs/vault-integration)
    86    to see how to generate an appropriate token in Vault.
    87  
    88    !> It is **strongly discouraged** to place the token as a configuration
    89    parameter like this, since the token could be checked into source control
    90    accidentally. Users should set the `VAULT_TOKEN` environment variable when
    91    starting the agent instead.
    92  
    93  ## `vault` Examples
    94  
    95  The following examples only show the `vault` stanzas. Remember that the
    96  `vault` stanza is only valid in the placements listed above.
    97  
    98  ### Nomad Server
    99  
   100  This example shows an example Vault configuration for a Nomad server:
   101  
   102  ```hcl
   103  vault {
   104    enabled     = true
   105    ca_path     = "/etc/certs/ca"
   106    cert_file   = "/var/certs/vault.crt"
   107    key_file    = "/var/certs/vault.key"
   108  
   109    # Address to communicate with Vault. The below is the default address if
   110    # unspecified.
   111    address     = "https://vault.service.consul:8200"
   112  
   113    # Embedding the token in the configuration is discouraged. Instead users
   114    # should set the VAULT_TOKEN environment variable when starting the Nomad
   115    # agent
   116    token       = "debecfdc-9ed7-ea22-c6ee-948f22cdd474"
   117  
   118    # Setting the create_from_role option causes Nomad to create tokens for tasks
   119    # via the provided role. This allows the role to manage what policies are
   120    # allowed and disallowed for use by tasks.
   121    create_from_role = "nomad-cluster"
   122  }
   123  ```
   124  
   125  ### Nomad Client
   126  
   127  This example shows an example Vault configuration for a Nomad client:
   128  
   129  ```hcl
   130  vault {
   131    enabled     = true
   132    address     = "https://vault.service.consul:8200"
   133    ca_path     = "/etc/certs/ca"
   134    cert_file   = "/var/certs/vault.crt"
   135    key_file    = "/var/certs/vault.key"
   136  }
   137  ```
   138  
   139  The key difference is that the token is not necessary on the client.
   140  
   141  ## `vault` Configuration Reloads
   142  
   143  The Vault configuration can be reloaded on servers. This can be useful if a new
   144  token needs to be given to the servers without having to restart them. A reload
   145  can be accomplished by sending the process a `SIGHUP` signal.
   146  
   147  [vault]: https://www.vaultproject.io/ 'Vault by HashiCorp'
   148  [nomad-vault]: /docs/vault-integration 'Nomad Vault Integration'