chef-run

chef-run is a tool to execute ad-hoc tasks on one or more target nodes using Chef.

chef-run <TARGET[S]> <RESOURCE> <RESOURCE_NAME> [PROPERTIES] [FLAGS]

Runs a single on the specified . [PROPERTIES] specify as key=value.

For example:

chef-run web01 service nginx
chef-run web01,web02 service nginx action=restart
chef-run web[1:2] service nginx priority=20 action=stop

chef-run <TARGET[S]> <RECIPE> [FLAGS]

Runs a single recipe located at on the specified .

For example:

chef-run web01 path/to/cookbook/recipe.rb
chef-run web01,web02 path/to/cookbook
chef-run web0[1:2] cookbook_name
chef-run web01 cookbook_name::recipe_name

ARGUMENTS:

  <TARGET[S]>       The hosts or IPs to target. Can also be an SSH or WinRM URLs
                    in the form:

                    ssh://[USERNAME]@example.com[:PORT]
  <RESOURCE>        A Chef resource, such as 'user' or 'package'
  <RESOURCE_NAME>   The name, usually used to specify what 'thing' to set up with
                    the resource. For example, given resource 'user', 'name' would be
                    the name of the user you wanted to create.
  <RECIPE>          The recipe to converge. This can be provided as one of:
                    1. Full path to a recipe file
                    2. Cookbook name. First we check the working directory for this
                       cookbook, then we check in the chef repository path. If a
                       cookbook is found we run the default recipe.
                    3. This behaves similarly to 'cookbook name' above, but it also allows
                       you to specify which recipe to use from the cookbook.

FLAGS:

    -c, --config PATH                  Location of config file. Defaults to /Users/username/.chef-workstation/config.toml
        --cookbook-repo-paths PATH     Comma separated list of cookbook repository paths.
    -h, --help                         Show help and usage for `chef-run`
    -i, --identity-file PATH           SSH identity file to use when connecting. Keys loaded into ssh-agent will also be used.
        --[no-]install                 Install Chef client on the target host(s) if it is not installed.
                                       This defaults to enabled - the installation will be performed
                                       if there is no Chef client on the target(s).
        --password <PASSWORD>          Password to use for authentication to the target(s). The same
                                       password will be used for all targets.
    -s, --[no-]ssl                     Use SSL for WinRM. Current default: false
    -s, --[no-]ssl-verify              Verify peer certificate when using SSL for WinRM
                                       Use --ssl-no-verify when using SSL for WinRM and
                                       the remote host is using a self-signed certificate.
                                       Current default: true
        --[no-]sudo                    Whether to use root permissions on the target. Default: true
        --sudo-command <COMMAND>       Command to use for administrative/root access. Defaults to 'sudo'.
        --sudo-options 'OPTIONS...'    Options to use with the sudo command. If there are multiple flags,
                                       quote them. For example: --sudo-options '-H -P -s'
        --sudo-password <PASSWORD>     Password to use with the sudo command.  This must be provided if
                                       password is required for sudo on the target(s). The same sudo password
                                       will be used for all targets.
        --user <USER>                  Username to use for authentication to the target(s). The same
                                       username will be used for all targets.
    -v, --version                      Show the current version of Chef Run.