Learning Kit

Intro to Bolt

Setting up Target Nodes

Time: 30 minutes
Materials needed: none

Now that you’ve installed Bolt on a host node, you need to identify or create target nodes to manage.

The instructions in this section apply equally well to Linux, macOS, and Windows (with one exception, shown in the instructions below).

Note: If you’re using Windows, be sure to type these commands into PowerShell, and not the older Command shell.

Creating new, temporary target nodes

When learning Bolt, it’s simplest—and safest—to create a new, temporary set of target nodes that you can fearlessly experiment with, and then delete when you’re done with this course. The rest of this section describes how to do that, and the rest of this course assumes that you’ve set up your target nodes in this way.

You’ll use two free, open-source tools—VirtualBox and Vagrant—to create the target nodes. These tools create and manage virtual machines, so the target nodes will be virtual and not physical machines. It’s easiest to host these virtual machines on your host node. This means that Bolt, VirtualBox, and Vagrant will all run on the same physical machine.

Instructions

1). Download VirtualBox and follow the installation instructions. You only need to install the base package, and not any extension packs. 2). Download and install Vagrant on the same computer as VirtualBox. 3). Configure Vagrant to create three CentOS 7 nodes and a Windows (Nano Server) node to be your target nodes by copy/pasting this content into a file called Vagrantfile:

Vagrant.configure('2') do |config|
  config.vm.box = 'centos/7'
  config.ssh.forward_agent = true
  config.vm.network "private_network", type: "dhcp"
  config.vm.define "node1"
  config.vm.define "node2"
  config.vm.define "node3"
  config.vm.define :windows do |windows|
    windows.vm.box = "mwrock/WindowsNano"
    windows.vm.guest = :windows
    windows.vm.communicator = "winrm"
  end
end

4). Create and start the target nodes by running the following command from the command line, from the directory Vagrantfile is in: vagrant up

The first time you do this it will download the CentOS and Windows virtual machine images, which can take several minutes. Starting the virtual machines once they’ve been created takes another few minutes.

5). When Vagrant is done, validate that the four target nodes are up by running vagrant status. The output should look similar to this:

Current machine states:
node1                     running (virtualbox)
node2                     running (virtualbox)
node3                     running (virtualbox)
windows                   running (virtualbox)

6). To make sure Bolt can communicate with the three Linux target nodes using their node names instead of their IP addresses, you need to capture networking information from Vagrant and store it in a SSH configuration file. Run these commands on the command line, from the directory Vagrantfile is in.

Note that these commands are slightly different for Linux/macOS and for Windows.

Linux or macOS

1. mkdir -p ~/.ssh
2. vagrant ssh-config >> ~/.ssh/config

Windows

1. mkdir ~/.ssh -Force
2. vagrant ssh-config | Out-File ~/.ssh/config -Append -Encoding utf8

Once you’ve created this SSH configuration file, you can point Bolt at a target node by referring to its node name rather than its IP address.

7). Make sure you can SSH into the first Linux target node:

ssh node1

If you see something similar to this, the first Linux target node is up and running:

[vagrant@localhost ~]$

8). Type exit to disconnect from the first Linux target node. Repeat the same process to make sure node2 and node3> are running and reachable.

9). If your host node is running on Windows, you should make sure you can connect to the Windows target node by running this command:

vagrant powershell windows

If you see something similar to this, the Windows target node is up and running:

==> windows: Detecting if a remote PowerShell connection can be made with
the guest...
    windows: Creating powershell session to 127.0.0.1:55985
    windows: Username: vagrant

10). Type exit to disconnect from the Windows target node.

Note that the Linux and macOS versions of Vagrant don’t have the vagrant powershell command, so you'll just have to trust that the Windows node is reachable.

Pausing the temporary target nodes

If you need to temporarily shut down the target nodes for some reason, run this command from the directory Vagrantfile is in:

vagrant halt

If you see an error message, see the Troubleshooting vagrant halt section below.

Restart the target nodes by running this command from the directory Vagrantfile is in:

vagrant up

Destroying the temporary target nodes

When you’re through with the course and want to delete all the Vagrant files related to the target nodes, run these commands from the directory Vagrantfile is in:

vagrant halt

If you see an error message, see the Troubleshooting vagrant halt section below.

vagrant destroy

Answer y when prompted.

vagrant box remove centos/7 --all

Answer y when prompted.

vagrant box remove mwrock/WindowsNano --all

Answer y when prompted.

Troubleshooting vagrant halt

Due to a bug in the msrock/WindowsNano virtual machine image, running vagrant halt might fail and produce an error message starting with this text:

==> windows: Attempting graceful shutdown of VM...
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
<snip>

If that happens, you need to manually halt the Windows VM before re-running vagrant halt. Follow these steps:

1). Find the window on your desktop that shows the Windows VM’s login screen. It will look like similar to this:

2). Click anywhere in that Window so the Windows VM captures your keystrokes. 3). Type vagrant in the User name field. 4). Hit tab to advance. 5). Type vagrant in the Password field. 6). Hit enter to log in. 7). Hit ctrl-F12 to begin the shutdown. 8). Hit enter to complete the shutdown. 9). Wait for the Windows VM to close, which means the Windows VM has halted. 10). Re-run vagrant halt to shut down the Linux virtual machines.

Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.