All pages
Powered by GitBook
1 of 1

Loading...

Bolt Examples

Demonstrates how to use Bolt, an orchestration tool in the Puppet ecosystem, to run ad-hoc commands, scripts, and tasks on remote MariaDB servers without a permanent agent.

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.

For information about installing Bolt, see Installing Bolt in Bolt documentation.

Inventory Files

The simplest way to call Bolt and instruct it to do something on some remote targets is the following:

However, for non-trivial setups it is usually better to use an inventory file. An example:

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:

With an inventory of this type, it will be possible to run Bolt actions against all the targets that are members of a group:

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:

Copying Files

To copy a file or a whole directory to targets:

To copy a file or a whole directory from the targets to the local host:

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 once.

Running Tasks on Targets

Puppet tasks are not always as powerful as custom scripts, but they are simpler and many of them are idempotent. The following task stops MariaDB replication:

Applying Puppet Code on Targets

It is also possible to apply whole manifests or portions of Puppet code (resources) on the targets.

To apply a manifest:

To apply a resource description:

Bolt Resources and References

  • .

  • .

Further information about the concepts explained in this page can be found in Bolt documentation:

  • in Bolt documentation.

  • in Bolt documentation.

Content initially contributed by .

This page is licensed: CC BY-SA / Gnu FDL

bolt ... --nodes 100.100.100.100,200.200.200.200,300,300,300,300
targets:
  - uri: maria-1.example.com
    name: maria_1
    alias: mariadb_main
  ...
Bolt documentation
Bolt on GitHub
Inventory Files
Applying Puppet code
Vettabase Ltd
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:
      ...
...
bolt ... --nodes mariadb-staging
bolt command run 'mariadb-admin start-all-slaves' --targets <targets>
bolt file upload /path/to/source /path/to/destination --targets <targets>
bolt file download /path/to/source /path/to/destination --targets <targets>
bolt script run rotate_logs.sh --targets <targets>
bolt task run mysql::sql --targets <targets> sql="STOP REPLICA"
bolt apply manifests/server.pp  --targets <targets>
bolt apply --execute "file { '/etc/mysql/my.cnf': ensure => present }" --targets <targets>