# Preparation of environment to use chef cookbook upload script

1. Install Chef DK (includes Berkshelf).
```sh
rpm -Uvh https://packages.chef.io/files/stable/chefdk/1.5.0/el/7/chefdk-1.5.0-1.el7.x86_64.rpm (Linux-only)
```
2. Install knife block plugin (this plugin enables the use of multiple *knife.rb* files against multiple chef servers).
```sh
chef gem install knife-block
```
3. Create with appropriate information a *knife-<chef_server_name>.rb* configuration file in your *~/.chef* directory for each Chef server that you wish to connect to.
4. Check if there is valid configuration.
```sh
knife block list
```
5. Knife block plugin creates a symlink from needed configuration to *knife.rb* by using the following command.
```sh
knife block use <chef_server_name>
```
6. Don't forget to set the correct path in the configuration file to your private key for Chef server.
7. Check Chef’s certificate
```sh
knife ssl check
```
8. Copy SSL certificate from Chef server to the *trusted_certs_dir* directory.
```sh
knife ssl fetch
```
9. Copy *chef_cookbook_upload.sh* file into cookbook’s directory.
10. Check if *Berksfile* and *metadata.rb* files are In the cookbook’s structure.
11. Run *chef_cookbook_upload.sh* script to upload current cookbook to all chef servers in the knife block list.
