Puppet Bolt orchestration tool

Lightning Strike

Creating a Bolt Directory

Your tasks in Bolt start with creating a Bolt project and setting up the targets. A Bolt project is a directory that includes the project-specific configuration settings. The first step is to create the project directory and convert it into a Bolt project:

mkdir first_bolt_project
bolt project init first_bolt_project

Bolt requires a specific directory structure for the projects – plans and tasks will not work without this structure. In this context, the directory structure of a Bolt project is closely linked to Puppet modules. For example, if you plan to install Apache on a remote system, you need to create an Apache module directory.

To stay with this example, you need to generate a module directory along with an Apache subdirectory by changing to the project directory and creating two directories, one for the project files and one for the plans:

cd first_bolt_project
mkdir -p module/apache/plans
mkdir -p module/apache/files

The directory structure for the first_bolt_project folder looks like this:

|-- bolt-project.yaml
|___module
    |__apache
       |- files
          |_plans

Defining Targets

The next step is to define the targets. In this section, I assume that you want to run an Apache web server on a Docker installation and perform typical tasks there. The connection between the Bolt installation and the remote systems is set up with either SSH or WinRM. As a rule, SSH will be the better choice. To talk to a Docker installation, generate a file named Dockerfile in the root directory of the Bolt projects and assign it the following commands:

from rastasheep/ubuntu-sshd
run apt-get update && apt-get -y install libssl-dev
expose 80
cmd ["/usr/sbin/sshd", "-d"]

The Dockerfile defines an Ubuntu container, including the SSH service, which lets you talk to the entities involved. The next step is to create the docker-compose.yaml file, which generates two container instances. To do this, create the file in your project directory and assign the settings shown in Listing 1.

Listing 1

docker-compose.yaml

version: '3'
services:
    target1:
        build: .
        ports:
            - '3000:80'
            - '2000:22'
        container_name: target1
    target2:
        build: .
        ports:
            - '3001:80'
            - '2001:22'
        container_name: target2

Now with the Compose file and the help of the Dockerfile, create two containers named target1 and target2. The SSH connections point to ports 2000 and 2001, respectively, and the HTTP connections to ports 3000 and 3001. To create and run the Docker containers and make sure the two containers are running, use the commands:

docker-compose up -d --build
docker-compose ps

Screen output should appear telling you that the Docker containers are ready to use, which means you can now run commands against the containers.

Commands Against Targets

Before you start executing extensive plans, you will want to run various commands against the target – not least to familiarize yourself with Bolt specifics. The general syntax for command execution is:

bolt command run <command> --targets <target name> <options>

To execute the whoami command on target 1, for example, you would type:

bolt command run whoami -t 127.0.0.1:2000 -u root -p root --no-host-key-check

This command targets a system with IP address 127.0.0.1 and port 2000, through which SSH is addressable. The command also passes in a username and password to enable access to the system. The --no-host-key-check option disables certificate authentication. Typical output for the command would be:

Started on 127.0.0.1:2000...
Finished on 127.0.0.1:2000:
    STDOUT:
        root
Successful on 1 target: 127.0.0.1:2000
Ran on 1 target in 0.3 sec

The output indicates that you have successfully run your first Bolt command on a target system. However, you will typically want to address a whole group and not just one system. To do this, Bolt uses an inventory file that lets you group an arbitrary number of systems.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=