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

How do you write `verify` tests that are actually useful?

IntermediateProductionTesting, CI/CD and Quality
Answer

Test outcomes, not the steps Ansible already reported. Checking that /etc/nginx/nginx.conf exists after a template task proves nothing new.

Useful checks:

  • The service answers on the expected port and protocol with the expected response.
  • The config passes the application's own validator (nginx -t, sshd -t, promtool check config).
  • Security properties hold: file owner and mode, the service does not run as root, the port is not open on the public interface.
  • A restart or reboot leaves the service running (enabled, not just started).
- name: App responds with expected version
  ansible.builtin.uri:
    url: http://localhost:8080/version
    return_content: true
  register: v
  failed_when: app_version not in v.content
All Ansible questions Roadmap: Ansible

More on Testing, CI/CD and Quality