What would a Molecule `verify.yml` check for an Nginx role?
IntermediateScenarioPerformance, Testing and CI/CD
Answer
Situation read → Assertions on the end state.
What I'd do →
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.service_facts:
- ansible.builtin.assert:
that: "ansible_facts.services['nginx.service'].state == 'running'"
- ansible.builtin.uri:
url: http://localhost
status_code: 200
Why → Assert behaviour (running, listening, responding), not implementation details.
Interview tip → Testinfra (Python) is the older verifier option.
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?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