---
- name: Windows updates
  hosts: "{{ _hosts | default('os_windows') }}"
  vars:
    report_server: aws_win1

  tasks:

    - name: Assert that host is in webservers group
      ansible.builtin.assert:
        that: "'{{ report_server }}' in groups.os_windows"
        msg: "Please run the 'Deploy Cloud Stack in AWS' Workflow Job Template first"

    - name: Patch windows server
      ansible.builtin.include_role:
        name: demo.patching.patch_windows

    - name: Build report server
      delegate_to: "{{ report_server }}"
      run_once: true  # noqa: run-once[task]
      block:
        - name: Install report server
          ansible.builtin.include_role:
            name: "{{ item }}"
          loop:
            - demo.patching.report_server
            - demo.patching.report_windows
            - demo.patching.report_windows_patching

        - name: Update landing page
          ansible.builtin.include_role:
            name: demo.patching.report_server
            tasks_from: windows_landing_page
