Working with Secrets
You use secrets in an inventory to protect sensitive information from anyone who does not have the rights to see this information.
The secret values protected by nevisAdmin 4 cannot be individually modified or viewed in the inventory once they are inserted; they are stored in the database in encrypted form. However, it is possible to modify and view the secret values in the Secret & Files screen if you have the required permissions. For more details, see the chapter Secrets & Files.
Protecting passwords
For example, consider a component that needs to connect to a database. Instead of putting the password as plain text in the inventory file, you can add it as a secret variable in the inventory.
Passwords are visible in generated configuration files, for example in the deployment wizard.
However, for Kubernetes deployments, if the secret is used in secret fields (secret properties), these secrets are not exposed, they are not visible in Git or the generated configuration files. This is done by mapping the secrets used in the inventory to corresponding Kubernetes secrets, then mounting them into the component containers, where they are used to resolve the secrets in the generated configuration files. For more information about the secret fields, see chapter Special Input Field Type: Secret fields.
Inserting a Secret
There are several ways to add a secret to an inventory:
- Via the Insert secret button in the Inventory Editor. This will create an inventory level secret, which you can only use in the given inventory.
- By using an existing secret (on a global or inventory level).
- Using a global secret: Global secrets can be used in multiple inventories. To use a global secret, refer to it from the given inventory. If the global secret does not exist yet, create it via the Create global secret button in the Secret & Files screen. To open this screen, go to the sidebar of the Administration tab, and select Secret & Files from the Global Settings menu. For more information, see the chapter Secrets & Files.
- Using an existing inventory level secret: To use an existing secret on inventory level, the secret must have been used in the given inventory before.
Inserting a new secret value into an inventory
To insert a new secret value into an inventory, perform the next steps:
- Put you cursor right after the variable name inside a vars block, for example after __connection_password: .
- Click the Insert secret button.
- The Insert secret dialog opens. Enter the secret value for this variable in the Define secret for variable
<var name>input field. - Add a description, if needed. The description will be visible in Secret & Files screen and also in the Inventory Editor on hovering over the inserted secret value.
- Click Insert secret to add the secret value to the variable in the inventory file.
- Click on Save changes in the lower right corner of the inventory file.
The following movie demonstrates the steps you need to perform. As an example, a secret is inserted for the __connection_password variable for SSH connections.
Note that it is usually more secure to configure key-based authentication. For more information, see Deployment via SSH.
Using an already existing global secret
There are several ways to use an already existing global secret.
-
By manually copy-pasting the reference ID into the inventory. For this, perform the following steps:
- Open the Secrets & Files screen and find your global secret in the table.
- Copy the reference ID (secret ID).
- Click inside the inventory file in the Inventory Editor.
- Put you cursor right after the variable name inside a vars block, for example after __connection_password: .
- Paste the reference ID to the variable as a value.
- Click on Save changes in the lower right corner of the inventory file.
-
By selecting the existing global secret from the list. For this, perform the following steps:
- Click inside the inventory file in the Inventory Editor.
- Put you cursor right after the variable name inside a vars block, for example after __connection_password: .
- Click on the Insert secret button.
- Select the existing global secret from the select existing secret dropdown.
You can still reuse a secret that was previously removed from the inventory. The secret only becomes unusable when it is removed from the Secret & Files screen.
- Click Insert secret to add the secret value to the variable in the inventory file.
- Click on Save changes in the lower right corner of the inventory file.
The following movies demonstrate the two possible ways of inserting an existing global secret.