Bolt Examples
This page shows some examples of what we can do with Bolt to administer a set of MariaDB servers. Bolt is a tool that is part of the Puppet ecosystem.
Contents
Invenvory Files
The simplest way to call Bolt and instruct it to do something on some remote targets is the following:
bolt ... --nodes 100.100.100.100,200.200.200.200,300,300,300,300
However, for non-trivial setups it is usually better to use an inventory file. An example:
targets: - uri: maria-1.example.com name: maria_1 alias: mariadb_main ...
In this way, it will be possible to refer the target by name or alias.
We can also define groups, followed by the group members. For example:
groups: - name: mariadb-staging targets: - uri: maria-1.example.com name: maria_1 - uri: maria-2.example.com name: maria_2 - name: mariadb-production targets: ... ...
With an inventory of this type, it will be possible to run Bolt actions against all the targets that are members of a group:
bolt ... --nodes mariadb-staging
In the examples in the rest of the page, the --targets
parameter will be indicated in this way, for simplicity: --targets <targets>
.
Running Commands on Targets
The simplest way to run a command remotely is the following:
bolt command run 'mariadb-admin start-all-slaves' --targets <targets>
Copying Files
To copy a file or a whole directory to targets:
bolt file upload /path/to/source /path/to/destination --targets <targets>
To copy a file or a whole directory from the targets to the local host:
bolt file download /path/to/source /path/to/destination --targets <targets>
Running Scripts on Targets
We can use Bolt to run a local script on remote targets. Bolt will temporarily copy the script to the targets, run it, and delete it from the targets. This is convenient for scripts that are meant to only run one time.
bolt script run rotate_logs.sh --targets <targets>
References
- Inventory Files in Bolt documentation.
Content initially contributed by Vettabase Ltd.