Trying to install Feature update to Windows 10, version 1909 with Ansible

111 views
Skip to first unread message

Alan Woods

unread,
Jul 6, 2020, 1:59:39 PM7/6/20
to Ansible Project
Hello I am trying to install windows 10 feature updates or upgrades. The playbook I am using seems to download it but it will not install it. I still need to go into windows updates and hit retry then it installs.  This is the playbook I am currently using:


---
- hosts: win10-pro-1
 gather_facts: yes
 tasks:
   - name: Re-Boot PC before upgrade
     win_reboot:

    - name: Upgrade Windows 10
     win_updates:
       category_names:
         - Upgrades
       state: installed
     register: update_result

    - name: reboot host if required
     win_reboot:
     when: update_result.reboot_required

I just added the first task to re-boot the PC first because I get errors sometimes that the PC needs to be re-booted first. The playbook runs with no errors and this is the what I get when running it.

[vagrant@controller win_10_Updates]$ ansible-playbook testFeatureUPdate.yml

PLAY
[win10-pro-1] ***********************************************************************************************************************

TASK
[Gathering Facts] *******************************************************************************************************************
ok
: [win10-pro-1]

TASK
[Re-Boot PC before upgrade] *********************************************************************************************************
changed
: [win10-pro-1]

TASK
[Upgrade Windows 10] ****************************************************************************************************************
changed
: [win10-pro-1]

TASK
[reboot host if required] ***********************************************************************************************************
changed
: [win10-pro-1]

PLAY RECAP
*******************************************************************************************************************************
win10
-pro-1                : ok=4    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

[vagrant@controller win_10_Updates]$



I am trying to get Ansible to install the upgrade and re-boot the PC if it needs to be without having to touch the windows 10 PC at all. Does anyone know if this is achievable?

Alan Woods

unread,
Jul 7, 2020, 11:27:09 AM7/7/20
to Ansible Project
Can anyone help with this?

Alan Woods

unread,
Jul 7, 2020, 12:33:28 PM7/7/20
to Ansible Project
I have also tired these:


---
- hosts: win10-pro-1
  gather_facts: yes
  tasks:
    - name: Re-Boot PC before upgrade
      win_reboot:

    - name: Upgrade Windows 10
      win_updates:
        category_names:
          - Upgrades
        state: installed
        reboot: yes
       
and


---
- hosts: win10-pro-1
  gather_facts: yes
  tasks:
    - name: Upgrade Windows 10
      win_updates:
        category_names:
          - Upgrades
        reboot: yes

Alan Woods

unread,
Jul 7, 2020, 1:53:42 PM7/7/20
to Ansible Project
I have ran this playbook again with the -vvv this was the out put:

[vagrant@controller win_10_Updates]$ ansible-playbook testFeatureUPdate.yml -vvv
ansible
-playbook 2.9.10
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python
module location = /usr/lib/python3.6/site-packages/ansible
  executable location
= /usr/bin/ansible-playbook
  python version
= 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing
/etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing
/etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin

PLAYBOOK
: testFeatureUPdate.yml **********************************************************************************************
1 plays in testFeatureUPdate.yml

PLAY
[win10-pro-1] ***********************************************************************************************************

TASK
[Gathering Facts] *******************************************************************************************************
task path
: /home/vagrant/ansible/win_10_Updates/testFeatureUPdate.yml:2
Using module file /usr/lib/python3.6/site-packages/ansible/modules/windows/setup.ps1
Pipelining is enabled.
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
ok
: [win10-pro-1]
META
: ran handlers

TASK
[Re-Boot PC before upgrade] *********************************************************************************************
task path
: /home/vagrant/ansible/win_10_Updates/testFeatureUPdate.yml:5
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
win_reboot
: rebooting server...
EXEC
(via pipeline wrapper)
win_reboot
: validating reboot
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
win_reboot
: attempting post-reboot test command
EXEC
(via pipeline wrapper)
win_reboot
: system successfully rebooted
changed
: [win10-pro-1] => {
   
"changed": true,
   
"elapsed": 23,
   
"rebooted": true
}

TASK
[Upgrade Windows 10] ****************************************************************************************************
task path
: /home/vagrant/ansible/win_10_Updates/testFeatureUPdate.yml:8
win_updates
: running win_updates module
Using module file /usr/lib/python3.6/site-packages/ansible/modules/windows/win_updates.ps1
Pipelining is enabled.
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
ok
: [win10-pro-1] => {
   
"changed": false,
   
"failed_update_count": 0,
   
"filtered_updates": {},
   
"found_update_count": 1,
   
"installed_update_count": 1,
   
"reboot_required": true,
   
"updates": {
       
"ac2b20ab-6186-4267-8d55-4b3ca35197d1": {
           
"categories": [
               
"Upgrades"
           
],
           
"id": "ac2b20ab-6186-4267-8d55-4b3ca35197d1",
           
"installed": true,
           
"kb": [
               
"4560960"
           
],
           
"title": "Feature update to Windows 10, version 1909"

       
}
   
}
}

