Petri Newsletter Sign-up
Tech Tuesday

Subscribe to Tech Tuesday, the latest insights from Petri.com for IT Pros.

    See All Petri Newsletters

    Use Puppet Bolt Tasks to Manage Windows Server

    Posted on by Russell Smith in Windows Server

    If you missed my piece last month on running commands on Windows Server using Puppet Bolt, you will need to read that and install Puppet Bolt on Windows or Linux before following the instructions below. Puppet Bolt is a free, open source, agentless, cross-platform tool that aims to make it easier to get started with automation. Because Bolt is agentless, you can use it to orchestrate operations without installing agents or using a Puppet Master server; and it can be used in mixed Linux and Windows Server environments.

    In today’s article, I’m going to show you how to run Tasks on a remote Windows server. Tasks are scripts used to perform single, ad-hoc actions. Tasks can be grouped into Plans that use other logic to carry out more complex tasks. But that is for another day. I’m running Bolt in Ubuntu Linux, but the same commands should work if you have installed Bolt in Windows. Additionally, you should be able to use the same Tasks against a remote Linux server.

    Run Built-In Puppet Bolt Tasks

    You can easily create your own tasks but before looking at that, you should familiarize yourself with running the tasks that are available with Bolt out-of-the-box. To list the available tasks, run the command below:


    Optionally, you can specify a modules path. While tasks are essentially scripts, they are stored in modules and can have metadata so that they can reused and stored easily. Tasks can be single-platform or cross-platform. The metadata can be used to explain when to use which implementation if a task is cross-platform.


    You’ll see several tasks listed, like reboot and service. Some task names consist of two parts, like puppet_agent::install. The first part of the task name indicates the module, and the second part, the name of the task file without its file extension.

    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)
    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)

    To find more information about a specific task, add the task after ‘show’. For instance, to find out how to use the service task, run the command below:

    Install the Puppet Agent

    Before we run a task remotely, let’s try running a task locally. The command below shows the version of the Puppet agent installed on the local device. In this case I don’t have the Puppet agent installed locally but the command should still provide some output to reflect that.


    Now let’s run the same command on a remote Windows device. You can see below that I need to specify the protocol for communication, in this case WinRM, the node IP address or DNS name, and the user account I will use for authentication on the remote device. When you run the command below, you will be prompted to enter the password for the account specified in the -u parameter.

    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)
    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)


    The Puppet agent isn’t installed on the remote Windows server, so again the output should reflect that. I can install the agent by changing version for install in the task name.


    The task will take some time complete and the remote Windows device must have Internet access to download the agent binaries. You can then use the puppet_agent::version task again to check the agent installed and which version.

    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)
    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)

    There’s no requirement to reboot the node after the agent is installed but this is how you would do it using Puppet Bolt:

    Manage Services

    Finally, let’s use the service task to get the status of a service and then restart it. The command below returns the status of the Application Management service. Note the action and name data being passed to the task.

    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)
    Use Puppet Bolt Tasks to Manage Windows Server (Image Credit: Russell Smith)


    If I want to restart the service, all I must do is change action=status to action=restart:


    That is it for today! In an upcoming article, I’ll show you how to create your own Puppet Bolt Tasks using PowerShell scripts.

    BECOME A PETRI MEMBER:

    Don't have a login but want to join the conversation? Sign up for a Petri Account

    Register

    Register for this Petri Webinar!

    Want to Make Your Backup Storage Unlimited & Ready for the Cloud? – Free Thurrott Premium Account with Webinar Registration!

    Tuesday, August 27, 2019 @ 1:00 pm EDT

    A Scale-Out Backup storage infrastructure is a must-have technology for your backups. In this webinar, join expert Rick Vanover for a look on what real-world problems are solved by the Scale-Out Backup Repository.

    Register Now

    Sponsored By