Skip to main content

Chef: ChefDK

chefdk1chefdk2chefdk3chefdk4

  1. Create a linux machine, login into it and execute the following command:
    curl -s https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk

  2. Now we need to change the default ruby to point it to the chef ruby and not the system ruby. Execute the following command for it.
    echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profileNote:eval is part of POSIX. Its an interface which can be a shell built-in.Its described in the "POSIX Programmer's Manual": http://www.unix.com/man-page/posix/1posix/eval/
    eval - construct command by concatenating arguments

    It will take an argument and construct a command of it, which will be executed by the shell. This is the example of the manpage:
    1) foo=10 x=foo
    2) y='$'$x
    3) echo $y
    4) $foo
    5) eval y='$'$x
    6) echo $y
    7) 10


    1. In the first line you define $foo with the value '10' and $x with the value 'foo'.

    2. Now define $y, which consists of the string '$foo'. The dollar sign must be escaped with '$'.

    3. To check the result, echo $y.

    4. The result will be the string '$foo'

    5. Now we repeat the assignment with eval. It will first evaluate $x to the string 'foo'. Now we have the statement y=$foo which will get evaluated to y=10.

    6. The result of echo $y is now the value '10'.


    This is a common function in many languages, e.g. Perl and JavaScript.

  3. The chef shell-init bash command ouputs as follows:
    export PATH="/opt/chefdk/bin:/root/.chefdk/gem/ruby/2.4.0/bin:/opt/chefdk/embedded/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/chefdk/gitbin"
    export GEM_ROOT="/opt/chefdk/embedded/lib/ruby/gems/2.4.0"
    export GEM_HOME="/root/.chefdk/gem/ruby/2.4.0"
    export GEM_PATH="/root/.chefdk/gem/ruby/2.4.0:/opt/chefdk/embedded/lib/ruby/gems/2.4.0"
    _chef_comp() {
    local COMMANDS="exec env gem generate shell-init install update push push-archive show-policy diff provision export clean-policy-revisions clean-policy-cookbooks delete-policy-group delete-policy undelete verify"
    COMPREPLY=($(compgen -W "$COMMANDS" -- ${COMP_WORDS[COMP_CWORD]} ))
    }
    complete -F _chef_comp chef
    Thus eval command will execute the above arguments as a command and set all the necessary variables.

  4. We then add these variables in .bash_profile file so that it is loaded for all the shell termnals. So load the .bash_profile by executing source ~/.bash_profile
    Check by executing which chef and which ruby

  5.  Execute  chef -v to check chef version. Output will be as follows:
    chef-client version: 13.4.19
    delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
    berks version: 6.3.1
    kitchen version: 1.17.0
    inspec version: 1.36.1

  6. Then execute the following:
    yum install -y git yum-utils

  7. Then configure git name and email:
    git config --global user.name "Arati"
    git config --global user.email "aratik711@gmail.com"
    git config --global core.editor vi
    git config --global color.ui auto

  8. Add the docker repo with the following command:
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    yum makecache fast

  9. Install docker container Engine with the following command:
    yum -y install docker-ce

  10. Enable and start the docker service:
    systemctl enable docker
    systemctl start docker

  11. If you are not using the root user you will need to add your user to the docker group to execute docker commands:
    sudo usermod -aG docker $USER

  12. So as to avoid the systemd issue that occurs in the containers we will have to stop and disable the getty@tty1 service.
    getty is the generic name for a program which manages a terminal line and its connected terminal. Its purpose is to protect the system from unauthorized access. Generally, each getty process is started by systemd and manages a single terminal line.
    sudo systemctl stop getty@tty1.service
    sudo systemctl mask getty@tty1.service
    Create a test network:
    docker network create --subnet=10.1.1.0/24 testnet

  13. Then install docker driver so that the test-kitchen can use it:
    gem install kitchen-docker
    You might get an error as follows:
    Fetching: mixlib-shellout-2.3.2.gem (100%)
    ERROR: Error installing kitchen-docker:
    mixlib-shellout requires Ruby version >= 2.2.

    Then install the individual dependencies with the following commands:
    gem install mixlib-shellout -v 2.2.7

    gem install test-kitchen -v 1.16.0

    gem install kitchen-docker


Comments

Popular posts from this blog

Terraform

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied. The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc. The key features of Terraform are: Infrastructure as Code : Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and...

Salt stack issues

The function “state.apply” is running as PID Restart salt-minion with command:  service salt-minion restart No matching sls found for ‘init’ in env ‘base’ Add top.sls file in the directory where your main sls file is present. Create the file as follows: 1 2 3 base: 'web*' : - apache If the sls is present in a subdirectory elasticsearch/init.sls then write the top.sls as: 1 2 3 base: '*' : - elasticsearch.init How to execute saltstack-formulas create file  /srv/pillar/top.sls  with content: base : ' * ' : - salt create file  /srv/pillar/salt.sls  with content: salt : master : worker_threads : 2 fileserver_backend : - roots - git gitfs_remotes : - git://github.com/saltstack-formulas/epel-formula.git - git://github.com/saltstack-formulas/git-formula.git - git://github.com/saltstack-formulas/nano-formula.git - git://github.com/saltstack-f...

Helm: Installation and Configuration

PREREQUISITES You must have Kubernetes installed. We recommend version 1.4.1 or later. You should also have a local configured copy of  kubectl . Helm will figure out where to install Tiller by reading your Kubernetes configuration file (usually  $HOME/.kube/config ). This is the same file that  kubectl  uses. To find out which cluster Tiller would install to, you can run  kubectl config current-context or  kubectl cluster-info . $ kubectl config current-context my-cluster INSTALL HELM Download a binary release of the Helm client. You can use tools like  homebrew , or look at  the official releases page . For more details, or for other options, see  the installation guide . INITIALIZE HELM AND INSTALL TILLER Once you have Helm ready, you can initialize the local CLI and also install Tiller into your Kubernetes cluster in one step: $ helm init This will install Tiller into the Kubernetes cluster you saw with  kubectl config current-context . TIP:  Want to install into a different cl...