KNIFE-ENVIRONMENT(1)

NAME
knife-environment - The man page for the knife environment subcommand.

An environment is a way to map an organization's real-life workflow to what can be configured and managed when using server. Every organization begins with a single environment called the _default environment, which cannot be modified (or deleted). Additional environments can be created to reflect each organization's patterns and workflow. For example, creating production, staging, testing, and development environments. Generally, an environment is also associated with one (or more) cookbook versions.

The knife environment subcommand is used to manage environments within a single organization on the server.

COMMON OPTIONS

The following options may be used with any of the arguments available to the knife environment subcommand:

--chef-zero-port PORT
    The port on which chef-zero will listen.

-c CONFIG_FILE, --config CONFIG_FILE
    The configuration file to use.

-d, --disable-editing
    Indicates that $EDITOR will not be opened; data will be accepted as-is.

--defaults
    Indicates that Knife will use the default value, instead of asking a user to provide one.

-e EDITOR, --editor EDITOR
    The $EDITOR that is used for all interactive commands.

-E ENVIRONMENT, --environment ENVIRONMENT
    The name of the environment. When this option is added to a command, the command will run only against the named environment.

-F FORMAT, --format FORMAT
    The output format: summary (default), text, json, yaml, and pp.

-h, --help
    Shows help for the command.

-k KEY, --key KEY
    The private key that Knife will use to sign requests made by the API client to the server.

--[no-]color
    Indicates whether colored output will be used.

--print-after
    Indicates that data will be shown after a destructive operation.

-s URL, --server-url URL
    The URL for the server.

-u USER, --user USER
    The user name used by Knife to sign requests made by the API client to the server. Authentication will fail if the user name does not match the private key.

-V, --verbose
    Set for more verbose outputs. Use -VV for maximum verbosity.

-v, --version
    The version of the chef-client.

-y, --yes
    Indicates that the response to all confirmation prompts will be "Yes" (and that Knife will not ask for confirmation).

-z, --local-mode
    Indicates that the chef-client will be run in local mode, which allows all commands that work against the server to also work against the local chef-repo.

COMPARE

The compare argument is used to compare the cookbook version constraints that are set on one (or more) environments.

Syntax

This argument has the following syntax:

$ knife environment compare [ENVIRONMENT_NAME...] (options)

Options

This argument has the following options:

-a, --all
    Indicates that all environments found at the specified path will be uploaded.

-m, --mismatch
    Use to show only matching versions.

    Example

    To compare cookbook versions for a single environment:

    $ knife environment compare development

    to return something similar to:

               development
    apache     2.3.1
    windows    4.1.2

    To compare cookbook versions for multiple environments:

    $ knife environment compare development staging

    to return something similar to:

                  development    staging
    apache        2.3.1          1.2.2
    windows       4.1.2          1.0.0
    postgresql    1.0.0          1.0.0

    To compare all cookbook versions for all environments:

    $ knife environment compare --all

    to return something similar to:

                       staging  development
    ulimit             latest   latest
    redisio            latest   latest
    journly            latest   latest
    aws                latest   latest
    test               latest   latest
    unicorn            latest   latest
    sensu              latest   latest
    runit              latest   latest
    templater          latest   latest
    powershell         latest   latest
    openssl            latest   latest
    rbenv              latest   latest
    rabbitmq           latest   latest
    postgresql         latest   latest
    mysql              latest   latest
    ohai               latest   latest
    git                latest   latest
    erlang             latest   latest
    ssh_known_hosts    latest   latest
    nginx              latest   latest
    database           latest   latest
    yum                latest   latest
    xfs                latest   latest
    apt                latest   latest
    dmg                latest   latest
    chef_handler       latest   latest
    windows            1.0.0    4.1.2

CREATE

The create argument is used to add an environment object to the server. When this argument is run, Knife will open $EDITOR to enable editing of the ENVIRONMENT description field (unless a description is specified as part of the command). When finished, Knife will add the environment to the server.

Syntax

This argument has the following syntax:

$ knife environment create ENVIRONMENT_NAME -d DESCRIPTION

Options

This argument has the following options:

-d DESCRIPTION, --description DESCRIPTION
    The description of the environment. This value will populate the description field for the environment on the server.

    Examples

    To create an environment named "dev" with a description of "The development environment.":

    $ knife environment create dev -d "The development environment."

DELETE

The delete argument is used to delete an environment from a server.

Syntax

This argument has the following syntax:

$ knife environment delete ENVIRONMENT_NAME

Options

This command does not have any specific options.

Examples

To delete an environment named "dev", enter:

$ knife environment delete dev

Type Y to confirm a deletion.

EDIT

The edit argument is used to edit the attributes of an environment. When this argument is run, Knife will open $EDITOR to enable editing of ENVIRONMENT attributes. When finished, Knife will update the server with those changes.

Syntax

This argument has the following syntax:

$ knife environment edit ENVIRONMENT_NAME

Options

This command does not have any specific options.

Examples

To edit an environment named "devops", enter:

$ knife environment edit devops

FROM FILE

The from file argument is used to add or update an environment using a JSON or Ruby DSL description. It must be run with the create or edit arguments.

Syntax

This argument has the following syntax:

$ knife environment [create | edit] from file FILE (options)

Options

This argument has the following options:

-a, --all
    Indicates that all environments found at the specified path will be uploaded.

    Examples

    To add an environment using data contained in a JSON file:

    $ knife environment create devops from file "path to JSON file"

    or:

    $ knife environment edit devops from file "path to JSON file"

LIST

The list argument is used to list all of the environments that are currently available on the server.

Syntax

This argument has the following syntax:

$ knife environment list -w

Options

This argument has the following options:

-w, --with-uri
    Indicates that the corresponding URIs will be shown.

    Examples

    To view a list of environments:

    $ knife environment list -w

SHOW

The show argument is used to display information about the specified environment.

Syntax

This argument has the following syntax:

$ knife environment show ENVIRONMENT_NAME

Options

This command does not have any specific options.

Examples

To view information about the "dev" environment enter:

$ knife environment show dev

to return:

% knife environment show dev
chef_type:            environment
cookbook_versions:
default_attributes:
description:
json_class:           Chef::Environment
name:                 dev
override_attributes:
\\
\\
\\
\\

To view information in JSON format, use the -F common option as part of the command like this:

$ knife role show devops -F json

Other formats available include text, yaml, and pp.

AUTHOR
Chef