You install 15 packages with a loop and it is slow.
BeginnerScenarioPerformance, Testing and CI/CD
Answer
Situation read → One module call per package means 15 round trips and 15 package-manager runs.
What I'd do →
- ansible.builtin.apt:
name: [git, curl, htop, jq, unzip]
state: present
update_cache: true
cache_valid_time: 3600
Why → The package manager resolves everything in one transaction.
Interview tip → cache_valid_time avoids repeated apt update.
More on Performance, Testing and CI/CD
A playbook that touches 200 hosts takes 40 minutes. Where do you start tuning?IntermediateHow 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?IntermediateDesign a CI pipeline for an Ansible repo.Advanced`--check` shows no change but the real run changes things. Why?Advanced