Remote Management Using Puppet Bolt and Windows Subsystem for Linux
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.
Install Windows Subsystem for Linux
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.
- In the search box on the taskbar, type control panel and select Control Panel from the list of results.
- In the Control Panel, click Programs.
- Now click Turn Windows features on or off. Give consent or provide an administrator password if prompted.
- In the Windows Feature dialog, select Windows Subsystem for Linux and then click OK.
- Reboot the device when prompted to complete the installation process.
- Once rebooted, open the Microsoft Store.
- Click Search in the top right corner of the Store and type Ubuntu.
- Under Apps, click Ubuntu.
- Now click Get to install Ubuntu on your system.
- Once the install has completed, click Launch.
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.
- Enter a new username as prompted and confirm the password twice. The new user is an administrator and will be automatically logged on each time you start Linux. It is also added to the sudo
Install Puppet Bolt in Ubuntu
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.
Run a Command on a Remote Server
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.
More in Windows 10
Windows 11 to Add New Multi-App Kiosk Mode for IT Admins
Jul 29, 2022 | Rabia Noureen
Microsoft Retires Windows Information Protection in Favor of New Purview Service
Jul 22, 2022 | Rabia Noureen
How to Use the Icacls Command to Manage File Permissions
Jul 20, 2022 | Michael Reinders
July Patch Tuesday Updates Fix 84 Vulnerabilities and LDAP Gets TLS 1.3
Jul 13, 2022 | Laurent Giret
Microsoft's New Windows Autopatch Service is Now Generally Available
Jul 12, 2022 | Rabia Noureen
What’s New with Windows – June 2022
Jul 5, 2022 | Russell Smith
Most popular on petri