Your teammate used `command: systemctl restart app` in tasks. What do you say in review?
BeginnerScenarioPlaybook Design, Handlers and Idempotency
Answer
Situation read → Non-idempotent and reports changed every run.
What I'd do → Replace with a module and a handler.
handlers:
- name: Restart app
ansible.builtin.systemd:
name: app
state: restarted
daemon_reload: true
Why → Modules report real state; handlers restart only when something changed.
Interview tip → Use state: started plus enabled: true in a normal task for the "ensure running" part.
More on Playbook Design, Handlers and Idempotency
Your playbook reports `changed` on every run for a task that runs a shell command. How do you fix it?BeginnerNginx must reload only when its config file actually changes.BeginnerA task fails halfway and its handler never ran, but the config file was changed. The next run shows no change and the service never reloads.AdvancedYou need three tasks to notify one handler, and want it to run once. Is that automatic?BeginnerYou need to deploy a binary only if it is missing or its checksum differs.IntermediateHow do you safely edit one line in `/etc/ssh/sshd_config` and be sure SSH keeps working?Intermediate