--- - name: Check if product key is defined ansible.builtin.fail: msg: Plese define windows product key when: windows_product_key == 'undefined' - name: Set windows product key ansible.windows.win_powershell: script: 'cscript.exe "C:\Windows\System32\slmgr.vbs" /ipk {{ windows_product_key }}' register: a1 - name: Show Script Output ansible.builtin.debug: msg: "{{ a1.output }}" verbosity: 1 - name: Akivate Windows ansible.windows.win_powershell: script: 'cscript.exe "C:\Windows\System32\slmgr.vbs" /ato' register: a2 - name: Show Script Output ansible.builtin.debug: msg: "{{ a2 }}" verbosity: 1 - name: Get product id and product key community.windows.win_product_facts: - name: Display Windows edition ansible.builtin.debug: var: ansible_os_license_edition - name: Display Windows license status ansible.builtin.debug: var: ansible_os_license_status - name: Install Windows Updates ansible.windows.win_updates: category_names: - SecurityUpdates - CriticalUpdates - UpdateRollups - Updates reboot: false register: res - name: Host is rebooting in 15 sec!! ansible.windows.win_reboot: pre_reboot_delay: 15 when: - res.reboot_required | bool - name: Post Update Check ansible.windows.win_updates: category_names: - Application - Connectors - CriticalUpdates - DefinitionUpdates - DeveloperKits - FeaturePacks - Guidance - SecurityUpdates - ServicePacks - Tools - UpdateRollups - Updates register: res - name: Host is rebooting in 15 sec!! ansible.windows.win_reboot: pre_reboot_delay: 15 when: - res.reboot_required | bool