Design a CI pipeline for an Ansible repo.
AdvancedScenarioPerformance, Testing and CI/CD
Answer
Situation read → End-to-end quality gates.
What I'd do →
- Lint:
yamllint,ansible-lint. - Syntax:
ansible-playbook --syntax-checkfor each playbook. - Unit/integration: Molecule per changed role.
- Dry run on staging:
--check --diff. - Deploy to staging; smoke tests.
- Manual approval; deploy to prod with
serial.
flowchart LR
A["Commit"] --> B["Lint"] --> C["Syntax check"] --> D["Molecule"] --> E["Staging check mode"] --> F["Staging deploy"] --> G["Approval"] --> H["Prod rolling deploy"]
Why → Cheaper checks run first; expensive ones only after they pass.
Interview tip → Run only changed roles in Molecule to keep the pipeline fast.
More on Performance, Testing and CI/CD
A playbook that touches 200 hosts takes 40 minutes. Where do you start tuning?IntermediateYou install 15 packages with a loop and it is slow.BeginnerHow would you test a role in CI before it reaches production?IntermediateWhat would a Molecule `verify.yml` check for an Nginx role?IntermediateMolecule's idempotence step fails. How do you find the offending task?Intermediate`--check` shows no change but the real run changes things. Why?Advanced