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

How do you keep a task from running when invoked with `--check`, because it only makes sense for real runs?

BeginnerScenarioPerformance, Testing and CI/CD
Answer

Situation read → Check-mode-aware logic.

What I'd do →

- ansible.builtin.command: /opt/app/send-metrics
  when: not ansible_check_mode

Why → ansible_check_mode is a special variable that is true during --check.

Interview tip → ansible_diff_mode is the equivalent for --diff.

All Ansible questions Roadmap: Ansible

More on Performance, Testing and CI/CD