# Ansible with windows server 2008 r2 sp1 - sysprep

**URL:** <https://forum.ansible.com/t/ansible-with-windows-server-2008-r2-sp1-sysprep/24913>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 6, 2017, 2:31pm UTC](https://forum.ansible.com/t/ansible-with-windows-server-2008-r2-sp1-sysprep/24913 "2017-07-06T14:31:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fernando\_Henrique\_Bo](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@Fernando\_Henrique\_Bo](https://forum.ansible.com/u/Fernando_Henrique_Bo)\
**Post date:** [July 6, 2017, 2:31pm UTC](https://forum.ansible.com/t/ansible-with-windows-server-2008-r2-sp1-sysprep/24913/1 "2017-07-06T14:31:57Z")

</div>

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: \*\*\*\*\*\*\*\*\*

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 7, 2017, 10:08am UTC](https://forum.ansible.com/t/ansible-with-windows-server-2008-r2-sp1-sysprep/24913/2 "2017-07-07T10:08:42Z")

</div>

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

[https://docs.ansible.com/ansible/vmware\_guest\_module.html](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](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
