You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for more information and other secret store integrations.
24
+
For Puppet 6+ or Puppet Enterprise 2019+ users wanting to use secrets from
25
+
[Hashicorp Vault](https://www.vaultproject.io/) on their Puppet agents, this
26
+
Puppet module provides the `vault_lookup::lookup()` function.
31
27
32
-
Authentication with Vault is achieved via Puppet certificates or by using the
33
-
Approle authentication method. See the Vault documentation for more information
34
-
on setting up finer grained access controls.
28
+
When used with Puppet 6's [`Deferred`
29
+
type](https://puppet.com/docs/puppet/7/deferring_functions.html), the function
30
+
allows agents to retrieve secrets from Vault when a catalog is applied rather
31
+
than compiled. In this way, the secret data is not embedded in the catalog and
32
+
the Puppetserver does not need permissions to read all your Vault secrets.
35
33
36
-
## Requirements
37
-
38
-
This is expected to be run using the `Deferred` type, which requires Puppet
39
-
6.0.0 or later, and of course [Vault](https://www.vaultproject.io/) to store the
40
-
data.
41
-
42
-
## Setup
43
-
44
-
### To set up Vault to use the Puppet Server CA cert:
45
-
46
-
The `vault::vault_lookup()` function can use the Puppet agent's certificates in
47
-
order to authenticate to the Vault server; this means that before any agents
48
-
contact a Vault server, you must configure the Vault server with the Puppet
49
-
Server's CA certificate, and Vault must be part of the same certificate
50
-
infrastructure.
51
-
52
-
1. Set up Vault using Puppet certs (if not already set up this way)
53
-
If the Vault host has a Puppet agent on it then you can just use the existing
54
-
certificates. Otherwise generate a new certificate with `puppetserver ca` and
55
-
copy the files.
56
-
57
-
```
58
-
puppetserver ca generate --certname my-vault.my-domain.me
59
-
```
60
-
61
-
In the Vault listener configuration, set `tls_client_ca_file` as the Puppet CA
62
-
cert, `tls_cert_file` as the agent or generated certificate, and
63
-
`tls_key_file` as the agent or generated private key.
64
-
65
-
2. Enable cert auth for Vault
66
-
Hashicorp’s Vault supports a variety of auth methods that are listed in their
67
-
documentation; the auth method required for usage with the
68
-
`vault:vault_lookup()` function is named cert, and can be turned on with the
69
-
Vault CLI:
70
-
71
-
```
72
-
$ vault auth enable cert
73
-
```
74
-
3. Upload the Puppet Server CA certificate to Vault.
75
-
After cert auth has been enabled for Vault, upload the CA certificate from
76
-
your Puppet Server to Vault and add it as a trusted certificate.
77
34
78
-
```
79
-
$ vault write auth/cert/certs/puppetserver \
80
-
display_name=puppet \
81
-
policies=prod,test \
82
-
certificate=@/path/to/puppetserver/ca.pem \
83
-
ttl=3600
84
-
```
85
-
86
-
Once the certificate has been uploaded, any Puppet agent with a signed
87
-
certificate will be able to authenticate with Vault.
88
-
89
-
### To use AppRole Authentication
90
-
91
-
`vault:vault_lookup()` can also use AppRole authentication to authenticate against Vault with a valid `role_id` and `secret_id`. See [The Approle Vault Documentation](https://www.vaultproject.io/docs/auth/approle) for detailed explanations of creating and obtaining the security credentials. You will need the Role ID (non sensitive) and the Secret ID (sensitive!). The Secret ID can be provided as an argument to the `vault:vault_lookup()` function but it is recommended to pass this as an environment variable and not bake this into code.
Not all options can be set with environment variables. Use the table below to find the matching env var, if available. Also note that environment variables are only used if the option is not supplied to the function.
@@ -261,3 +232,94 @@ notify { 'show the dev namespace DB password':
261
232
}
262
233
```
263
234
235
+
## Authentication Methods
236
+
237
+
The `vault_lookup::lookup()` function can authenticate to Vault in a number of ways. This table shows the currently supported `auth_method` types:
238
+
239
+
|`auth_method`| Description |
240
+
| --- | --- |
241
+
|`cert`| (this is the default) Uses the Puppet agent's certificate via the [TLS Certificates](https://developer.hashicorp.com/vault/docs/auth/cert) auth method. |
242
+
|`approle`| Uses the [AppRole](https://developer.hashicorp.com/vault/docs/auth/approle) auth method. |
243
+
244
+
245
+
### Puppetserver CA and agent certificates
246
+
247
+
The `vault_lookup::lookup()` function by default will use the Puppet agent's
248
+
certificates to authenticate to the Vault server. This means that before any
249
+
agents contact a Vault server, you must configure the Vault server with the
250
+
Puppet Server's CA certificate, and Vault must be part of the same certificate
251
+
infrastructure.
252
+
253
+
1. Set up Vault using Puppet certs (if not already set up this way). If the
254
+
Vault host has a Puppet agent on it then you can just its existing host
255
+
certificates. Otherwise generate a new certificate with `puppetserver ca`
256
+
and copy the files.
257
+
258
+
```
259
+
$ puppetserver ca generate --certname my-vault.my-domain.me
260
+
```
261
+
262
+
In the Vault listener configuration, set `tls_client_ca_file` as the Puppet
263
+
CA cert, `tls_cert_file` as the agent's or generated certificate, and
264
+
`tls_key_file` as the agent's or generated private key.
265
+
266
+
2. Enable the `cert` auth backend in Vault.
267
+
268
+
```
269
+
$ vault auth enable cert
270
+
```
271
+
272
+
3. Upload the Puppet Server CA certificate to Vault. After `cert` auth has been
273
+
enabled for Vault, upload the CA certificate from your Puppet Server to
274
+
Vault, and add it as a trusted certificate.
275
+
276
+
```
277
+
$ vault write auth/cert/certs/puppetserver \
278
+
display_name=puppet \
279
+
policies=prod,test \
280
+
certificate=@/path/to/puppetserver/ca.pem \
281
+
ttl=3600
282
+
```
283
+
284
+
285
+
Once the certificate has been uploaded, any Puppet agent with a signed
286
+
certificate will be able to authenticate with Vault.
287
+
288
+
### AppRole
289
+
290
+
`vault:vault_lookup()` can also use AppRole authentication to authenticate
291
+
against Vault with a valid `role_id` and `secret_id`. See [The Approle Vault
292
+
Documentation](https://www.vaultproject.io/docs/auth/approle) for detailed
293
+
explanations of creating and obtaining the security credentials. You will need
294
+
the Role ID (non sensitive) and the Secret ID (sensitive!). The Secret ID can
295
+
be provided as an argument to the `vault:vault_lookup()` function but it is
296
+
recommended to pass this as an environment variable and not bake this into
0 commit comments