The Problem
Manifests and Hiera data go into Git. If a database password is written there in plain text, everyone with repository access can read it, and it stays in the Git history for ever. Secrets can also leak through logs, reports, PuppetDB and the catalog. Puppet gives you several tools to reduce this.
Where Secrets Can Leak
| Place | Risk | Protection |
|---|---|---|
| Git repository | Anyone who clones sees plain text | Encrypt values with eyaml, or store only references |
| Catalog on the server | Contains resource values | Use Sensitive so values are hidden in logs and reports |
| Agent reports and logs | Diffs of changed files show content | Sensitive and show_diff => false |
| PuppetDB | Stores catalogs and reports | Sensitive data is redacted in reports, check your version and settings |
| Files on the node | Readable by other users | Strict mode and owner |
Command lines (exec) | Visible in ps | Pass secrets by files or environment, not arguments |
hiera-eyaml: Encrypted Values in YAML
hiera-eyaml lets you encrypt individual values in a YAML file. The file stays readable and diff-friendly. Only the server's private key can decrypt.
Configure hiera.yaml
Sensitive[String] $admin_password in the class. When Hiera returns a string, Puppet wraps it, so it is redacted in logs.
The Sensitive Type
Sensitive values print as [redacted] in notices, reports and diffs. Call unwrap only where you must write the real value. A template that outputs a Sensitive value makes the resulting file content sensitive too.
Fetch Secrets on the Agent: Deferred Functions
With eyaml, the secret is decrypted on the server and placed in the catalog. A Deferred function is different: the catalog contains only the *call*, and the agent runs it at apply time, for example to read from a vault. The secret does not sit in the catalog or PuppetDB.
puppetlabs-vault_lookup) for your Puppet version.
HashiCorp Vault Example
Vault, cloud secret managers (AWS Secrets Manager, Azure Key Vault) and tools such as 1Password or CyberArk each have Puppet modules or custom Hiera backends. The pattern is the same: store secrets centrally, fetch them at the last moment, limit who can read them.
Other Safe Habits
- Never commit private keys,
private_key.pkcs7.pem, or Vault tokens to Git - Restrict the Puppet server, because it can decrypt everything (use full disk encryption and limited admin access)
- Set
mode '0600'and the correct owner for every secret file - Use
show_diff => falsewhereSensitivecannot be used - Do not print secrets with
notice()orexeccommand arguments - Rotate secrets: change the encrypted value, commit, deploy, and Puppet updates nodes on the next run
- Use different keys or data per environment so staging cannot decrypt production secrets
Checking for Leaks
Practice Tasks
- Create an eyaml key pair on a lab server and encrypt a password
- Configure
hiera.yamlwitheyaml_lookup_keyand read the value in a class with aSensitive[String]parameter - Write the secret into a file with mode
0600and check that Puppet output hides it - Try
eyaml decryptwith and without the private key - Describe how you would rotate the database password across 50 servers
Conclusion
Never put plain secrets in Git. Encrypt values with hiera-eyaml, type them as Sensitive, protect the files that hold them, and move to agent-side Deferred fetching from a vault when you need a stronger model.

