Thanks to visit codestin.com
Credit goes to github.com

Skip to content

timidri/bolt_primer

Repository files navigation

Getting started with bolt tasks and plans - example repo

What is this?

This repo contains some simple bolt configuration and task and plan examples to help you get up and running quickly. Originally presented at PEX Germany 2019 and published by popular demand :-)

Updated on 2024-04-18:

  • fix outdated syntax
  • update docs
  • include a task written in Go.

How to use

Install and configure

  1. Install bolt
  2. Clone this repo
  3. Run bolt module install
  4. Rename bolt.example.yaml to bolt.yaml and modify accordingly (docs)
  5. For ssh or winrm transports: rename inventory.example.yaml to inventory.yaml and modify accordingly (docs)
  6. For pcp transport: rename inventory.pcp.yaml to inventory.yaml and modify accordingly (docs)

Usage

Commands

  1. Run a command on a node not in inventory (ssh transport is the default and ssh access must be configured)

    bolt command run hostname -t mynode.example.com
  2. Run a command on all nodes in inventory

    bolt command run hostname -t all

Scripts

  1. Run a script on all nodes in inventory

    bolt script run scripts/hello.sh -t all

Tasks

  1. Show all available tasks

    bolt task show
  2. Show documentation for a task

    bolt task show bolt_primer::hello
  3. Check the status of the httpd service on all nodes

    bolt task run service -t all action=status name=httpd
  4. Run a task on the linux nodes

    bolt task run bolt_primer::hello -t linux message="Hello, World"
  5. Run a multi-OS task on all nodes

    bolt task run bolt_primer::goodbye -t all message="Goodbye, World"
    bolt task run bolt_primer::hello_go -t all message="Golang task"

    Note: see tasks/hello_go.go for instructions how to compile the go task.

Plans

  1. Show all available plans

    bolt plan show
  2. Run a yaml plan

    bolt plan run bolt_primer::first -t all
    bolt plan run bolt_primer::second hello_hosts=linux goodbye_hosts=windows message="Hello, World" --verbose
  3. Convert a yaml plan into a Puppet-language plan

    bolt plan convert plans/second.yaml > plans/third.pp
  4. Install and start httpd on all linux nodes

    bolt plan run bolt_primer::httpd -t linux --verbose
  5. Generate a CSV file of all the nodes

    First, configure the puppetdb bolt plugin as shown in the bolt.example.yaml. You will need the cacert and the token of the PuppetDB server (in PE usually the same as the puppetmaster). Note that you need to address the puppetdb server by its certname to make SSL work, so if the certname is not resolvable, you will need to add it /etc/hosts.

    bolt plan run bolt_primer::pdb_query query="nodes[]{}" format=csv

About

A "crash guide" to get up and running with bolt quickly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published