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.
- Install bolt
- Clone this repo
- Run
bolt module install - Rename
bolt.example.yamltobolt.yamland modify accordingly (docs) - For ssh or winrm transports: rename
inventory.example.yamltoinventory.yamland modify accordingly (docs) - For pcp transport: rename
inventory.pcp.yamltoinventory.yamland modify accordingly (docs)
-
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 -
Run a command on all nodes in inventory
bolt command run hostname -t all
-
Run a script on all nodes in inventory
bolt script run scripts/hello.sh -t all
-
Show all available tasks
bolt task show
-
Show documentation for a task
bolt task show bolt_primer::hello
-
Check the status of the
httpdservice on all nodesbolt task run service -t all action=status name=httpd
-
Run a task on the linux nodes
bolt task run bolt_primer::hello -t linux message="Hello, World" -
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.
-
Show all available plans
bolt plan show
-
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 -
Convert a yaml plan into a Puppet-language plan
bolt plan convert plans/second.yaml > plans/third.pp -
Install and start httpd on all linux nodes
bolt plan run bolt_primer::httpd -t linux --verbose
-
Generate a CSV file of all the nodes
First, configure the
puppetdbbolt plugin as shown in thebolt.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