Ansible with windows server 2008 r2 sp1 - sysprep

Hi.

I deployed one VM (Vcenter Server/ESXi 5.5.0) from windows server 2008 r2 template using ansible playbook.
Now I 'd like to initialize it, but the vm is configured with sysprep, When the ansible start the vm, it stop in the windows startup.

hosts: localhost
connection: local
gather_facts: False
tasks:

  • name: Create a VM from Template
    vmware_guest:
    validate_certs: false
    hostname: vcenterserver.lab.intranet
    username: user@lab.intranet
    password: *******
    datacenter: DC
    folder: /POC/Ansible
    esxi_hostname: esxi@lab.intranet
    name: win1
    state: poweredon
    template: TPL_W2008_STD_R2_SP1
    disk:
    type: thin
    datastore: “LUN_POC_DS8870_1TB_01”
    networks:
  • name: Lab
    ip: 192.168.12.15
    netmask: 255.255.255.0
    customization:
    autologon: True
    dns_servers:
  • 192.168.12.10
    joindomain: lab.intranet
    domainadmin: useradmin@lab.intranet
    domainadminpassword: *********

Maybe you need to use runonce to run the powershell script to enable remoting:

https://docs.ansible.com/ansible/vmware_guest_module.html

Be aware that unpatched Windows Server 2008 R2 has a bug in WMF 3.0 which stops winrm from being able to do anything useful. You need to install http://support.microsoft.com/kb/2842230 or get it up to date with windows updates before even running the setup module to gather facts against it.

Hope this helps,

Jon