Last active
September 27, 2018 20:18
-
-
Save sginkov/ed3fe2cb78fab07dff71 to your computer and use it in GitHub Desktop.
Chef solo usage example(Berkshelf, Vagrant)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Installation steps to use chef scripts | |
| #### 1. Install ruby | |
| #### 2. Added Gemfile with kinfe-solo | |
| ``` | |
| source "https://rubygems.org" | |
| gem "knife-solo" | |
| gem "berkshelf" | |
| ``` | |
| #### 3. Install chef solo with dependencies | |
| ```bash | |
| gem install bundler && bundle install | |
| ``` | |
| #### 3. Create a new directory structure(i.e. “kitchen”) that fits with Chef's standard structure and can be used to build and store recipes | |
| ```bash | |
| knife solo init . | |
| ``` | |
| #### 3. Create Berkshelf config | |
| ```bash | |
| berks init . | |
| ``` | |
| Script above creates file `Berksfile` which contains cookbook dependencies | |
| #### 4. Added cookbook dependencies to Berksfile | |
| Example: | |
| ``` | |
| source "https://supermarket.chef.io" | |
| metadata | |
| cookbook "mysql" | |
| cookbook "nginx", "~> 2.6" | |
| ``` | |
| #### 5. Install cookbook dependencies | |
| ```bash | |
| berks install | |
| ``` | |
| This command downloads required cookbooks and store it into `cookbooks` directory. | |
| # Deploy | |
| All nodes are located into directory 'nodes'. | |
| #### 1. First of all you should install chef-client on taget server | |
| ``` | |
| knife solo prepare [user]@[node] --forward-agent | |
| ``` | |
| Example for staging.com: | |
| ```bash | |
| knife solo prepare root@staging.com --forward-agent | |
| ``` | |
| #### 2. You should execute the following command to run chef script for you node: | |
| ```bash | |
| knife solo cook [user]@[node] --forward-agent | |
| ``` | |
| Example for staging.com: | |
| ```bash | |
| knife solo cook root@staging.com --forward-agent | |
| ``` | |
| # Testing chef scripts with vagrant | |
| Vagrant helps to create virtual host on your local machine which used for emulating external virtual hosts. | |
| ## Installation vagrant steps | |
| #### 1. Install virtualbox and vagrant | |
| #### 2. Install vagrant plugins | |
| ``` | |
| vagrant plugin install vagrant-hostsupdater | |
| ``` | |
| #### 3. Add dummy box from https://atlas.hashicorp.com/boxes/search | |
| ``` | |
| vagrant box add precise32 http://files.vagrantup.com/precise32.box | |
| vagrant box add ubuntu-14.04 https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box | |
| ``` | |
| #### 4. Start vagrant | |
| This command create local virtual hosts which described into Vagrantfile. | |
| ``` | |
| vagrant up | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment