DevOps / Ansible Interview questions
What happens when a handler is notified multiple times in a play?
Even if several different tasks across a play all call notify on the same handler name, and each of those tasks independently reports changed, Ansible still only executes that handler once, at the point handlers run (by default, at the end of the play).
tasks: - name: Update main config ansible.builtin.template: src: app.conf.j2 dest: /etc/app/app.conf notify: Restart app - name: Update feature flags ansible.builtin.template: src: flags.conf.j2 dest: /etc/app/flags.conf notify: Restart app handlers: - name: Restart app ansible.builtin.service: name: app state: restarted
Internally, Ansible tracks notified handlers as a de-duplicated set per host rather than a queue that fires once per notification, which is exactly the behavior you want: a service that needed to pick up two separate config changes only needs one restart to reflect both, not two back-to-back restarts. This also means handler order is determined by where the handler is defined (in handlers/main.yml or the playbook's handlers section), not by which task happened to notify it first or last.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
