Last Update: Sep 04, 2024 | Published: Mar 25, 2019
Last month, in How To Run Commands on Remote Windows Servers Using Puppet Bolt on Petri, I showed you how to install Puppet Bolt on Windows 10 and use it to run commands remotely in Windows Server 2019. Puppet Bolt is a free, open source, agentless, cross-platform remote task runner that aims to make it easier to get started with automation. Bolt supports any language the remote nodes run natively, and it can execute any existing management scripts that you have.
Puppet Bolt can be installed in Windows or Linux. But as I start to learn more about Bolt, I wondered whether it might be beneficial to run it in Linux instead of Windows. Principally because the documentation is written with Linux users in mind first and foremost. And secondly, it would give me the chance to test whether the Windows Subsystem for Linux (WSL) in Windows 10 could really replace a Linux virtual machine (VM). In this article, that’s what I’ll set out to show.
WSL lets you run a lightweight Linux environment on Windows without the overhead of a VM. And while it’s possible to run Linux GUI programs using an X Server, WSL isn’t intended for average users who want to spin up their favorite GUI Linux apps. WSL is for developers and sysadmins that need Linux interoperability in Windows. WSL provides a layer for mapping Windows kernel system calls to Linux kernel system calls, allowing Linux binaries to run in Windows unmodified. WSL also maps Windows services, like the filesystem and networking, as devices that Linux can access.
For more information on WSL, see How Does the Windows 10 Subsystem for Linux Work and What Is It For? on Petri.
Before you can install a Linux distribution from the Microsoft Store in Windows 10, you’ll need to install the Windows Subsystem for Linux. In this example, I’ll use Ubuntu.
A console window will appear. It will take another few minutes to complete the install. When Ubuntu is ready to use, you’ll need to create a user account.
The next step is to install Puppet Bolt in Ubuntu. This involves running a few commands as shown below. Wget downloads the binaries, and then dpkg and apt-get are used to unpack and install the package. Sudo will prompt you to enter your password.
wget https://apt.puppet.com/puppet6-release-bionic.deb sudo dpkg -i puppet6-release-bionic.deb sudo apt-get update sudo apt-get install puppet-bolt
Once installed, run Bolt as shown below to confirm the version installed.
bolt –version
Now we can try and run a command on a remote server. Like in the original article, I have Windows Server 2019 in a VM. It is on the same device where Ubuntu is running. Let’s find out which version of PowerShell is installed on the remote server using $psversiontable.
bolt command run '$psversiontable' --nodes winrm://server1.mshome.net -u administrator --no-ssl –password
I get an error message saying that the remote device can’t be contacted. Ubuntu can’t resolve the server name (server1.mshome.net) because it doesn’t have any connection to DNS on the Windows 10 host device. The quickest solution is to replace the server’s domain name with its IP address. And viola, it works.
bolt command run '$psversiontable' --nodes winrm://172.17.165.71 -u administrator --no-ssl –password
I’ll be back with more articles on managing Windows Server with Puppet Bolt in the coming weeks.