Exercise 2: Installing firewalld Only on RedHat-Family Hosts — Possible Solution ==================================================================== - name: Install firewalld on RedHat-family hosts yum: name: firewalld state: present when: ansible_os_family == "RedHat" Explanation: This directly mirrors the chapter's own ansible_os_family == "Debian" example, just testing for "RedHat" instead and installing a package appropriate to that family (firewalld, RedHat/CentOS/Fedora's own common firewall management tool, using the yum module rather than apt, since apt wouldn't exist on a RedHat-family host in the first place). ansible_os_family is one of the automatically gathered facts the chapter describes -- available without any extra setup, simply because fact gathering ran at the start of the play. The when: clause means this task is skipped entirely (not run, not reported as failed) on any host where ansible_os_family isn't exactly "RedHat" -- so running this same playbook against a mixed inventory of Debian and RedHat-family hosts would only actually install firewalld on the RedHat-family ones. WHY THIS WORKS AS AN ANSWER ------------------------------ This builds a correctly structured conditional task using the exact when:/ansible_os_family pattern from the chapter's own example, choosing an appropriately RedHat-specific module (yum) and package (firewalld) rather than reusing Debian-specific tooling.