{"id":15241,"date":"2026-02-19T22:30:32","date_gmt":"2026-02-20T06:30:32","guid":{"rendered":"https:\/\/www.apolonio.com\/blog\/?p=15241"},"modified":"2026-02-19T22:30:32","modified_gmt":"2026-02-20T06:30:32","slug":"sysprep-done-using-ansible","status":"publish","type":"post","link":"https:\/\/www.apolonio.com\/blog\/?p=15241","title":{"rendered":"Sysprep Done Using Ansible"},"content":{"rendered":"\n<p>I got sysprep working at a minimal level the way I want.  I now have a base windows 11 image I can use to rebuild a box relatively quickly.<\/p>\n\n\n\n<p>After a reboot I rename it and add it to the domain.<\/p>\n\n\n\n<p>From there ansible takes over.  I am able to use a rocky 9.7 box to manage Windows Desktops via the domain through winrm<\/p>\n\n\n\n<p>Here is how I got winrm working (not I just used a self signed cert)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Enable-PSRemoting -Force<br>$CertDnsName = \"win11.example.com\"<br>$Cert = New-SelfSignedCertificate `<br>    -DnsName $CertDnsName `<br>\t-Provider \"Microsoft RSA SChannel Cryptographic Provider\" `<br>\t-KeyLength 2048 -NotAfter (Get-Date).AddYears(5) `<br>    -CertStoreLocation Cert:\\LocalMachine\\My<br>$CertThumbprint = $Cert.Thumbprint<br><br># Create Listener<br>New-Item -Path WSMan:\\LocalHost\\Listener -Transport HTTPS -Address * -HostName $CertDnsName -CertificateThumbPrint $CertThumbprint -Force<br><br># Open Firewall<br>New-NetFirewallRule -DisplayName \"Windows Remote Management (HTTPS-In)\" -Direction Inbound -LocalPort 5986 -Protocol TCP -Action Allow<br><br># Verify<br>winrm enumerate winrm\/config\/listener<\/pre>\n\n\n\n<p>On the Linux side I had to make sure I had the correct ansible packages<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo dnf -y install ansible-core epel-release<br>sudo dnf -y install krb5-workstation krb5-devel python3-devel gcc python3-passlib apg <br>sudo dnf install -y python3-kerberos krb5-workstation<br><br>python3 -m pip install pywinrm requests<br>ansible-galaxy collection install community.general<br>ansible-galaxy collection install community.mysql<br>ansible-galaxy collection install ansible.posix<br>ansible-galaxy collection install ansible.windows:2.3.0<\/pre>\n\n\n\n<p>This got me working but my ansible.cfg needed to look like this<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[defaults]<br>inventory = .\/inventory<br>host_key_checking = False<br>retry_files_enabled = False<br>stdout_callback = default<br>timeout = 30<br>ansible_connection=winrm<br><br># Optional but useful<br>interpreter_python = auto_silent<br><br>[connection]<br>pipelining = True<br><br>[winrm]<br># Kerberos settings<br>transport = kerberos<br>scheme = https<br>port = 5986<br>server_cert_validation = ignore<br>kerberos_delegation = true<br><\/pre>\n\n\n\n<p>And finally some variables needed to be set in the inventory file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">##### Sample inventory<br>[windows]<br>win11a.example.com<br>win11b.example.com<br>win11c.example.com<br><br>[windows:vars]<br>ansible_connection=winrm<br>ansible_port=5986<br>ansible_winrm_transport=kerberos<br>ansible_winrm_scheme=https<br>ansible_winrm_server_cert_validation=ignore<br><br>kilist<br>kdestroy<br>kinit Admin@EXAMPLE.COM<\/pre>\n\n\n\n<p>In other news, got a new Sony earbuds, RIP my old set.<\/p>\n\n\n\n<p>Still need to get bathroom done<\/p>\n\n\n\n<p>Got a new UPS to install this weekend.<\/p>\n\n\n\n<p>Weight: 321.6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I got sysprep working at a minimal level the way I want. I now have a base windows 11 image I can use to rebuild a box relatively quickly. After a reboot I rename it and add it to the &hellip; <a href=\"https:\/\/www.apolonio.com\/blog\/?p=15241\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,14,11,3,9],"tags":[],"class_list":["post-15241","post","type-post","status-publish","format-standard","hentry","category-coding","category-new-toys","category-technical","category-training","category-weighin"],"_links":{"self":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/15241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15241"}],"version-history":[{"count":1,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/15241\/revisions"}],"predecessor-version":[{"id":15242,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/15241\/revisions\/15242"}],"wp:attachment":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}