You need three tasks to notify one handler, and want it to run once. Is that automatic?
BeginnerScenarioPlaybook Design, Handlers and Idempotency
Answer
Situation read → Several changes, one restart.
What I'd do → Just add notify: Restart app to each task.
Why → A handler runs once per play per host no matter how many tasks notified it. Use listen: to let one event trigger several handlers.
handlers:
- name: Restart app
ansible.builtin.systemd: { name: app, state: restarted }
listen: "app config changed"
Interview tip → Notify by listen topic to decouple task names from handler names.
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 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?IntermediateA task should run only on Debian-family hosts and a different one on RedHat.Beginner