TASK
[reboot host if required] ***********************************************************************************************

task path
: /home/vagrant/ansible/win_10_Updates/testFeatureUPdate.yml:15
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
win_reboot
: rebooting server...
EXEC
(via pipeline wrapper)
win_reboot
: validating reboot
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
win_reboot
: attempting to get system boot time
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
EXEC
(via pipeline wrapper)
<win10-pro-1> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO win10-pro-1
win_reboot
: attempting post-reboot test command
EXEC
(via pipeline wrapper)
win_reboot
: system successfully rebooted
changed
: [win10-pro-1] => {
   
"changed": true,
   
"elapsed": 25,
   
"rebooted": true
}
META
: ran handlers
META
: ran handlers

PLAY RECAP
*******************************************************************************************************************
win10
-pro-1                : ok=4    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

But when I go into the windows box and look at updates this is what I get:

Pending install.png

Restart now.png

I used Ansible to restart the PC but is does not install it. This is what I used to restart it. If I actually press the restart now button or go into the start menu and choose update and restart it installs.

---
- hosts: win10-pro-1
 gather_facts: no
 tasks:
   - name: Re-Boot windows PC
     win_reboot:


Alan Woods

unread,
Jul 7, 2020, 1:56:54 PM7/7/20
to Ansible Project
Sorry here is the rest of the output from the play with -vvv it got cut off for some reason:

EXEC
(via pipeline wrapper)<span style="color:

CORLEONE##

unread,
Jul 8, 2020, 2:36:34 AM7/8/20
to ansible...@googlegroups.com
Hi Alan,

Can you please check if the ansible account you are using for winrm has all root permissions i.e Administrator 

This is weird. I have achieved the same result back 6 months and it went smooth for me.

Regards, 
Manash

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d248e549-cfae-45e8-8e66-91a6982a2afbo%40googlegroups.com.

Alan Woods

unread,
Jul 8, 2020, 11:07:20 AM7/8/20
to Ansible Project

Hi Corleone, the account that I am using is in the Administrators group on the windows 10 boxes. Right now, I am using a Dev environment using Vagrant. I have 4 windows 10 boxes that are all from Vagrant Cloud and a centos box for the ansible controller that is also from Vagrant Cloud. So, by default the Vagrant user is always an admin on the boxes.

 

I did also try to install Google Chrome with Ansible on these boxes with this playbook and it does work just to test it. Google Chrome does get installed:


---
- name: Install Google Chrome
  hosts
: win10-pro-1
  gather_facts
: no
  tasks
:
   
- win_chocolatey:
        name
:
         
- googlechrome
        state
: present


 

This is what I have in my hosts file for Ansible. Right now, I am just using the winPro group at the moment but Ansible can talk to all these machines with the win_ping:


[all]
win
-10-1
win
-10-2
win10
-pro-1
win10
-pro-2
server
-1
server
-2

[all:vars]
ansible_user
=vagrant
ansible_password
=vagrant
ansible_connection
=winrm
ansible_winrm_server_cert_validation
=ignore


[win]
win
-10-1
win
-10-2

[win:vars]
ansible_user
=vagrant
ansible_password
=vagrant
ansible_connection
=winrm
ansible_winrm_server_cert_validation
=ignore

[winPro]
win10
-pro-1
win10
-pro-2

[winPro:vars]
ansible_user
=vagrant
ansible_password
=vagrant
ansible_connection
=winrm
ansible_winrm_server_cert_validation
=ignore


[server]
server
-1
server
-2

[server:vars]
ansible_user
=vagrant
ansible_password
=vagrant
ansible_connection
=winrm
ansible_winrm_server_cert_validation
=ignore

The only thing I have in my ansible.cfg file is:


[defaults]

host_key_checking
= false
timeout
= 30


 

the hosts file and the ansble.cfg file are both in the default location of /etc/ansible.Thanks for any help on this I really appreciate it.



On Tuesday, July 7, 2020 at 11:36:34 PM UTC-7, CORLEONE## wrote:
Hi Alan,

Can you please check if the ansible account you are using for winrm has all root permissions i.e Administrator 

This is weird. I have achieved the same result back 6 months and it went smooth for me.

Regards, 
Manash

To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Message has been deleted

Alan Woods

unread,
Jul 8, 2020, 4:24:17 PM7/8/20
to Ansible Project
Would you mind sharing you playbook for the upgrade install?

CORLEONE##

unread,
Jul 17, 2020, 5:26:28 AM7/17/20
to ansible...@googlegroups.com
Have you used the win feature module before?

Regards, 
Manash

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/53dda0f0-7b83-44c6-b253-2562b7758e10o%40googlegroups.com.
Message has been deleted

Alan Woods

unread,
Jul 17, 2020, 10:23:04 AM7/17/20
to Ansible Project
I have. I  have used it for installing IIS and a few other features.
Reply all
Reply to author
Forward
0 new messages