How do you deploy private keys and certificates safely?
IntermediateProductionSecurity and Secrets
Answer
- ansible.builtin.copy:
content: "{{ vault_tls_key }}"
dest: /etc/ssl/private/app.key
owner: root
group: ssl-cert
mode: "0640"
no_log: true
notify: Reload nginx
Use content: from a vaulted variable or a secret-manager lookup, restrictive mode and owner, no_log, and a handler to reload. Do not leave copies in /tmp. For certificates prefer ACME automation (certbot or community.crypto.acme_certificate) over copying long-lived files by hand.
More on Security and Secrets
How do you set up a secure automation user and SSH access?BeginnerHow do you give the automation user sudo with least privilege?IntermediateWhat are the alternatives to Ansible Vault for secrets, and when do you use them?IntermediateHow do you read AWS Secrets Manager and SSM parameters in a playbook?IntermediateHow do you integrate HashiCorp Vault with Ansible?AdvancedHow do you stop secrets from leaking into logs and output?Beginner