windows patching_uninstall

31 views
Skip to first unread message

Vandana Thakur

unread,
May 22, 2019, 6:36:39 AM5/22/19
to : Ansible Project
Hello All!

I need to uninstall the windows install package with KB article with help of  ansible.
the  win_update is  not happy with 'absent'

Please help.

Thanks

J Hawkesworth

unread,
May 22, 2019, 12:30:41 PM5/22/19
to Ansible Project

Hmm, I have not had to do this myself.  One thing you could try is using wusa, although I think you may well have to use 'become' on your task as I believe wusa won't run in a 'normal' ansible remote login

- name: uninstall KB1234
win_shell: wusa /uninstall /kb:1234
become: yes

Hope this helps,

Jon

Vandana Thakur

unread,
May 23, 2019, 2:29:03 AM5/23/19
to 'J Hawkesworth' via Ansible Project
Hello Jon,

Thanks.
I  worked but to restart the os after uninstall , i  am using this :

    - name: uninstall kb
      win_shell: WUSA /uninstall /kb:{{ kbno }}  /quiet /norestart
      register: uninstall


    - debug: var="uninstall"

    - win_reboot:
      when: uninstall.rc == 0
      reboot_timeout: 1500
      post_reboot_delay: 100


if  the uninstall is  successful.

Since without "  /quiet /norestart " the job was getting stuck as it  needed user input to whether restart or not at windows server side.


Is there any better way to  handle the user input to restart if required in playbook.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/13305499-fb6f-4797-ab77-43701448584f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

lloyd noble

unread,
Jul 28, 2022, 2:05:13 AM7/28/22
to Ansible Project
I am struggling with a proper way to remove a patch KB your method is failing for me

---
- name: Install all windows security and critical updates and wait 10 mins
  hosts: all
  become: false
  tasks:
 - name: uninstall kb
      win_shell: WUSA /uninstall /kb:{{ 5015811 }}  /quiet /norestart
      register: uninstall

Error:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
  did not find expected '-' indicator
The error appears to be in '/tmp/bwrap_180_6em4f0yx/awx_180_n9swe56o/project/winupdateuninstall.yml': line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
     - name: uninstall kb
      win_shell: WUSA /uninstall /kb: "{{ 5015811 }}"  /quiet /norestart
      ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
    with_items:
      - {{ foo }}
Should be written as:
    with_items:
      - "{{ foo }}"
Reply all
Reply to author
Forward
0 new messages