Interview Prep/Ansible/Performance and Scale

How do you skip unchanged work to make repeat runs fast?

IntermediateProductionPerformance and Scale
Answer

Use idempotent modules (they check state quickly), creates/removes on commands, and when guards based on a version marker so expensive steps happen only on change.

- ansible.builtin.command: cat /opt/app/.version
  register: ver
  changed_when: false
  failed_when: false
- ansible.builtin.include_tasks: upgrade.yml
  when: ver.rc != 0 or ver.stdout | trim != app_version

Better: use tags to run targeted subsets, --limit to affected hosts, and fact caching. Avoid always-changed tasks, because they also trigger handlers and cost restarts.

All Ansible questions Roadmap: Ansible

More on Performance and Scale