Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Ansible handlers are deferred tasks that run only after another task reports a change. Define them in a play’s handlers: section, connect ordinary tasks with notify, and Ansible runs the notified handlers after the play’s task sections. This is the standard way to restart a service only when its configuration actually changed.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
A reliable handler design depends on five details: the notifying task must return changed: true, names or topics must match, repeated notifications are merged, definition order controls execution, and handlers can be flushed early when later tasks depend on their effects.
As an Amazon Associate I earn from qualifying purchases.
What an Ansible handler is
A handler is a task with deferred, change-triggered execution. It looks like an ordinary Ansible task, but it is declared under handlers: and does not run on every playbook execution. A task elsewhere in the play sends a notification when it changes the managed host.
This pattern prevents unnecessary restarts and reloads. A template task can rewrite a web-server configuration and notify a restart handler; if the rendered file is identical to the existing file, the template reports no change and the service is left running. The same mechanism works for daemon reloads, cache refreshes, configuration validation, or any other follow-up action that should happen only after a change.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Handlers belong to the play’s handler scope. Give each handler a unique name, because handlers from roles and other play components are inserted into that scope and a later duplicate can shadow an earlier definition.
The smallest working playbook
The following play writes an Apache configuration and restarts the service only when the template task changes the destination file:
- hosts: webservers
tasks:
- name: Write the Apache configuration
ansible.builtin.template:
src: httpd.j2
dest: /etc/httpd.conf
notify: Restart apache
handlers:
- name: Restart apache
ansible.builtin.service:
name: httpd
state: restarted
The task’s notify value must identify the handler’s name exactly. The handler is not called immediately after the template task. Ansible records the notification and normally runs the handler after the play’s task sections have finished.
What happens on an unchanged run
If /etc/httpd.conf already matches the rendered template, the template task is ok, not changed. No notification is queued, so Restart apache does not run. This idempotent behavior is the principal reason to use handlers instead of placing a restart task directly after every configuration task.
Handler execution, step by step
- An ordinary task executes. Modules such as
template,copy, andlineinfilecalculate whether they changed the host. - A changed result queues notifications. A task that returns
changed: truequeues each handler name or topic listed undernotify. A task that returns no change queues nothing. - Notifications are coalesced. If several tasks notify the same handler during one play, Ansible runs that handler once rather than once per notification.
- Handlers run at the normal handler point. Ansible processes the queued handlers after the play’s task sections. They are executed in handler definition order, not in the order in which tasks notified them or in the order shown in a particular
notifylist. - The queue is cleared for that execution point. A later change can notify the handler again, and an explicit flush can run newly queued notifications at a chosen point.
| Situation | Result |
|---|---|
Notifying task reports ok |
No handler is queued. |
One task reports changed |
Each matching handler or topic is queued. |
| Three tasks notify one handler | The handler runs once at the handler execution point. |
| Two handlers are notified in reverse order | They still run in the order in which they are defined. |
| A handler is defined but never notified | It does not run. |
Connecting tasks with notify
Use a handler’s exact name for a direct notification. A task may notify one handler:
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
- name: Install the game-server configuration
ansible.builtin.template:
src: server.conf.j2
dest: /etc/game-server/server.conf
notify: Restart game server
Or it may notify several handlers:
- name: Deploy the proxy configuration
ansible.builtin.template:
src: proxy.conf.j2
dest: /etc/proxy/proxy.conf
notify:
- Validate proxy configuration
- Reload proxy
The list order above does not determine execution order. If Reload proxy is defined before Validate proxy configuration in the handlers: section, reload runs first. Arrange handler definitions in the safe operational order you need.
Recommended Free Tools
Using listen topics to fan out one event
A handler can listen for a topic that is different from its task name. Tasks notify the topic, and every handler declaring that topic runs. This is useful when one configuration change needs several responses or when you want a stable event vocabulary that is independent of implementation-specific handler names.
- name: Write the application configuration
ansible.builtin.template:
src: app.conf.j2
dest: /etc/myapp/app.conf
notify: Restart application stack
handlers:
- name: Restart application service
ansible.builtin.service:
name: myapp
state: restarted
listen: Restart application stack
- name: Refresh application proxy
ansible.builtin.service:
name: myapp-proxy
state: reloaded
listen: Restart application stack
Here the task knows only the event topic. Both listening handlers are queued when the template changes. Handler definition order still controls which listener runs first.
| Design choice | Direct handler name | listen topic |
|---|---|---|
| Coupling | The task depends on a specific handler name. | The task depends on an event topic; implementation names can change independently. |
| Fan-out | List several handler names explicitly. | One notification reaches every handler listening to the topic. |
| Collision risk | Names must remain unique across the play and inserted roles. | Topic names provide an event vocabulary, but listening handlers still need unique names. |
| Best fit | Small, local playbooks with one obvious response. | Shared roles or events that intentionally trigger multiple responses. |
| Templating | Handler names are templated early. | listen topics cannot be templated. |
Forcing handlers to run before the play ends
Most handlers should remain deferred until the normal handler point. Sometimes later tasks must see the effect immediately—for example, a configuration must be applied before a migration or a validation command can succeed. Insert the ansible.builtin.meta task with flush_handlers:
- name: Install the new application configuration
ansible.builtin.template:
src: app.conf.j2
dest: /etc/myapp/app.conf
notify: Restart application
- name: Run handlers before continuing
ansible.builtin.meta: flush_handlers
- name: Perform a check against the running application
ansible.builtin.command: /usr/local/bin/check-myapp
flush_handlers runs handlers that have been notified up to that point. Notifications generated by later tasks remain pending until the next handler execution point or another flush. Use flushes deliberately: an early restart can interrupt a deployment, and flushing too often removes the batching benefit that handlers provide.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Making command and shell tasks notify correctly
Modules that manage files and services generally know when they changed. A command or shell task may not, because Ansible cannot infer the command’s intended state. Set changed_when so the result reflects the command’s actual effect.
- name: Generate the server index
ansible.builtin.command: /usr/local/bin/build-index
register: build_index
changed_when:
- build_index.rc == 0
- build_index.stdout is search('updated')
notify: Reload game server
When changed_when is a list, its expressions have implicit and semantics: every expression must be true for the task to be marked changed. If the command reports success but did not update anything, the handler is not notified. If your condition is too broad, the handler will run on every playbook execution; if it is too narrow, required reloads will be skipped.
Loops can trigger broader handler actions
A loop is one Ansible task, even though it processes multiple items. If any loop item changes, the task is marked changed and all handlers notified by that task are queued. This can be surprising when each item represents an independent configuration file but the handler restarts a shared service.
- name: Install server drop-in files
ansible.builtin.template:
src: '{{ item }}.j2'
dest: '/etc/myapp/{{ item }}.conf'
loop:
- limits
- logging
- networking
notify: Restart application
A change to only logging still queues Restart application. If you need different follow-up behavior per item, separate the work into distinct tasks or design separate notifications rather than assuming Ansible will invoke a handler once per changed item.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteNames, roles, and handler scope
Keep names unique
Handler names share play scope. A duplicate name can make a later-loaded handler shadow an earlier one, producing a result that looks like a failed notification even though the task changed correctly. Use descriptive, specific names such as Reload nginx after gateway config rather than generic names such as Restart service in a large collection.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
Role handlers are not private by default
Handlers defined by roles are inserted into the global handler scope and can be used outside the role in which they were defined. If a role-qualified notification is required, use the role-qualified form:
- name: Apply the role-provided configuration
ansible.builtin.template:
src: app.conf.j2
dest: /etc/myapp/app.conf
notify: 'web_role : Restart application'
The role-qualified form is especially useful when different roles expose similarly named operations. It also makes the intended provider explicit when a play combines multiple roles.
Put distribution differences in module parameters
Do not rely on templated handler names to select a distribution-specific service. Handler names are templated early, which can create ordering and resolution surprises. Keep the stable handler name or topic, and template variables inside the handler’s module parameters instead:
Free tools Windows power users keep installed
One-click scans. No signup required.
handlers:
- name: Restart web service
ansible.builtin.service:
name: '{{ web_service_name }}'
state: restarted
For event grouping, remember that listen topics cannot be templated. Choose a stable literal topic and vary the handler’s parameters with ordinary variables.
Includes, imports, and handlers
Dynamic task includes
A dynamic task include can itself be notified as a handler. When the notification fires, Ansible executes the tasks supplied by that include. This lets one event activate a variable set of tasks at runtime.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
handlers:
- name: Apply database maintenance actions
ansible.builtin.include_tasks: database-maintenance.yml
Static imports
A static import is expanded before execution. The imported tasks become part of the playbook during parsing, so the import statement itself cannot be notified as a handler. If the operation must be deferred behind a notification, use a dynamic include instead.
Meta tasks as handlers
Since ansible-core 2.14, meta tasks can be used as handlers. The special flush_handlers action cannot itself be used as a handler; it is the mechanism that executes handlers already queued at a chosen point. When portability across older ansible-core versions matters, verify the behavior against the version installed in your execution environment.
Why a handler did not run: a diagnostic checklist
Work through these checks in order:
- Did the notifying task report a change? A task result of
okdoes not queue a handler. For command and shell tasks, inspectchanged_when. - Does the notification match? Compare spelling, capitalization, punctuation, and whitespace in a direct handler name. For topics, confirm the task notifies the literal value used by
listen. - Is the handler in scope? Confirm it is under the relevant play’s
handlers:section or supplied by a role that is loaded for that play. - Was a duplicate name loaded later? A later definition can shadow an earlier handler. Rename handlers or use a role-qualified notification where appropriate.
- Did a loop behave differently than expected? Any changed item marks the task changed and can trigger every handler notified by that task.
- Was execution deferred? A notification normally waits until the play’s handler point. Add
ansible.builtin.meta: flush_handlersonly when the handler must run before subsequent tasks. - Are you using an include or import? A dynamic include can be notified; a static import is expanded before execution and the import statement cannot be notified.
- Are variables being templated in the wrong place? Keep variable-driven service names and paths in module parameters, not in handler names or
listentopics.
Design patterns that keep handlers predictable
Use one event for one operational outcome
Name a direct handler after the action it performs, such as Reload proxy or Restart worker pool. Use a topic when the event has several legitimate consumers, such as a configuration deployment that must reload both a service and its proxy.
Keep validation and activation separate
A configuration-writing task can notify a validation handler and an activation handler. Define them in the order required by your operation. If validation must happen before activation, place the validation handler first in the handler section; the order of the notify list cannot override that definition order.
Batch related changes
Let several template and copy tasks notify the same restart handler. Ansible coalesces those notifications, so a play that changes five related files still performs one restart at the normal handler point. This reduces service churn while preserving idempotence.
Flush only at a real dependency boundary
Use a flush when a later task must interact with the newly restarted or reloaded service. Otherwise, leave notifications deferred so all changes in the play can be applied together.
A complete example with validation, a topic, and an early flush
- hosts: game_servers
tasks:
- name: Deploy the server configuration
ansible.builtin.template:
src: server.conf.j2
dest: /etc/game-server/server.conf
notify: game server configuration changed
- name: Deploy the access-control configuration
ansible.builtin.template:
src: access.conf.j2
dest: /etc/game-server/access.conf
notify: game server configuration changed
- name: Apply configuration before checking readiness
ansible.builtin.meta: flush_handlers
- name: Check the running server
ansible.builtin.command: /usr/local/bin/game-server --check-ready
handlers:
- name: Validate game-server configuration
ansible.builtin.command: /usr/local/bin/game-server --validate-config
listen: game server configuration changed
- name: Restart game-server service
ansible.builtin.service:
name: game-server
state: restarted
listen: game server configuration changed
Both file tasks publish the same event topic. If neither file changes, neither listener runs. If one or both change, validation and restart are each queued once, in the order shown in the handler section. The explicit flush makes the running service reflect the new configuration before the readiness command executes.
Version and portability considerations
Most handler behavior—change-triggered execution, coalescing, definition order, direct names, and listening topics—is foundational Ansible behavior. The details around meta tasks and include handling are version-sensitive. In particular, meta tasks are documented as usable handlers beginning with ansible-core 2.14, while flush_handlers remains an execution control task rather than a handler target. When a playbook must run across multiple ansible-core versions, test these constructs against the oldest supported version and keep version-specific assumptions documented near the affected task.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




