Skip to content

Instantly share code, notes, and snippets.

@sginkov
Last active September 27, 2018 20:18
Show Gist options
  • Select an option

  • Save sginkov/ed3fe2cb78fab07dff71 to your computer and use it in GitHub Desktop.

Select an option

Save sginkov/ed3fe2cb78fab07dff71 to your computer and use it in GitHub Desktop.

Revisions

  1. sginkov renamed this gist Apr 10, 2016. 1 changed file with 0 additions and 0 deletions.
  2. sginkov revised this gist May 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ gem install bundler && bundle install
    knife solo init .
    ```

    #### 3. Create Berkshelf config
    #### 3. Create Berkshelf config if it's not exist

    ```bash
    berks init .
  3. sginkov revised this gist May 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ 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
    knife solo init .
    ```

    #### 3. Create Berkshelf config
  4. sginkov revised this gist May 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Installation steps to use chef scripts

    #### 1. Install ruby and bundler
    #### 1. Install ruby
    #### 2. Added Gemfile with kinfe-solo

    ```
  5. sginkov revised this gist May 24, 2015. No changes.
  6. sginkov created this gist May 24, 2015.
    106 changes: 106 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,106 @@
    # Installation steps to use chef scripts

    #### 1. Install ruby and bundler
    #### 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
    ```