Files
toallab-automation/roles/oatakan.windows_update/tasks/main.yml

68 lines
2.5 KiB
YAML

---
- debug:
msg: "win update server: {{ win_update_server }}"
when: win_update_server is defined
- name: disable firewall for Domain, Public and Private profiles
win_shell: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
when:
- "'Windows Server 2012' in ansible_distribution or 'Windows 8' in ansible_distribution"
- windows_update_disable_firewall | bool
- name: disable firewall for Domain, Public and Private profiles
win_shell: netsh advfirewall set allprofiles state off
when:
- "'Windows Server 2008' in ansible_distribution or 'Windows 7' in ansible_distribution"
- windows_update_disable_firewall | bool
- name: get used space before update
win_shell: Get-PSDrive C | Select-Object Used | ConvertTo-Json
register: used_space_before_update
ignore_errors: yes
- name: reset some facts
set_fact:
update_retry_count: 0
missing_hotfixes: []
failed_kb: []
_reject_list: []
- include_tasks: updates-all.yml
when:
- "'Windows Server 2008' not in ansible_distribution"
- "'Windows 7' not in ansible_distribution"
#- include_tasks: updates-powershell.yml
# when:
# - install_updates | bool
# - "'Windows Server 2008' in ansible_distribution"
- include_tasks: updates-win2008r2.yml
when:
- "'Windows Server 2008' in ansible_distribution or 'Windows 7' in ansible_distribution"
- name: get used space after update
win_shell: Get-PSDrive C | Select-Object Used | ConvertTo-Json
register: used_space_after_update
ignore_errors: yes
- debug:
msg:
- "Used space before update: {{ ((used_space_before_update.stdout | from_json)['Used']|int / (1024*1024*1024)) | round(2, 'floor') }} GB"
- "Used space after update: {{ ((used_space_after_update.stdout | from_json)['Used']|int / (1024*1024*1024)) | round(2, 'floor') }} GB"
when:
- used_space_before_update.stdout is defined
- used_space_after_update.stdout is defined
- name: enabled firewall for Domain, Public and Private profiles
win_shell: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
when:
- "'Windows Server 2012' in ansible_distribution or 'Windows 8' in ansible_distribution"
- windows_update_disable_firewall | bool
- name: enable firewall for Domain, Public and Private profiles
win_shell: netsh advfirewall set allprofiles state on
when:
- "'Windows Server 2008' in ansible_distribution or 'Windows 7' in ansible_distribution"
- windows_update_disable_firewall | bool