Interview Prep/Ansible/Testing, CI/CD and Quality

How does a CI pipeline get credentials to deploy with Ansible without long-lived secrets?

AdvancedProductionTesting, CI/CD and Quality
Answer

Use short-lived, identity-based credentials:

  • Cloud APIs: OIDC federation. GitHub Actions or GitLab exchanges its job token for a temporary AWS role; no access keys stored anywhere.
  • SSH: SSH certificates signed per job by Vault or a CA with a 30 to 60 minute TTL, or SSM Session Manager so there is no SSH at all.
  • Vault password / secrets: fetched at runtime from Vault or Secrets Manager using the same OIDC identity.
permissions:
  id-token: write
  contents: read
steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/ci-ansible-prod
      aws-region: ap-south-1

Scope the IAM role's trust policy to the repo and the protected branch or environment, so a fork or feature branch cannot assume the prod role.

All Ansible questions Roadmap: Ansible

More on Testing, CI/CD and Quality