FROM mcr.microsoft.com/windows/servercore:ltsc2022 # Set up cygwin with git and ansible as a bootstrap, and add to system default path RUN powershell wget -UseBasicParsing https://cygwin.com/setup-x86_64.exe -OutFile setup-x86_64.exe & \ setup-x86_64.exe --packages git,ansible --download --local-install --delete-orphans --site https://mirrors.kernel.org/sourceware/cygwin --local-package-dir c:\cygwin_packages --root C:\cygwin64 --wait --quiet-mode & \ C:\cygwin64\bin\git config --system core.autocrlf false RUN setx PATH "c:\cygwin64\bin;%PATH%" # Set up WinRM for the ansible connection RUN powershell wget -UseBasicParsing https://raw.githubusercontent.com/ansible/ansible/dd4c56e4d68664e4a50292aa19ea61b15c92287c/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1 & \ PowerShell .\ConfigureRemotingForAnsible.ps1 -CertValidityDays 9999 & \ PowerShell .\ConfigureRemotingForAnsible.ps1 -EnableCredSSP & \ PowerShell .\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert & \ PowerShell .\ConfigureRemotingForAnsible.ps1 -SkipNetworkProfileCheck # Specify this with --build-arg PW=SomePassword ARG PW # Clone infrastructure repository RUN C:\cygwin64\bin\git clone https://github.com/sxa/infrastructure -b windows_docker_fixes c:/infrastructure RUN sed -i -e 's/hosts: .*/hosts: localhost/' infrastructure/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/main.yml # Set up user for WinRM RUN net user ansible %PW% /ADD & net localgroup "Administrators" ansible /ADD & net localgroup "Remote Management Users" ansible /ADD RUN echo localhost ansible_connection=winrm > infrastructure/ansible/hosts RUN fsutil 8dot3name set 0 ENV TERM dumb # Wix install fails due to missing ansible.builtin.runas RUN mkdir c:\temp RUN cd infrastructure\ansible & C:\cygwin64\bin\python3.7m.exe /usr/bin/ansible-playbook -vvvv -e ansible_user=ansible -e ansible_password=%PW% -e git_sha=123456 -i hosts --skip-tags=adoptopenjdk,reboot,NTP_TIME,Wix,MSVS_2013,MSVS_2017,MSVS_2019,MSVS_2022 playbooks/AdoptOpenJDK_Windows_Playbook/main.yml # Note: adoptopenjdk skipped here as that permits the playbooks to download instead of using layout RUN cd infrastructure\ansible & C:\cygwin64\bin\python3.7m.exe /usr/bin/ansible-playbook -i hosts -e git_sha=123456 -e ansible_user=ansible -e ansible_password=%PW% -t MSVS_2019 --skip-tags=reboot,adoptopenjdk playbooks/AdoptOpenJDK_Windows_Playbook/main.yml RUN cd infrastructure\ansible & C:\cygwin64\bin\python3.7m.exe /usr/bin/ansible-playbook -i hosts -e git_sha=123456 -e ansible_user=ansible -e ansible_password=%PW% -t MSVS_2022 --skip-tags=reboot,adoptopenjdk playbooks/AdoptOpenJDK_Windows_Playbook/main.yml # Clear up ansible user credentials so they cannot be used RUN net user ansible /DELETE