Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_update shows "installed:false" even after installed #331

Closed
iamgini opened this issue Jan 25, 2022 · 7 comments
Closed

win_update shows "installed:false" even after installed #331

iamgini opened this issue Jan 25, 2022 · 7 comments

Comments

@iamgini
Copy link

iamgini commented Jan 25, 2022

SUMMARY

When using ansible.windows.win_updates, we need to verify the updates are installed or not. When we register the output of ansible.windows.win_updates task, we are getting the output as "installed": false, which is wrong (!)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible.windows.win_updates

ANSIBLE VERSION
ansible [core 2.11.4] 
  config file = /Users/gini/bau/ansible-bau-windows-patching/ansible.cfg
  configured module search path = ['/Users/gini/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/gini/python-venv/ansible210/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/gini/bau/ansible-bau-windows-patching/collections
  executable location = /Users/gini/python-venv/ansible210/bin/ansible
  python version = 3.9.9 (main, Nov 21 2021, 03:23:44) [Clang 13.0.0 (clang-1300.0.29.3)]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
Collection      Version
--------------- -------
ansible.windows 1.9.0  
CONFIGURATION
$ ansible-config dump --only-changed
COLLECTIONS_PATHS(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = ['/Users/gini/bau/ansible-bau-win
DEFAULT_BECOME_ASK_PASS(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = False
DEFAULT_BECOME_METHOD(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = root
DEFAULT_FORKS(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = 25
DEFAULT_HOST_LIST(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = ['/Users/gini/bau/ansible-bau-win
DEFAULT_REMOTE_USER(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = ansible
DEFAULT_ROLES_PATH(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = ['/Users/gini/bau/ansible-bau-wi
DEFAULT_TIMEOUT(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = 5
HOST_KEY_CHECKING(/Users/gini/bau/ansible-bau-windows-patching/ansible.cfg) = False
OS / ENVIRONMENT

MacOS

$ sw_vers
ProductName:    macOS
ProductVersion: 12.1
BuildVersion:   21C52
STEPS TO REPRODUCE
  1. Create a simple task to update windows and register the output
  2. print the registered variable to see the update status.
    - name: Updating packages on Windows
      ansible.windows.win_updates:
        category_names: 
          - "*"
        reboot: no
        skip_optional: "{{ winupdate_skip_optional }}"
        state: installed
        #log_path: 
      register: package_update_status
      ignore_errors: yes

    - debug:
        msg: "{{ package_update_status }}"
EXPECTED RESULTS

The registered output should contain installed: true if the update is installed successfully.

ACTUAL RESULTS

Check below.

TASK [os-patching-windows : debug] ****************************************************************************
ok: [win2019] => {
    "msg": {
        "changed": false,
        "failed": false,
        "failed_update_count": 0,
        "filtered_updates": {},
        "found_update_count": 4,
        "installed_update_count": 0,
        "reboot_required": false,
        "updates": {
            "148819ed-5f74-4426-a455-38ac288a5e67": {
                "categories": [
                    "Security Updates",
                    "Windows Server 2019"
                ],
                "downloaded": false,
                "id": "148819ed-5f74-4426-a455-38ac288a5e67",
                "installed": false,
                "kb": [
                    "5009718"
                ],
                "title": "2022-01 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB5009718)"
            },
            "a3b20bee-07e8-4eb6-95ba-1008677c9a7c": {
                "categories": [
                    "Security Updates"
                ],
                "downloaded": false,
                "id": "a3b20bee-07e8-4eb6-95ba-1008677c9a7c",
                "installed": false,
                "kb": [
                    "5009557"
                ],
                "title": "2022-01 Cumulative Update for Windows Server 2019 (1809) for x64-based Systems (KB5009557)"
            },
@jborean93
Copy link
Collaborator

Your example task has state: searched which means updates won't be installed (why the value is false). The module will only return "installed": true if it actually installed the update in question.

@iamgini
Copy link
Author

iamgini commented Jan 25, 2022

@jborean93 my bad, copied the output from wrong task.

Updated with correct details. still facing same.

@jborean93
Copy link
Collaborator

jborean93 commented Jan 25, 2022

Can you run with -vvv and show the full output of the win_updates task? I'm interested in the module_invocation field tos ee what the input values are. But there is no reason that installed, or even downloaded should be false if it found updates and there was no failure.

@iamgini
Copy link
Author

iamgini commented Jan 25, 2022

@jborean93 sure, I will share it soon. (connecting to my lab)
Yeah, my expectation was same and wondering why its happening.

@iamgini
Copy link
Author

iamgini commented Jan 25, 2022

@jborean93
my bad; I found the issue and it was not a module issue but one of the update was causing trouble and failing updates.
I have made some error handling and the updates are working fine.

Thank you so much for the quick help.

I will mark the issue as closed.

            "f26a0046-1e1a-4305-8743-19c92c3095a5": {
                "categories": [
                    "Updates",
                    "Windows Server 2019"
                ],
                "downloaded": true,
                "failure_hresult_code": 2149842967,
                "failure_msg": "Operation was not performed because there are no applicable updates (WU_E_NOT_APPLICABLE 80240017)",
                "id": "f26a0046-1e1a-4305-8743-19c92c3095a5",
                "installed": false,
                "kb": [
                    "4577586"
                ],
                "title": "Update for Removal of Adobe Flash Player for Windows Server 2019 for x64-based systems (KB4577586)"
            }

@iamgini iamgini closed this as completed Jan 25, 2022
@jborean93
Copy link
Collaborator

Glad you were able to figure it out.

@iamgini
Copy link
Author

iamgini commented Jan 25, 2022

@jborean93
Your comment woke me up and I used the -vvv 😄 and since you confirmed that the default behaviour is installed: true, I was sure that it will be my mistake 😸

Thanks again

shahargolshani pushed a commit to shahargolshani/ansible.windows that referenced this issue Nov 24, 2024
jborean93 added a commit that referenced this issue Nov 27, 2024
…unity repo (#702)

* Initial commit

* Fix tests - ci_complete ci_coverage

* Fix up docs after migration (#95)

* Fix up docs after migration

* Fix up sanity errors

* Rebalance the test targets (#128)

* Rebalance the test targets

* Make sure IIS test removes the service so our httptester works

* Fix devel sanity checks - ci_complete (#331)

* Migrate win_timezone module to ansible.windows repo from ansible.community repo

---------

Co-authored-by: Jordan Borean <jborean93@gmail.com>
shahargolshani pushed a commit to shahargolshani/ansible.windows that referenced this issue Dec 2, 2024
shahargolshani pushed a commit to shahargolshani/ansible.windows that referenced this issue Dec 3, 2024
Yaish25491 pushed a commit to Yaish25491/ansible.windows that referenced this issue Dec 4, 2024
jborean93 added a commit that referenced this issue Dec 8, 2024
* Initial commit

* Fix tests - ci_complete ci_coverage

* removing chocolatey as they have moved to chocolatey.chocolatey (#65)

* removing chocolatey as they have moved to chocolatey.chocolatey

* more chocolatey removals

* fix sanity error

* fixing one last time I hope

* Fix up docs after migration (#95)

* Fix up docs after migration

* Fix up sanity errors

* fix up sanity ignores (#97)

* fix up sanity ignores

* Bump ansible-windows dep

* Fix bad change for win_region

* Rebalance the test targets (#128)

* Rebalance the test targets

* Make sure IIS test removes the service so our httptester works

* Fix new santiy check and stabilise external downloads (#171)

* Mark win_hotfix as unstable (#245)

* Fix devel sanity checks - ci_complete (#331)

* Update win_hotfix.ps1 (#386)

* Update win_hotfix.ps1

* Fix up docs and return values

Co-authored-by: Jordan Borean <jborean93@gmail.com>

---------

Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Jake Jackson <jljacks93@gmail.com>
Co-authored-by: fsteve800 <91268425+fsteve800@users.noreply.github.com>
amitosw15 pushed a commit to amitosw15/ansible.windows that referenced this issue Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants