--- - include_tasks: install_dism.yml - name: check installed kbs win_shell: wmic qfe | ConvertTo-Json register: installed_kbs - name: missing hotfixes set_fact: missing_hotfixes: "{{ hotfixes | json_query(query) }}" vars: set_installed_kbs: "{{ (installed_kbs.stdout | from_json) | reject('match', '^$') | reject('match', '^Caption *') | map('regex_replace', '^.* (KB[0-9]+) .*', '\\1') | list }}" query: "[?!contains(`{{ set_installed_kbs }}`, kb)]" - include_role: name: "{{ windows_hotfix_role }}" loop: "{{ missing_hotfixes }}" loop_control: loop_var: hotfix - name: check for available updates win_updates: server_selection: "{{ win_update_server_selection }}" category_names: "{{ win_update_category_names }}" reject_list: "{{ win_update_reject_list | default(omit) }}" state: searched register: available_updates - debug: msg: "{{ _msg.split('\n')[:-1] }}" vars: _msg: | {{ inventory_hostname }} has {{ available_updates.found_update_count }} updates available. {% for update in updates %} - {{ update.title }} {% endfor %} updates: "{{ (available_updates.updates.values() | list) if (available_updates.updates is mapping) else (available_updates.updates) }}" when: available_updates.updates is defined - include_tasks: updates-with-retry.yml when: - available_updates.updates is defined - available_updates.found_update_count > 0 - name: check for missing updates. win_updates: server_selection: "{{ win_update_server_selection }}" state: searched register: available_updates - name: list missing updates debug: var: available_updates