windowsansibleautologinwinrm

Ansible auto login to windows 10 session


Ansible on mojave works A1. Winrm is enabled on the windows 10 home machine. I have setup a windows update play that reboots the machine. The problem is it reboots but then i have to login manually.

Maybe someone has an idea on how to automate that part ? is there a module that i could use ?

- name: Install windows updates
  win_updates:
    category_names:
        - SecurityUpdates
        - CriticalUpdates
        - UpdateRollups
    reboot: yes

Solution

  • look at : https://learn.microsoft.com/en-us/sysinternals/downloads/autologon

    Its a bit of a hack, but it does permit a user to autologon, in unattended mode.

    I usually simply copy the autologon exec to 'Program Files' (ansible module win_copy), and then run it with CLI params (using ansible-vault of course; the password is hashed in the win registry... not super secure, but for my use-case, it is sufficient):

    - name: Sync the contents of autologon directory
      win_robocopy:
        src: "E:\\install_packages\\Autologon"
        dest: "C:\\Program Files\\Autologon"
    
    - name: Configure autologon
      win_command: "C:\\Program Files\\Autologon.exe <username> <domain> <password>"