PAGE
Introduction
The Windows Server 2022 (sshd & chocolatey)
template (in the Featured
tab) provides a Windows Server Core 2022
Datacenter Edition installation with a native OpenSSH server and Chocolatey.
You may connect a fresh instance of this template via SSH.
SSH connections use the Powershell as default shell. You may change the default shell for
cmd.exe
, or the Cygwin bash
, or the bash
provided by the
Windows subsystem for Linux.
Chocolatey is a package manager for Windows. You may use it to install the development tools that you need.
and many other packages.
git and GitLab-runner are pre-installed, but GitLab-runner is not configured. To do so, please refer to this installation example on a Windows slave from ci.inria.fr
Virtualization is enabled, which means Docker can be installed, but you have to know this
application requires much more resources than the Linux version (python:3.13.4-windowsservercore-ltsc2022
is for instance 2.17 Go, against python:3.13.4-alpine
that is only 16 Mo).
This is the reason why it is advised to have about 100 Go of Hard Drive (cf. resize disk section) when
building Windows Docker images is required.
Docker-in-Docker is not available with the Docker Community Edition, this means that if you need to build docker images and use them in your CI pipeline, you will need 2 Virtual Machines:
- The first one is configured as a
shell
gitlab-runner with docker installed to build your docker image from the Dockerfile in the GitLab repository - A second Virtual Machine configured as a
docker-windows
gitlab-runner that will be able to use the docker image built by the previous step, and build the code from the sources in the GitLab repository
Connect a slave via SSH
Add these lines to your ~/.ssh/config
file (by substituting
‹login›
with your actual login on ci.inria.fr
).
Host *.ci
ProxyCommand ssh -W $(basename %h .ci):%p ‹login›@ci-ssh.inria.fr
The following command connect the instance.
ssh ci@‹project›-‹slave›.ci
Change the default shell
The initial default shell when opening an SSH connection is C:\Program Files\PowerShell\7\pwsh.exe
. This default can
be changed by setting the string value DefaultShell
in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH
.
For example, the following Powershell command line sets cmd.exe
as the default shell.
For more details about configuring OpenSSH, see
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\system32\cmd.exe" -PropertyType String -Force
Install Java runtime
The following command installs Java runtime. More details about javaruntime
package:
https://chocolatey.org/packages/javaruntime
choco install -y javaruntime
Install Microsoft Visual Studio
The following command installs a minimal setup for Visual Studio 2017 Community.
More details about VisualStudio2017Community
package: https://chocolatey.org/packages/VisualStudio2017Community
choco install -y visualstudio2017community --execution-timeout=0
The following command installs Visual C/C++ compiler. Visual Studio 2017 Community (or another base package) should
have already been installed before running this command. More details about visualstudio2017-workload-nativedesktop
package: https://chocolatey.org/packages/visualstudio2017-workload-nativedesktop
choco install -y visualstudio2017-workload-nativedesktop
The following command adds x64 native tools (e.g., the cl.exe
compiler) to the PATH
variable of the current shell
environment.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
Install Cygwin
The following command installs a minimal setup for Cygwin. More details about Cygwin
package:
https://chocolatey.org/packages/Cygwin
choco install -y cygwin
Once Cygwin is installed, Cygwin packages can be installed via choco
command line with option --source cygwin
.
For instance, to install GNU Make:
choco install --source cygwin make
The following command runs the Cygwin environment, which by default provides a bash
command line.
C:\tools\cygwin\Cygwin.bat
The following Powershell command makes Cygwin the default shell for SSH connections.
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\tools\cygwin\Cygwin.bat" -PropertyType String -Force
Install CMake
The following command installs CMake and add CMake
to PATH
for all users. More details about cmake
package:
https://chocolatey.org/packages/cmake
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
You should run the Powershell command Reload-Service sshd
to get the new environment for subsequent SSH connections.
Install docker
The following command installs Docker Community Edition. More details about Windows Docker Community Edition
package:
https://github.com/microsoft/Windows-Containers
Install-Module DockerMsftProvider -Force
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -OutFile install-docker-ce.ps1
./install-docker-ce.ps1
Then the Virtual Machine will restart. After the restart, relaunch the script:
./install-docker-ce.ps1
One can test the installation is successful with:
docker ps
Install Windows subsystem for Linux
The Windows subsystem for Linux is an optional feature, you may enable it by installing the package wsl
.
https://chocolatey.org/packages/wsl
choco install -y wsl
You will probably have to restart Windows before being able to use the subsystem. If subsequent installations of some distributions fail, you may try to restart before trying again.
Alternatively, you may enable the feature in Powershell as administrator.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
You may then install the distribution of your choice. Some examples:
choco install -y wsl-ubuntu-1604
choco install -y wsl-debiangnulinux
These packages have wsl
package as dependency: the feature Windows subsystem for Linux will therefore be enabled
if required when you request to install these packages.
However, choco
appears not to restart Windows before trying to install the distributions, leading their installation
to fail if you don’t restart Windows yourself before.
The command ubuntu
launches Ubuntu default shell (presumably, bash).
The Debian package does not appear to insert debian
command in PATH
; the command can be found in
C:\ProgramData\chocolatey\lib\wsl-debiangnulinux\tools\unzipped\debian.exe
.
The following Powershell command makes Ubuntu default shell the default shell for SSH connections.
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\ProgramData\chocolatey\bin\ubuntu.exe" -PropertyType String -Force
Resize disk
The original template size is 40 Go. If you create a Virtual Machine from this template with an hard drive bigger than 40 Go, or if the volume has been resized in CloudStack (in the volume panel, click on the last button of the toolbar,
the one with the tooltip Resize Volume
, in the form, you can ignore the first line New Offering
and supply the
second line with a size in Go New Size (GB)
), you can extend the volume in a command line with:
> diskpart
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 40 GB 1024 KB
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 100 MB 1024 KB
Partition 2 Primary 39 GB 101 MB
DISKPART> select partition 2
Partition 2 is now the selected partition.
DISKPART> extend
DiskPart successfully extended the volume.
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D CD-ROM 0 B No Media
Volume 1 System Rese NTFS Partition 100 MB Healthy System
* Volume 2 C NTFS Partition 99 GB Healthy Boot
DISKPART> exit