How do i install chef development kit (chef dk)?



  • Chef DK Install Link: https://docs.chef.io/install_dk.html

    This guide refers to a redhat installation.

    Install the chef df rpm using yum.

    $ sudo yum install https://packages.chef.io/files/stable/chefdk/1.5.0/el/7/chefdk-1.5.0-1.el7.x86_64.rpm
    

    The installation directory is /opt/chefdk.

    $  cd /opt/chefdk/
    $ ls
    bin       Gemfile       gitbin   LICENSES               version-manifest.txt
    embedded  Gemfile.lock  LICENSE  version-manifest.json
    

    After the yum package install has completed run chef verify.

    $ chef verify
    Running verification for component 'berkshelf'
    Running verification for component 'test-kitchen'
    Running verification for component 'tk-policyfile-provisioner'
    Running verification for component 'chef-client'
    Running verification for component 'chef-dk'
    Running verification for component 'chef-provisioning'
    Running verification for component 'chefspec'
    Running verification for component 'generated-cookbooks-pass-chefspec'
    Running verification for component 'rubocop'
    Running verification for component 'fauxhai'
    Running verification for component 'knife-spork'
    Running verification for component 'kitchen-vagrant'
    Running verification for component 'package installation'
    Running verification for component 'openssl'
    Running verification for component 'inspec'
    Running verification for component 'delivery-cli'
    Running verification for component 'git'
    Running verification for component 'opscode-pushy-client'
    Running verification for component 'chef-sugar'
    ...................................
    ---------------------------------------------
    Verification of component 'rubocop' succeeded.
    Verification of component 'kitchen-vagrant' succeeded.
    Verification of component 'openssl' succeeded.
    Verification of component 'delivery-cli' succeeded.
    Verification of component 'opscode-pushy-client' succeeded.
    Verification of component 'test-kitchen' succeeded.
    Verification of component 'fauxhai' succeeded.
    Verification of component 'git' succeeded.
    Verification of component 'berkshelf' succeeded.
    Verification of component 'chefspec' succeeded.
    Verification of component 'knife-spork' succeeded.
    Verification of component 'inspec' succeeded.
    Verification of component 'tk-policyfile-provisioner' succeeded.
    Verification of component 'chef-dk' succeeded.
    Verification of component 'chef-sugar' succeeded.
    Verification of component 'chef-client' succeeded.
    Verification of component 'generated-cookbooks-pass-chefspec' succeeded.
    Verification of component 'chef-provisioning' succeeded.
    Verification of component 'package installation' succeeded.
    

    You can choose to set the ruby version to the chef installed version, instead of the one included in the operating system repositories.

    OS installed version.

    $ which ruby
    /usr/bin/ruby
    $ ruby --version
    ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
    

    Set ruby version to the chef dk installed version.

    $ echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profile
    $ source .bash_profile
    $ which ruby
    /opt/chefdk/embedded/bin/ruby
    

    Install git latest or OS package repository version.
    see link: https://git-scm.com/download/linux

    $ sudo yum install git
    

    You can use one of two methods to create the chef-repo, using the starter kit with the chef-server or manually create it. This guide uses the manual method.

    $ chef generate app chef-repo
    

    Create the .chef directory. Which should contain the following files.

    • knife.rb
    • ORGANIZATION-validator.pem
    • USER.pem
    $ mkdir -p ~/chef-repo/.chef
    

    You chef-repo should contain these directories, mkdir them.
    chef-repo/
    .chef/ << the hidden directory
    certificates/
    config/
    cookbooks/
    data_bags
    environments/
    roles/

    Add entries to .gitignore file.

    $ pwd
    /home/chef/chef-repo
    $ echo '.chef' >> ~/chef-repo/.gitignore
    
    **Create an organization.** Example as per chef website link. The ORGANIZATION-validator.pem is stored in chef.key
    ```bash
    $ chef-server-ctl org-create chef "Chef Software, Inc." -f /tmp/chef.key
    

    Create a user. Example as per chef website.

    $ chef-server-ctl user-create grantmc Grant McLennan [email protected] p@s5w0rD! -f /tmp/grantmc.key
    

    Create a knife.rb file following the example from chef website. Replacing the pem file names for your file names.

    current_dir = File.dirname(__FILE__)
    log_level                :info
    log_location             STDOUT
    node_name                'node_name'
    client_key               "#{current_dir}/USER.pem"
    validation_client_name   'ORG_NAME-validator'
    validation_key           "#{current_dir}/ORGANIZATION-validator.pem"
    chef_server_url          'https://api.chef.io/organizations/ORG_NAME'
    cache_type               'BasicFile'
    cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
    cookbook_path            ["#{current_dir}/../cookbooks"]
    

    Add Ruby to the PATH.

    $ echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file
    $ echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile
    

    Fetch the ssl certificate from the chef server.

    $ knife ssl fetch
    WARNING: Certificates from goldenhost will be fetched and placed in your trusted_cert
    directory (/home/chef/chef-repo/.chef/trusted_certs).
    
    Knife has no means to verify these are the correct certificates. You should
    verify the authenticity of these certificates after downloading.
    
    Adding certificate for goldenhost in /home/chef/chef-repo/.chef/trusted_certs/goldenhost.crt
    

    Verify the workstation can connect to the chef server. In this example it just listed the server.

    $ knife client list
    goldenhost-validator
    

Log in to reply
 

© Lightnetics 2024