- name: Patch Applied Check
  hosts: 
  strategy: free
  gather_facts: false
  vars:
    var_2012_Stack: KB5001403.msu
    var_2012_Rollup: KB5011564.msu
    var_2016_Stack: KB5011570.msu
    var_2016_Rollup: KB5011495.msu
    var_2019_patch_Total: KB5011503.msu
  tasks:

  - name: Check Client OS Edition
    win_shell: "wmic os get Caption | findstr Window"
    register: OS_Edition

  - name: Patch Applied Check (2012)  
    win_shell: |
        cmd /C "wmic qfe list | findstr {{ var_2012_Stack.split('.').0 }}"
        cmd /C "wmic qfe list | findstr {{ var_2012_Rollup.split('.').0 }}"
    when: '"2012" in OS_Edition.stdout'

  - name: Patch Applied Check (2016)
    win_shell: |
        cmd /C "wmic qfe list | findstr {{ var_2016_Stack.split('.').0 }}"
        cmd /C "wmic qfe list | findstr {{ var_2016_Rollup.split('.').0 }}"
    when: '"2016" in OS_Edition.stdout'

  - name: Patch Applied Check (2019)
    win_shell: |
        cmd /C "wmic qfe list | findstr {{ var_2019_patch_Total.split('.').0 }}"
    when: '"2019" in OS_Edition.stdout'
