Change backup file globbing for network _config modules so backing up one host's config will not delete the backed up config of any host whose hostname is a subset of the first host's hostname (e.g., switch1 and switch11)
$ bolt help
Usage: bolt <subcommand> <action> [options]
Available subcommands:
bolt command run <command> Run a command remotely
bolt file upload <src> <dest> Upload a local file
bolt script run <script> Upload a local script and run it remotely
bolt task show Show list of available tasks
bolt task show <task> Show documentation for task
bolt task run <task> [params] Run a Puppet task
bolt plan show Show list of available plans
bolt plan show <plan> Show details for plan
bolt plan run <plan> [params] Run a Puppet task plan
bolt apply <manifest> Apply Puppet manifest code
bolt puppetfile install Install modules from a Puppetfile into a Boltdir
Run `bolt <subcommand> --help` to view specific examples.
where [options] are:
-n, --nodes NODES Identifies the nodes to target.
Enter a comma-separated list of node URIs or group names.
Or read a node list from an input file '@<file>' or stdin '-'.
Example: --nodes localhost,node_group,ssh://nix.com:23,winrm://windows.puppet.com
URI format is [protocol://]host[:port]
SSH is the default protocol; may be ssh, winrm, pcp, local, docker, remote
For Windows nodes, specify the winrm:// protocol if it has not be configured
For SSH, port defaults to `22`
For WinRM, port defaults to `5985` or `5986` based on the --[no-]ssl setting
-q, --query QUERY Query PuppetDB to determine the targets
--noop Execute a task that supports it in noop mode
--description DESCRIPTION Description to use for the job
--params PARAMETERS Parameters to a task or plan as json, a json file '@<file>', or on stdin '-'
Authentication:
-u, --user USER User to authenticate as
-p, --password [PASSWORD] Password to authenticate with. Omit the value to prompt for the password.
--private-key KEY Private ssh key to authenticate with
--[no-]host-key-check Check host keys with SSH
--[no-]ssl Use SSL with WinRM
--[no-]ssl-verify Verify remote host SSL certificate with WinRM
Escalation:
--run-as USER User to run as using privilege escalation
--sudo-password [PASSWORD] Password for privilege escalation. Omit the value to prompt for the password.
Run context:
-c, --concurrency CONCURRENCY Maximum number of simultaneous connections (default: 100)
--compile-concurrency CONCURRENCY
Maximum number of simultaneous manifest block compiles (default: number of cores)
--modulepath MODULES List of directories containing modules, separated by ':'
--boltdir FILEPATH Specify what Boltdir to load config from (default: autodiscovered from current working dir)
--configfile FILEPATH Specify where to load config from (default: ~/.puppetlabs/bolt/bolt.yaml)
--inventoryfile FILEPATH Specify where to load inventory from (default: ~/.puppetlabs/bolt/inventory.yaml)
Transports:
--transport TRANSPORT Specify a default transport: ssh, winrm, pcp, local, docker, remote
--connect-timeout TIMEOUT Connection timeout (defaults vary)
--[no-]tty Request a pseudo TTY on nodes that support it
--tmpdir DIR The directory to upload and execute temporary files on the target
Display:
--format FORMAT Output format to use: human or json
--[no-]color Whether to show output in color
-h, --help Display help
--verbose Display verbose logging
--debug Display debug logging
--trace Display error stack traces
--version Display the version
$ bolt command run "hostname" -n 172.16.0.10 -u vagrant --no-host-key-check -p
Please enter your password: (パスワードを入力)
Started on 172.16.0.10...
Finished on 172.16.0.10:
STDOUT:
testsv ← リモートホストで hostname コマンドを実行した結果
Successful on 1 node: 172.16.0.10
Ran on 1 node in 0.67 seconds
$ bolt script run myscript.sh -n 172.16.0.10 -u vagrant --no-host-key-check -p
Please enter your password: (パスワードを入力)
Started on 172.16.0.10...
Finished on 172.16.0.10:
STDOUT:
Hello, Bolt! (on testsv) ← リモートホストで myscript.sh を実行した結果
Successful on 1 node: 172.16.0.10
Ran on 1 node in 0.68 seconds
You can run scripts in any language as long as the appropriate interpreter is installed on the remote system. This includes Bash, PowerShell, or Python.
$ bolt task run service::linux name="postfix" action="stop" -n 172.16.0.10 -u vagrant --no-host-key-check -p --run-as root
Please enter your password: (パスワードを入力)
Started on 172.16.0.10...
Finished on 172.16.0.10:
{
"status": "postfix stop"
}
Successful on 1 node: 172.16.0.10
Ran on 1 node in 1.51 seconds
$ bolt task run package::linux action=install name=wget -n 172.16.0.10 -u vagrant --no-host-key-check -p --run-as root
Please enter your password:
Started on 172.16.0.10...
Finished on 172.16.0.10:
{
"status": "wget install"
}
Successful on 1 node: 172.16.0.10
Ran on 1 node in 1.97 seconds
$ bolt task show
facts Gather system facts
facts::bash Gather system facts using bash
facts::powershell Gather system facts using powershell
facts::ruby Gather system facts using ruby and facter
package Manage and inspect the state of packages
package::linux Manage the state of packages (without a puppet agent)
package::windows Manage the state of packages (without a puppet agent)
puppet_agent::install Install the Puppet agent package
puppet_agent::install_powershell
puppet_agent::install_shell
puppet_agent::version Get the version of the Puppet agent package installed. Returns nothing if nonepresent.
puppet_agent::version_powershell
puppet_agent::version_shell
puppet_conf Inspect puppet agent configuration settings
reboot Reboots a machine
reboot::last_boot_time Gets the last boot time of a Linux or Windows system
service Manage and inspect the state of services
service::linux Manage the state of services (without a puppet agent)
service::windows Manage the state of Windows services (without a puppet agent)
Use `bolt task show <task-name>` to view details and parameters for a specific task.
$ bolt task show service
service - Manage and inspect the state of services
USAGE:
bolt task run --nodes <node-name> service action=<value> name=<value> provider=<value>
PARAMETERS:
- action: Enum[start, stop, restart, enable, disable, status]
The operation (start, stop, restart, enable, disable, status) to perform on the service
- name: String[1]
The name of the service to operate on.
- provider: Optional[String[1]]
The provider to use to manage or inspect the service, defaults to the system service manager
MODULE:
built-in module
service::linux の情報
$ bolt task show service::linux
service::linux - Manage the state of services (without a puppet agent)
USAGE:
bolt task run --nodes <node-name> service::linux action=<value> name=<value>
PARAMETERS:
- action: Enum[start, stop, restart]
The operation (start, stop) to perform on the service
- name: String[1]
The name of the service to operate on.
MODULE:
built-in module
plan myweb::deploy (TargetSpec$nodes) {
run_task(
"package::linux",
$nodes,
name => "httpd",
action => "install"
)
run_task(
"service::linux",
$nodes,
name => "httpd",
action => "start"
)
upload_file(
"/vagrant/bolt/index.html",
"/var/www/html/index.html",
$nodes
)
}
bolt plan show でプランの定義を確認できます
$ bolt plan show --modulepath ./modules/
aggregate::count
aggregate::nodes
canary
facts
facts::info
myweb::deploy ← 作成したプラン
puppetdb_fact
reboot
Use `bolt plan show <plan-name>` to view details and parameters for a specific plan.
$ bolt plan run myweb::deploy nodes=172.16.0.10 --no-host-key-check -u vagrant -p --run-as root --modulepath ./modules/
Please enter your password: (パスワードを入力)
Starting: plan myweb::deploy
Starting: task package::linux on 172.16.0.10
Finished: task package::linux with 0 failures in 3.99 sec
Starting: task service::linux on 172.16.0.10
Finished: task service::linux with 0 failures in 1.3 sec
Starting: file upload from /vagrant/bolt/index.html to /var/www/html/index.html on 172.16.0.10
Finished: file upload from /vagrant/bolt/index.html to /var/www/html/index.html with 0 failures in 0.93 sec
Finished: plan myweb::deploy in 6.27 sec
Plan completed successfully with no result