Introduction
A Knife environment is a way to translate a company's actual process into what Chef Infra can configure and manage. Setting characteristics and pinning cookbooks at the environment level allows for this mapping. Depending on the system's designation, you can modify recipe setups using environments. For instance, you can provide the appropriate URL of a database server for each domain by defining various staging and production environments. By moving releases through testing environments before hitting production, settings enable organizations to confidently migrate new cookbook releases from staging to production.

In this article, we will see the different functions of the knife Environment in detail. So, Stay till the end, and Let's get started.
Compare
The cookbook version limits placed on one (or more) environments can be compared using the compare argument.
| Syntax | knife environment compare [ENVIRONMENT_NAME...] (options) |
| Options |
-a, --all (Upload all environment found at specified path) -m, –mismatch(show only mismatch versions) |
Examples
Compare cookbook versions for a single environment
knife environment compare development
Output
apache 2.3.1
windows 4.1.2
Compare cookbook versions for Multiple environments
knife environment compare development staging
Output
apache 2.3.1 1.2.2
windows 4.1.2 1.0.0
postgresql 1.0.0 1.0.0
Compare cookbook versions of all environment
knife environment compare --all
Output
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




