From the course: Red Hat Certified Engineer (EX294) Cert Prep: 2 Using Ansible Playbooks
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Playbook change handlers
From the course: Red Hat Certified Engineer (EX294) Cert Prep: 2 Using Ansible Playbooks
Playbook change handlers
- [Instructor] As I've mentioned before, modules should be idempotent, so you can run a playbook as many times as you want, and the results are always the same. If a task is already in the desired state, that task should exit. If a task makes a change, we can fire an event using Ansible's basic event system that can be used to respond to that change. Let me first talk about how we'd do this without using Ansible's event system and outline the pitfalls. Let's say we create a task using the copy module, in this task we copy the apache config file to its appropriate destination on our node. After this, we use a service module to restart the service. We could make an additional task that ensures that the apache package is updated and restart the service as well. The problem is that we're blindly restarting the service, and we may even have more than one task restarted in the apache service unnecessarily. To set up a change…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Introduction to playbooks1m 33s
-
(Locked)
Playbook language2m 4s
-
(Locked)
YAML tips and tricks4m 6s
-
(Locked)
Install the Atom editor2m 37s
-
(Locked)
Configure VIM for YAML6m 20s
-
(Locked)
Playbook hosts and users5m 22s
-
(Locked)
Playbook tasks list2m 43s
-
(Locked)
Playbook change handlers3m 2s
-
(Locked)
Verify Playbooks2m 59s
-
-
-
-
-
-
-