How do you secure the supply chain of collections and roles?
AdvancedProductionSecurity and Secrets
Answer
- Pin exact versions in
requirements.ymland commit it, neverlatest. - Mirror what you need in a private Galaxy/Automation Hub and install only from it (
galaxy_serverlist inansible.cfg). - Verify integrity with
ansible-galaxy collection verify, and require GPG signatures for collections that provide them. - Bake approved versions into execution environment images, scan them (Trivy, Grype), and sign images.
- Review roles from Galaxy before use. Their tasks run as root on your hosts.
ansible-galaxy collection install community.general:10.1.0 \
--keyring ~/.ansible/pubring.kbx --required-valid-signature-count 1
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