2022-12-31 20:10:59 +01:00
|
|
|
---
|
|
|
|
- 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:
|
2022-12-31 20:40:01 +01:00
|
|
|
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
|
2022-12-31 20:10:59 +01:00
|
|
|
|
|
|
|
- name: Akivate Windows
|
|
|
|
ansible.windows.win_powershell:
|
2022-12-31 20:40:01 +01:00
|
|
|
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
|
|
|
|
|
2022-12-31 22:58:55 +01:00
|
|
|
- name: Install Windows Updates
|
2022-12-31 20:40:01 +01:00
|
|
|
ansible.windows.win_updates:
|
|
|
|
category_names:
|
|
|
|
- SecurityUpdates
|
|
|
|
- CriticalUpdates
|
2022-12-31 22:58:55 +01:00
|
|
|
- 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
|
2022-12-31 20:40:01 +01:00
|
|
|
|
2022-12-31 22:58:55 +01:00
|
|
|
- name: Post Update Check
|
2022-12-31 20:40:01 +01:00
|
|
|
ansible.windows.win_updates:
|
|
|
|
category_names:
|
2022-12-31 22:58:55 +01:00
|
|
|
- Application
|
|
|
|
- Connectors
|
|
|
|
- CriticalUpdates
|
|
|
|
- DefinitionUpdates
|
|
|
|
- DeveloperKits
|
|
|
|
- FeaturePacks
|
|
|
|
- Guidance
|
|
|
|
- SecurityUpdates
|
|
|
|
- ServicePacks
|
|
|
|
- Tools
|
2022-12-31 20:40:01 +01:00
|
|
|
- UpdateRollups
|
2022-12-31 22:58:55 +01:00
|
|
|
- Updates
|
|
|
|
register: res
|
|
|
|
|
|
|
|
- name: Host is rebooting in 15 sec!!
|
|
|
|
ansible.windows.win_reboot:
|
|
|
|
pre_reboot_delay: 15
|
|
|
|
when:
|
|
|
|
- res.reboot_required | bool
|