You are writing an Ansible playbook that copies an updated Nginx configuration file to each web server. The configuration change should take effect only if the copy operation actually modifies the file, and in that case the Nginx service must be restarted by a handler named reload-nginx. Which YAML key should you add to the file-copying task so that Ansible calls the handler only when the task reports a change?
The notify key is added inside a task to reference one or more handlers. When the task's result is changed, Ansible queues the referenced handler(s) to run after all tasks in the current play. No notification occurs if the task is skipped or returns "ok" with no change. The listen keyword belongs in the handler itself, register merely stores a task's output, and delegate_to runs a task on another host without affecting handler invocation.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
How does the 'notify' keyword work in an Ansible playbook?
Open an interactive chat with Bash
What is the purpose of the 'listen' keyword in an Ansible handler?
Open an interactive chat with Bash
When should the 'delegate_to' keyword be used in a task?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access