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
Copy file name to clipboardExpand all lines: README.md
+64-3Lines changed: 64 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,15 @@
11
11
12
12
1.[Description](#description)
13
13
1.[Setup](#setup)
14
+
1.[Managed Service Identity (MSI) vs Service Principal Credentials](#managed-service-identity-msi-vs-service-principal-credentials)
14
15
1.[How it works](#how-it-works)
15
16
*[Puppet Function](#puppet-function)
16
17
*[Hiera Backend](#hiera-backend)
17
18
1.[How it's secure by default](#how-its-secure-by-default)
18
19
1.[Usage](#usage)
19
20
*[Embedding a secret in a file](#embedding-a-secret-in-a-file)
20
21
*[Retrieving a specific version of a secret](#retrieving-a-specific-version-of-a-secret)
22
+
*[Retrieving a certificate](#retrieving-a-certificate)
21
23
1.[Reference - An under-the-hood peek at what the module is doing and how](#reference)
22
24
1.[Development - Guide for contributing to the module](#development)
23
25
@@ -32,19 +34,29 @@ The module requires the following:
32
34
33
35
* Puppet Agent 6.0.0 or later.
34
36
* Azure Subscription with one or more vaults already created and loaded with secrets.
35
-
* Puppet Server running on a machine with Managed Service Identity ( MSI ) and assigned the appropriate permissions
37
+
* One of the following authentication strategies
38
+
* Managed Service Identity ( MSI )
39
+
* Puppet Server running on a machine with Managed Service Identity ( MSI ) and assigned the appropriate permissions
36
40
to pull secrets from the vault. To learn more or get help with this please visit https://docs.microsoft.com/en-us/azure/active-directory/managed-service-identity/tutorial-windows-vm-access-nonaad
41
+
* Service Principal
42
+
* Following the required steps to setup a Service Principal. To learn more or get help with this please visit https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
43
+
44
+
# Managed Service Identity (MSI) vs Service Principal Credentials
45
+
46
+
This module provides 2 ways for users to authenticate with azure key vault and pull secrets. These 2 options are Managed Service Identity ( MSI ) and Service Principal Credentials. We highly recommend you utilize Managed Service Identity over service principal credentials whenever possible. This is because you do not have to manage and secure a file on our machines that contain credentials! In some cases, Managed Service Identity ( MSI ) might not be an option for you. One example of this is if your Puppet server and some of your puppet agents are not hosted in Azure. In that case, you can create a Service Principal in Azure Active Directory, assign the appropriate permissions to this Service Principal, and both the function and Hiera Backend provided in this module can authenticate to Azure Keyvault using the credentials of this Service Principal.
37
47
38
48
## How it works
39
49
40
50
### Puppet Function
41
51
42
-
This module contains a Puppet 4 function that allows you to securely retrieve secrets from Azure Key Vault. In order to get started simply call the function in your manifests passing in the required parameters:
52
+
This module contains a Puppet 4 function that allows you to securely retrieve secrets from Azure Key Vault. In order to get started simply call the function in your manifests passing in the required parameters.
This example show how to utilize service principal credentials if you for some reason are unable to use Managed Service Identity ( MSI ) at your organization. The client_secret must be of type "Sensitive". Please ensure you configure hiera to return the value wrapped in this type as this is what the secret function expects to ensure there is possibilty of leaking the client_secret.
88
+
60
89
### Hiera Backend
61
90
62
91
This module contains a Hiera 5 backend that allows you to securely retrieve secrets from Azure key vault and use them in hiera.
63
92
93
+
94
+
#### Using Managed Service Identity ( MSI )
95
+
64
96
Add a new entry to the `hierarchy` hash in `hiera.yaml` providing the following required lookup options:
65
97
66
98
```yaml
@@ -77,6 +109,33 @@ Add a new entry to the `hierarchy` hash in `hiera.yaml` providing the following
77
109
- '^password.*'
78
110
```
79
111
112
+
#### Using Service Principal Credentials
113
+
114
+
To utilize service principal credentials in hiera simply replace `metadata_api_version` with `service_principal_credentials` and ensure it points to a valid yaml file that contains the service principal credentials you would like to use.
Below is the format of the file that is expected to contain your service principal credentials.
132
+
133
+
```yaml
134
+
tenant_id: '00000000-0000-1234-1234-000000000000'
135
+
client_id: '00000000-0000-1234-1234-000000000000'
136
+
client_secret: some-secret
137
+
```
138
+
80
139
To retrieve a secret in puppet code you can use the `lookup` function:
81
140
82
141
```puppet
@@ -110,6 +169,8 @@ Alternatively a custom trusted fact can be included [in the certificate request]
110
169
- '^password.*'
111
170
```
112
171
172
+
**NOTE: While the above examples show manual lookups happening, it's recommended and considered a best practice to utilize Hiera's automatic parameter lookup (APL) within your puppet code**
173
+
113
174
### What is confine_to_keys?
114
175
115
176
By design, hiera will traverse the configured heiarchy for a given key until one is found. This means that there can be a potentially large number of web requests against azure key vault. In order to improve performance and prevent hitting the Azure KeyVault rate limits ( ex: currently there is a maximum of 2,000 lookups every 10 seconds allowed against a key vault), the confine_to_keys allows you to provide an array of regexs that help avoid making a remote call.
# @param vault_name Name of the vault in your Azure subscription.
6
6
# @param secret_name Name of the secret to be retrieved.
7
-
# @param api_versions_hash A Hash of the exact versions of the metadata_api_version and vault_api_version to use.
7
+
# @param api_endpoint_hash A Hash with API endpoint and authentication information
8
8
# @param secret_version The version of the secret you want to retrieve. This parameter is optional and if not passed the default behavior is to retrieve the latest version.
9
9
# @return [Sensitive[String]] Returns the secret as a String wrapped with the Sensitive data type.
0 commit comments