---
- name: Reboot the managed host to apply kernel_settings changes
  reboot:
    test_command: tuned-adm active
  listen: __kernel_settings_handler_modified
  when:
    - kernel_settings_reboot_required | d(false)
    - kernel_settings_reboot_ok | d(false)

# Since we just rebooted the machine above, a reboot is not
# needed.
- name: Clear the kernel_settings_reboot_required flag
  set_fact:
    kernel_settings_reboot_required: false
  listen: __kernel_settings_handler_modified
  when:
    - kernel_settings_reboot_required | d(false)
    - kernel_settings_reboot_ok | d(false)
